import 'dart:async'; import 'package:fikoyt_mesaici/apps/mesaici/model/ayarlar/model_ayarlar.dart'; import 'package:fikoyt_mesaici/core/Extensions/fiko_double_ext.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:fikoyt_ui/ui/themes/table_theme.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../model/calisma_kayit/calisma_kayit.dart'; class BrutMaasTablosu extends StatefulWidget { BrutMaasTablosu({super.key, required this.kayit}); final Rx? kayit; @override State createState() => _BrutMaasTablosuState(); } class _BrutMaasTablosuState extends State { Rx normalMesaiUcreti$ = Rx(0.0); Rx fazlaMesaiUcreti$ = Rx(0.0); Rx toplamBrutEkUcretler$ = Rx(0.0); Rx toplamBrutUcretler$ = Rx(0.0); late Timer timer$; @override void initState() { normalMesaiUcreti$.value = widget.kayit?.value?.brutNormal ?? 0.0; fazlaMesaiUcreti$.value = widget.kayit?.value?.brutFazlaMesai ?? 0.0; toplamBrutEkUcretler$.value = widget.kayit?.value?.ekOdemeler?.toplam() ?? 0.0; toplamBrutUcretler$.value = widget.kayit?.value?.brutToplam ?? 0.0; timer$ = Timer.periodic( const Duration(seconds: 1), (timer) async { normalMesaiUcreti$.value = widget.kayit?.value?.brutNormal ?? 0.0; fazlaMesaiUcreti$.value = widget.kayit?.value?.brutFazlaMesai ?? 0.0; toplamBrutEkUcretler$.value = widget.kayit?.value?.ekOdemeler?.toplam() ?? 0.0; toplamBrutUcretler$.value = widget.kayit?.value?.brutToplam ?? 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: Theme.of(context).extension()?.titleBackgroundColor, ), child: const Text( "B. Maaş", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), ), ), Expanded( child: Container( alignment: Alignment.center, decoration: BoxDecoration( color: Theme.of(context).extension()?.titleBackgroundColor, ), child: const Text( "B. Fazla Mesai", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), ), ), Expanded( child: Container( alignment: Alignment.center, decoration: BoxDecoration( color: Theme.of(context).extension()?.titleBackgroundColor, ), child: const Text( "B. Ek Ücret", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: Obx( () => AnimatedNumberFikoYTButton( // key: ValueKey("${toplamBrutEkUcretler$.value?.toPrecision(2) ?? 0.0} TL"), text: normalMesaiUcreti$.value, textBuilder: (tweenValue) => tweenValue.toParaBirimi(), tema: FikoYTButtonTheme( fontSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Theme.of(context).extension()?.dataSuccesTextColor, textStrokeColor: Colors.transparent, radius: 0, backgroundColor: Theme.of(context).extension()?.dataBackgroundColor, ), onPressed: () {}, ), ), ), Expanded( child: Obx( () => AnimatedNumberFikoYTButton( // key: ValueKey("${toplamBrutEkUcretler$.value?.toPrecision(2) ?? 0.0} TL"), text: fazlaMesaiUcreti$.value, textBuilder: (tweenValue) => tweenValue.toParaBirimi(), tema: FikoYTButtonTheme( fontSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Theme.of(context).extension()?.dataSuccesTextColor, textStrokeColor: Colors.transparent, radius: 0, backgroundColor: Theme.of(context).extension()?.dataBackgroundColor, ), onPressed: () {}, ), ), ), Expanded( child: Obx( () => AnimatedNumberFikoYTButton( // key: ValueKey("${toplamBrutEkUcretler$.value?.toPrecision(2) ?? 0.0} TL"), text: toplamBrutEkUcretler$.value, textBuilder: (tweenValue) => tweenValue.toParaBirimi(), tema: FikoYTButtonTheme( fontSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Theme.of(context).extension()?.dataSuccesTextColor, textStrokeColor: Colors.transparent, radius: 0, backgroundColor: Theme.of(context).extension()?.dataBackgroundColor, ), onPressed: () {}, ), ), ), ], ), /** */ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: Obx( () => AnimatedNumberFikoYTButton( text: toplamBrutUcretler$.value, textBuilder: (tweenValue) => "Brüt Toplam -> ${tweenValue.toParaBirimi()}", tema: FikoYTButtonTheme( fontSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Theme.of(context).extension()?.infoTextColor, //Colors.blueAccent, textStrokeColor: Colors.transparent, radius: 0, backgroundColor: Theme.of(context).extension()?.infoBackgroundColor, //Colors.yellow.shade100, ), onPressed: () {}, ), ), ), ], ), // 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 Fazla 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: oncekiMesaiUcreti$.value, // Başlangıç değeri // end: normalMesaiUcreti$.value), // Bitiş değeri // duration: const Duration(milliseconds: 900), // Animasyon süresi // builder: (context, value, child) { // return Expanded( // child: FikoYTButton( // key: ValueKey("${normalMesaiUcreti$.value.toPrecision(2)} TL"), // text: "${value.toPrecision(2).toStringAsFixed(2)} TL", // textSize: 12, // edgePadding: const EdgeInsets.symmetric(vertical: 2.0), // textColor: Colors.red, // textStrokeColor: Colors.transparent, // radius: 0, // backColor: Theme.of(context).extension()?.dataBackgroundColor, // onPressed: () {}, // ), // ); // }, // ), // ), // Obx( // () => TweenAnimationBuilder( // tween: Tween( // begin: oncekiFazlaMesaiUcreti$.value, // Başlangıç değeri // end: fazlaMesaiUcreti$.value), // Bitiş değeri // duration: const Duration(milliseconds: 900), // Animasyon süresi // builder: (context, value, child) { // return Expanded( // child: FikoYTButton( // key: ValueKey("${fazlaMesaiUcreti$.value.toPrecision(2)} TL"), // text: "${value.toPrecision(2).toStringAsFixed(2)} TL", // textSize: 12, // edgePadding: const EdgeInsets.symmetric(vertical: 2.0), // textColor: Colors.red, // textStrokeColor: Colors.transparent, // radius: 0, // backColor: Theme.of(context).extension()?.dataBackgroundColor, // onPressed: () {}, // ), // ); // }, // ), // ), // Obx( // () => TweenAnimationBuilder( // tween: Tween( // begin: oncekiBrutEkUcetler$.value, // Başlangıç değeri // end: toplamBrutEkUcretler$.value), // Bitiş değeri // duration: const Duration(milliseconds: 900), // Animasyon süresi // builder: (context, value, child) { // return Expanded( // child: FikoYTButton( // key: ValueKey("${toplamBrutEkUcretler$.value.toPrecision(2)} TL"), // text: "${value.toPrecision(2).toStringAsFixed(2)} TL", // textSize: 12, // edgePadding: const EdgeInsets.symmetric(vertical: 2.0), // textColor: Colors.red, // textStrokeColor: Colors.transparent, // radius: 0, // backColor: Theme.of(context).extension()?.dataBackgroundColor, // onPressed: () {}, // ), // ); // }, // ), // ), // ], // ), ], ); } }