import 'dart:async'; import 'package:fikoyt_mesaici/core/widgets/fiko_ui/fiko_button/fiko_button.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../model/calisma_kayit/calisma_kayit.dart'; class NetMaasTablosu extends StatefulWidget { NetMaasTablosu({super.key, required this.kayit}); final Rx? kayit; @override State createState() => _NetMaasTablosuState(); } class _NetMaasTablosuState extends State { Rx normalNetMaas$ = Rx(0.0); Rx fazlaMesaiUcreti$ = Rx(0.0); Rx toplamNetEkUcretler$ = Rx(0.0); Rx toplamNetUcretler$ = Rx(0.0); late Timer timer$; @override void initState() { normalNetMaas$.value = widget.kayit?.value?.hesaplamalar.odenecekUcret ?? 0.0; fazlaMesaiUcreti$.value = widget.kayit?.value?.hesaplamalar.netFazlaMesai ?? 0.0; toplamNetUcretler$.value = widget.kayit?.value?.hesaplamalar.netNormalUcret ?? 0.0; timer$ = Timer.periodic( const Duration(seconds: 1), (timer) async { await widget.kayit?.value?.hesaplamalar.hesapla(); normalNetMaas$.value = widget.kayit?.value?.hesaplamalar.odenecekUcret ?? 0.0; fazlaMesaiUcreti$.value = widget.kayit?.value?.hesaplamalar.netFazlaMesai ?? 0.0; toplamNetEkUcretler$.value = widget.kayit?.value?.hesaplamalar.netEkUcretler ?? 0.0; toplamNetUcretler$.value = widget.kayit?.value?.hesaplamalar.netNormalUcret ?? 0.0; }, ); super.initState(); } @override void dispose() { timer$.cancel(); super.dispose(); } @override Widget build(BuildContext context) { return Column( children: [ Row( children: [ Expanded( child: Container( alignment: Alignment.center, decoration: BoxDecoration( color: Colors.blue.shade400, ), child: const Text( "Net Maaş", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), ), ), Expanded( child: Container( alignment: Alignment.center, decoration: BoxDecoration( color: Colors.blue.shade400, ), child: const Text( "Net F. Mesai", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), ), ), Expanded( child: Container( alignment: Alignment.center, decoration: BoxDecoration( color: Colors.blue.shade400, ), child: const Text( "Net Ek Ücret", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Obx( () => TweenAnimationBuilder( tween: Tween( begin: oncekiNetMaas$.value ?? 0.0, // Başlangıç değeri end: normalNetMaas$.value ?? 0.0, ), // Bitiş değeri duration: const Duration(milliseconds: 900), // Animasyon süresi builder: (context, value, child) { return Expanded( child: FikoButton1( // key: ValueKey("${normalMesaiUcreti$.value?.toPrecision(2) ?? 0.0} TL"), text: "${(value.isNaN || value.isInfinite) ? 0 : value.toPrecision(2).toStringAsFixed(2)} TL", textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Colors.red, textStrokeColor: Colors.transparent, radius: 0, backColor: Colors.grey.shade200, onPressed: () {}, ), ); }, ), ), Obx( () => TweenAnimationBuilder( tween: Tween( begin: oncekiFazlaMesaiUcreti$.value ?? 0.0, // Başlangıç değeri end: fazlaMesaiUcreti$.value ?? 0.0, ), // Bitiş değeri duration: const Duration(milliseconds: 900), // Animasyon süresi builder: (context, value, child) { return Expanded( child: FikoButton1( // key: ValueKey("${fazlaMesaiUcreti$.value?.toPrecision(2) ?? 0.0} TL"), text: "${(value.isNaN || value.isInfinite) ? 0 : value.toPrecision(2).toStringAsFixed(2)} TL", textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Colors.red, textStrokeColor: Colors.transparent, radius: 0, backColor: Colors.grey.shade200, onPressed: () {}, ), ); }, ), ), Obx( () => Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ AnimatedNumberFikoButton1( text: toplamNetEkUcretler$.value, textBuilder: (tweenValue) => "${tweenValue.toPrecision(2).toStringAsFixed(2)} TL", textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Colors.blueAccent, textStrokeColor: Colors.transparent, radius: 0, backColor: Colors.yellow.shade100, onPressed: () {}, ), ]), ), ], ), /** */ Obx( () => Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ AnimatedNumberFikoButton1( text: toplamNetUcretler$.value, textBuilder: (tweenValue) => "Ödenecek Tutar -> ${tweenValue.toPrecision(2).toStringAsFixed(2)} TL", textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Colors.blueAccent, textStrokeColor: Colors.transparent, radius: 0, backColor: Colors.yellow.shade100, onPressed: () {}, ), ]), ), ], ); } }