import 'dart:async'; import 'package:fikoyt_mesaici/apps/mesaici/widgets/aktif_kart/calisma_suresi_sec.dart'; import 'package:fikoyt_mesaici/apps/mesaici/widgets/aktif_kart/saat_tablosu/cikis_secici.dart'; import 'package:fikoyt_mesaici/apps/mesaici/widgets/aktif_kart/saat_tablosu/giris_secici.dart'; import 'package:fikoyt_mesaici/apps/mesaici/widgets/aktif_kart/saat_tablosu/molalar.dart'; import 'package:fikoyt_mesaici/apps/mesaici/widgets/aktif_kart/saat_tablosu/saat_tablosu_dialog_mesai_carpani.dart'; import 'package:fikoyt_mesaici/core/Extensions/fiko_build_context.dart'; import 'package:fikoyt_mesaici/core/Extensions/fiko_duration_ext.dart'; import 'package:fikoyt_mesaici/core/Extensions/fiko_tarih.dart'; import 'package:fikoyt_mesaici/core/fikoyt.service.dart'; import 'package:fikoyt_mesaici/core/interface/fiko_dialog_ayarlari.dart'; import 'package:fikoyt_mesaici/core/widgets/fiko_ui/fiko_button/fiko_button.dart'; import 'package:fikoyt_mesaici/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:get/get.dart'; import 'package:vrouter/vrouter.dart'; import '../../../model/calisma_kayit/calisma_kayit.dart'; import '../../../model/ayarlar/model_ayarlar.dart'; class SaatTablosu extends StatefulWidget { SaatTablosu({super.key, required this.kayit}); final Rx? kayit; @override State createState() => _SaatTablosuState(); } class _SaatTablosuState extends State { Rx? normalMesai$ = Rx(null); Rx? fazlaMesai$ = Rx(null); Rx? yasananMola$ = Rx(null); // FikoYTMesaiciService FikoYTService.servisMesaici = Get.put(FikoYTMesaiciService()); FikoYTService servisFikoYT = FikoYTService(); late Timer timer$; @override void initState() { normalMesai$?.value = widget.kayit?.value?.normalMesai; fazlaMesai$?.value = widget.kayit?.value?.fazlaMesai; yasananMola$?.value = widget.kayit?.value!.yasananMolaSuresi; timer$ = Timer.periodic( const Duration(seconds: 1), (timer) async { normalMesai$?.value = widget.kayit?.value?.normalMesai; fazlaMesai$?.value = widget.kayit?.value?.fazlaMesai; yasananMola$?.value = widget.kayit?.value!.yasananMolaSuresi; }, ); super.initState(); } @override void dispose() { timer$.cancel(); super.dispose(); } @override Widget build(BuildContext context) { return Column( children: [ Row( children: [ Expanded( child: Column( children: [ Text( "Giriş", style: TextStyle(color: FikoTheme.of(context).saatTabloBaslikRenk, fontWeight: FontWeight.bold), ), ], ), ), Expanded( child: Column( children: [ Obx( () => Text( "Mola(${widget.kayit?.value?.molalar?.toplamMola.insanize ?? 'Yok'})", style: TextStyle(color: FikoTheme.of(context).saatTabloBaslikRenk, fontWeight: FontWeight.bold), ), ), ], ), ), Expanded( child: Column( children: [ Text( "Çıkış", style: TextStyle(color: FikoTheme.of(context).saatTabloBaslikRenk, fontWeight: FontWeight.bold), ), ], ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: Obx( () => FikoButton1( text: widget.kayit?.value?.giris != null ? "${widget.kayit?.value?.giris?.formatla('HH:mm:ss')}" : "Seçiniz", textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: widget.kayit?.value?.giris == null ? context.tema.tabloHataliYaziRenk : context.miKoyuMod ? context.tema.tabloGecerliYaziRenk, textStrokeColor: Colors.transparent, radius: 0, backColor: FikoTheme.of(context).saatTabloVeriArkaPlanRenk, onPressed: () { FikoYTService.dialogGoster( context, GirisSecici( kayit: widget.kayit, ), FikoDialogAyarlari( altButonlar: [ TextButton( onPressed: () { widget.kayit?.value?.giris = null; widget.kayit?.refresh(); Navigator.pop(context); }, child: const Text( "Girişi Sil", style: TextStyle(color: Colors.redAccent, fontWeight: FontWeight.bold), ), ), const Spacer(), TextButton( onPressed: () { Navigator.pop(context); }, child: const Text( "Kapat", style: TextStyle(color: Colors.green, fontWeight: FontWeight.bold), ), ), ], baslik: "Giriş Saatiniz", baslikSimge: "🕙", ), ); }, ), ), ), Expanded( child: Obx( () => FikoButton1( text: "${yasananMola$?.value?.insanize ?? '❌ Yok'}", textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Colors.red, textStrokeColor: Colors.transparent, radius: 0, backColor: FikoTheme.of(context).saatTabloVeriArkaPlanRenk, onPressed: () async { FikoYTService.dialogGoster( context, MolalarWidget( kayit: widget.kayit, ), FikoDialogAyarlari( baslik: "Mola Ekle", baslikSimge: "🕙", arkaPlanaTiklanincaKapansin: false, altButonlar: [ TextButton( onPressed: () { widget.kayit?.value?.molalar = []; widget.kayit?.refresh(); Navigator.pop(context); }, child: const Text( "Temizle", style: TextStyle(color: Colors.redAccent, fontWeight: FontWeight.bold), ), ), const Spacer(), TextButton( onPressed: () { widget.kayit?.refresh(); FikoYTService.servisMesaici.ayarlarModel!.refresh(); Navigator.pop(context); }, child: const Text( "Kapat", style: TextStyle(color: Colors.green, fontWeight: FontWeight.bold), ), ), ], ), ); }, ), ), ), Expanded( child: Obx( () => FikoButton1( text: widget.kayit?.value?.cikis != null ? "${widget.kayit?.value?.cikis?.formatla('HH:mm:ss')}" : "Seçiniz", textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: widget.kayit?.value?.cikis == null ? Colors.red : Colors.green, textStrokeColor: Colors.transparent, radius: 0, backColor: FikoTheme.of(context).saatTabloVeriArkaPlanRenk, onPressed: () async { FikoYTService.dialogGoster( context, CikisSecici( kayit: widget.kayit, ), FikoDialogAyarlari( altButonlar: [ TextButton( onPressed: () { widget.kayit?.value?.cikis = null; widget.kayit?.refresh(); Navigator.pop(context); }, child: const Text( "Çıkışı Sil", style: TextStyle(color: Colors.redAccent, fontWeight: FontWeight.bold), ), ), const Spacer(), TextButton( onPressed: () { Navigator.pop(context); }, child: const Text( "Kapat", style: TextStyle(color: Colors.green, fontWeight: FontWeight.bold), ), ), ], baslik: "Çıkış Saatiniz", baslikSimge: "🕙", ), ); }, ), ), ), ], ), Row( children: [ Expanded( child: Column( children: [ Text( "F.Mesai Oranı", style: TextStyle(color: FikoTheme.of(context).saatTabloBaslikRenk, fontWeight: FontWeight.bold), ), ], ), ), Expanded( child: Column( children: [ Text( "Çalışma Süresi", style: TextStyle(color: FikoTheme.of(context).saatTabloBaslikRenk, fontWeight: FontWeight.bold), ), ], ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: Obx( () => FikoButton1( text: "%${widget.kayit?.value?.mesaiOrani?.toStringAsFixed(3) ?? 0.000.toStringAsFixed(3)}", textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Colors.green, textStrokeColor: Colors.transparent, radius: 0, backColor: FikoTheme.of(context).saatTabloVeriArkaPlanRenk, onPressed: () async { FikoYTService.dialogGoster( context, SaatTablosuMesaiCarpani(kayit: widget.kayit), FikoDialogAyarlari( altButonlar: [ TextButton( onPressed: () { widget.kayit?.value?.mesaiOrani = 0.00; widget.kayit?.refresh(); context.vRouter.pop(); }, child: const Text( "Çarpanı Sıfırla", style: TextStyle(color: Colors.redAccent, fontWeight: FontWeight.bold), ), ), const Spacer(), TextButton( onPressed: () { context.vRouter.pop(); // Navigator.of(context, rootNavigator: true).pop(); }, child: const Text( "Kapat", style: TextStyle(color: Colors.green, fontWeight: FontWeight.bold), ), ), ], baslik: "Mesai Çarpanı", baslikSimge: "✨", ), ); }, ), ), ), Expanded( child: Obx( () => FikoButton1( text: "${widget.kayit?.value?.calismaSuresi?.insanize ?? 'Yok'}", textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Colors.yellow, textStrokeColor: Colors.red, textStrokeWidth: 2, radius: 0, backColor: FikoTheme.of(context).saatTabloVeriArkaPlanRenk, onPressed: () { FikoYTService.dialogGoster( context, CalismaSuresiSecWidget(kayit: widget.kayit), FikoDialogAyarlari(baslik: "Çalışma Süresi", baslikSimge: "🛠️", altButonlar: [ TextButton( onPressed: () { widget.kayit?.value?.calismaSuresi = null; widget.kayit?.refresh(); context.vRouter.pop(); }, child: const Text( "Sıfırla", style: TextStyle(color: Colors.redAccent, fontWeight: FontWeight.bold), ), ), const Spacer(), TextButton( onPressed: () { context.vRouter.pop(); // Navigator.of(context, rootNavigator: true).pop(); }, child: const Text( "Kapat", style: TextStyle(color: Colors.green, fontWeight: FontWeight.bold), ), ), ]), ); }, ), ), ), ], ), Row( children: [ Expanded( child: Column( children: [ Text( "Normal Mesai", style: TextStyle(color: FikoTheme.of(context).saatTabloBaslikRenk, fontWeight: FontWeight.bold), ), ], ), ), Expanded( child: Column( children: [ Text( "Fazla Mesai", style: TextStyle(color: FikoTheme.of(context).saatTabloBaslikRenk, fontWeight: FontWeight.bold), ), ], ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: Obx( () => Row( children: [ Visibility( visible: ((normalMesai$?.value ?? Duration.zero) == (widget.kayit?.value?.calismaSuresi ?? Duration.zero)) && (normalMesai$?.value != Duration.zero), child: FikoButton1( text: '✔️', textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Colors.red, textStrokeColor: Colors.transparent, radius: 0, backColor: FikoTheme.of(context).saatTabloVeriArkaPlanRenk, ), ), Visibility( visible: ((normalMesai$?.value ?? Duration.zero) < (widget.kayit?.value?.calismaSuresi ?? Duration.zero)) && (normalMesai$?.value != Duration.zero), child: FikoButton1( text: '⛔', textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Colors.red, textStrokeColor: Colors.transparent, radius: 0, backColor: FikoTheme.of(context).saatTabloVeriArkaPlanRenk, ), ), Expanded( child: FikoButton1( text: "${normalMesai$?.value?.insanize ?? '❌ Yok'}", textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: ((normalMesai$?.value ?? Duration.zero) == (widget.kayit?.value?.calismaSuresi ?? Duration.zero)) && (normalMesai$?.value != Duration.zero) ? Colors.green : Colors.red, textStrokeColor: Colors.transparent, radius: 0, backColor: FikoTheme.of(context).saatTabloVeriArkaPlanRenk, onPressed: () {}, ), ), Visibility( visible: (fazlaMesai$?.value ?? Duration.zero) > Duration.zero && (normalMesai$?.value != Duration.zero), child: FikoButton1( text: '➕', textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Colors.red, textStrokeColor: Colors.transparent, radius: 0, backColor: FikoTheme.of(context).saatTabloVeriArkaPlanRenk, ), ), ], ), ), ), Expanded( child: Obx( () => FikoButton1( text: "${fazlaMesai$?.value?.insanize ?? '❌ Yok'}", textSize: 12, edgePadding: const EdgeInsets.symmetric(vertical: 2.0), textColor: Colors.red, textStrokeColor: Colors.transparent, radius: 0, backColor: FikoTheme.of(context).saatTabloVeriArkaPlanRenk, onPressed: () {}, ), ), ), ], ), ], ).animate(effects: [ FadeEffect( duration: 1000.ms, ), SaturateEffect(delay: 1000.ms, duration: 500.ms, curve: Curves.easeIn), BlurEffect( duration: 600.ms, begin: const Offset(3, 3), end: const Offset(0, 0), ), ShimmerEffect( delay: 1000.ms, duration: 1000.ms, curve: Curves.easeIn, ), ]); } }