// ignore_for_file: library_private_types_in_public_api import 'package:fikoyt_mesaici/apps/mesaici/base_page_mesaici_view.dart'; import 'package:fikoyt_mesaici/apps/mesaici/model/alt_kart/alt_kart.dart'; import 'package:fikoyt_mesaici/apps/mesaici/model/model_hareketler.dart'; import 'package:fikoyt_mesaici/apps/mesaici/pages/hareketler/hareket_kart/hareket_kart.dart'; import 'package:fikoyt_mesaici/apps/mesaici/widgets/kullanici_bilgi_navigasyon/kullanici_bilgi_navigasyon.dart'; import 'package:fikoyt_mesaici/apps/mesaici/widgets/uygulama_baslik/uygulama_baslik.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/base_page/base_page_view.dart'; import 'package:fikoyt_mesaici/core/widgets/fikoyt_elastic/fikoyt_elastic.dart'; import 'package:fikoyt_mesaici/core/widgets/yazi_kutulari/yazi_kutulari.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:fikoyt_ui/ui/fiko_serit_ana.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:get/get.dart'; import 'package:isar/isar.dart'; import 'package:vrouter/vrouter.dart'; import 'package:fikoyt_mesaici/core/Extensions/fiko_tarih.dart'; class PageMesaiciGunHareketlerLogic extends GetxController { BasePageLogic basePageLogic = Get.put(BasePageLogic()); BasePageMesaiciLogic basePageMesaiciLogic = Get.put(BasePageMesaiciLogic()); //---> // final FikoYTMesaiciService FikoYTService.servisMesaici = Get.put(FikoYTMesaiciService()); final FikoYTService servisFikoYT = FikoYTService(); //---> Rx gun = Rx(null); Rx?> hareketler = Rx?>(null); Rx?> altKartlar = Rx?>(null); Future?> alHareketler() async { DateTime? tarih; tarih = DateTime(2024).formattan("dd.MM.yyyy EEEE", gun.value); hareketler.value = await FikoYTService.servisMesaici.isar!.modelHareketlers.where().filter().turuEqualTo(KartTuru.CALISMA_KARTI).calismaKarti((q) => q.tarihBetween(tarih?.ilkSaatler(), tarih?.sonSaatler())).findAll(); // for (var i = 0; i < (hareketler.value ?? []).length; i++) { // await hareketler.value?[i].altKartlar.load(); // } // await hareketler.value?.altKartlar.load(); hareketler.refresh(); return hareketler.value; } Future?> alAltHareketler() async { DateTime? tarih; tarih = DateTime(2024).formattan("dd.MM.yyyy EEEE", gun.value); altKartlar.value = (await FikoYTService.servisMesaici.isar!.modelHareketlers.where().filter().turuEqualTo(KartTuru.ALT_KART).ustKart((q) => q.tarihBetween(tarih?.ilkSaatler(), tarih?.sonSaatler())).altKartIsNotNull().or().altKartIsNotNull().turuEqualTo(KartTuru.ALT_KART).tarihBetween(tarih?.ilkSaatler(), tarih?.sonSaatler()).ustKartIsNull().findAll()); print(altKartlar.value); for (var i = 0; i < (altKartlar.value ?? []).length; i++) { await altKartlar.value?[i].altKartlar.load(); } // await hareketler.value?.altKartlar.load(); altKartlar.refresh(); return altKartlar.value; } Future aciklamaEkle(BuildContext context, AltKart altKart) async { return FikoYTService.dialogGoster( context, SizedBox( width: 250, child: FikoAciklamaKutusu( baslik: "Açıklama Metni", radius: 5.0, degeri: altKart.aciklama, yaziBoyutu: 12.0, degisti: (value) { altKart.aciklama = value; }, ), ), FikoDialogAyarlari(baslik: "Açıklama Ekle", baslikSimge: "➕", altButonlar: [ FikoButton( text: "Ekle", tema: FikoButtonTheme( textColor: Colors.green, textStrokeColor: Colors.transparent, edgePadding: const EdgeInsets.symmetric(horizontal: 5, vertical: 0), ), onPressed: (() { Navigator.pop(context, altKart); }), ), const Spacer(), FikoButton( text: "Kapat", tema: FikoButtonTheme( textColor: Colors.red, textStrokeColor: Colors.transparent, edgePadding: const EdgeInsets.symmetric(horizontal: 5, vertical: 0), ), onPressed: (() { Navigator.pop( context, ); }), ), ]), ); } } class PageMesaiciGunHareketler extends StatefulWidget { PageMesaiciGunHareketler({super.key, required this.gun}); dynamic gun; @override _PageMesaiciGunHareketlerState createState() => _PageMesaiciGunHareketlerState(); } class _PageMesaiciGunHareketlerState extends State { PageMesaiciGunHareketlerLogic logic = Get.put(PageMesaiciGunHareketlerLogic()); @override void initState() { SchedulerBinding.instance.addPostFrameCallback((_) async { logic.gun.value = widget.gun; await logic.alHareketler(); await logic.alAltHareketler(); logic.gun.refresh(); logic.basePageLogic.subTitle.value = "📝 Gün Hareketleri"; }); // widget.kartId = DateTime.now().formatla("dd.MM.yyyy EEEE"); super.initState(); } @override void dispose() { Get.delete(); super.dispose(); } @override Widget build(BuildContext context) { ScreenSizeTypes screenType = FikoYTElastic.getScreenSizeType(context); [ // ScreenSizeTypes.small, ScreenSizeTypes.mini, ScreenSizeTypes.extraMini ].contains(screenType); return FikoSeritAna( leading: const UygulamaBaslikSol(), title: UygulamaBaslikOrta(), actions: const [ UygulamaBaslikSag(), ], headerWidget: PageView( children: [ Container( color: Colors.transparent, //Colors.orange, height: 300 - kToolbarHeight - 10, margin: const EdgeInsets.only(top: kToolbarHeight, bottom: 10, right: 10, left: 10), child: KullaniciBilgiNavigasyon( simge: const Text( "📝", style: TextStyle( fontSize: 54, ), ), ), ), ], ), body: [ // Obx( // () => Text(logic.hareketler.value?.toString() ?? "Yok"), // ), /** */ /** */ Row( children: [ FikoButton( text: "<", tema: FikoButtonTheme( fontSize: 16, edgePadding: const EdgeInsets.symmetric(horizontal: 5), textColor: Theme.of(context).extension()?.textColor, ), onPressed: () { context.vRouter.to("/mesaici/hareketler/gun-hareketleri/${DateTime(2024).formattan('dd.MM.yyyy EEEE', logic.gun.value)?.subtract(Duration(days: 1)).formatla('dd.MM.yyyy EEEE')}"); }, ), Expanded( child: Obx( () => AnimatedFikoButton1( text: "${logic.gun.value != null ? (DateTime.now().formatla("dd.MM.yyyy EEEE") == DateTime(2024).formattan("dd.MM.yyyy EEEE", logic.gun.value)?.formatla("dd.MM.yyyy EEEE") ? "👉🏻" : "") : ''}${logic.gun.value != null ? DateTime(2024).formattan("dd.MM.yyyy EEEE", logic.gun.value)?.formatla("dd.MM.yyyy EEEE") : ''} Kartları", tema: FikoButtonTheme( fontSize: 16, textColor: Theme.of(context).extension()?.textColor, ), onPressed: () { context.vRouter.to("/mesaici/hareketler/gun-hareketleri/${DateTime.now().formatla('dd.MM.yyyy EEEE')}"); }, ), ), ), FikoButton( text: ">", tema: FikoButtonTheme( fontSize: 16, edgePadding: const EdgeInsets.symmetric(horizontal: 5), textColor: Theme.of(context).extension()?.textColor, ), onPressed: () { context.vRouter.to("/mesaici/hareketler/gun-hareketleri/${DateTime(2024).formattan('dd.MM.yyyy EEEE', logic.gun.value)?.add(Duration(days: 1)).formatla('dd.MM.yyyy EEEE')}"); }, ), ], ), Obx( () => Column( children: [ const SizedBox( height: 5, ), /** */ ListView.builder( itemCount: logic.hareketler.value?.length ?? 0, physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, reverse: true, itemBuilder: (context, index) => logic.hareketler.value != null ? KartHareket( kayit: logic.hareketler.value?.elementAtOrNull(index).obs, callState: () async { await logic.alAltHareketler(); logic.update(); }, ) : const SizedBox.shrink(), ), ], ), ), /** */ Obx( () => Visibility( visible: (logic.hareketler.value ?? []).isEmpty, child: Column( key: const ValueKey("Kayıt Yok Listesi"), children: [ Padding( padding: const EdgeInsets.only(left: 24, right: 24, top: 15, bottom: 24), child: Stack( clipBehavior: Clip.none, children: [ Padding( padding: const EdgeInsets.only(top: 20), child: Container( decoration: BoxDecoration( color: Colors.blueAccent.shade100.withOpacity(0.2), borderRadius: const BorderRadius.only(topLeft: Radius.circular(8.0), bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topRight: Radius.circular(8.0)), border: Border.all(color: Colors.blueAccent), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.2), // offset: const Offset(0.9, 0.9), offset: const Offset(3, 3), spreadRadius: 5, blurRadius: 10.0, ), ], ), child: Padding( padding: const EdgeInsets.only(left: 46, bottom: 12, right: 16, top: 12), child: Column( children: [ Text( 'Bu Güne Ait Herhangi Bir Çalışma Kartı Bulunamadı.İsterseniz Ekleyebilirsiniz.', textAlign: TextAlign.left, style: TextStyle( fontWeight: FontWeight.w500, fontSize: 12, letterSpacing: 0.0, color: Theme.of(context).extension()?.hatalitextColor, ), ), // Align( // alignment: Alignment.centerRight, // child: TextButton( // // icon: const Text("💡"), // child: const Text( // "📜 Hemen Ekle", // style: TextStyle( // color: Colors.blue, // fontWeight: FontWeight.bold, // fontSize: 12, // ), // ), // onPressed: () async {}), // ) ], ), ), ), ), const Positioned( top: -10, left: 0, child: SizedBox( width: 80, height: 80, child: Text( "📝", style: TextStyle(fontSize: 40), ), ), ) ], ), ), ], ), ), ), /** Ek Ödemeler */ Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Expanded( child: Divider( indent: 0.0, endIndent: 10.0, thickness: 1, ), ), Obx( () => FikoButton( text: '➕ ${logic.gun.value != null ? DateTime(2024).formattan("dd.MM.yyyy EEEE", logic.gun.value)?.formatla("dd.MM.yyyy") : ''} Hareketleri', tema: FikoButtonTheme( textStrokeColor: Colors.transparent, textColor: Theme.of(context).extension()?.textColor, )), ), const Expanded( child: Divider( indent: 10.0, endIndent: 0.0, thickness: 1, ), ), FikoButton( text: "➕", onPressed: () async { AltKart altKart1 = AltKart(); logic.aciklamaEkle(context, altKart1).then( (value) async { if (value == null) return; /** */ await FikoYTService.servisMesaici.isar?.writeTxn( () async { ModelHareketler altHrkt = ModelHareketler()..turu = KartTuru.ALT_KART; altHrkt.tarih = DateTime(2024).formattan("dd.MM.yyyy EEEE", logic.gun.value); AltKart altKart = AltKart(); altKart.aciklama = altKart1.aciklama ?? ""; altHrkt.altKart = altKart; // altKart.ustKartid = logic.hareketler.value?.id; // logic.aktifHareket.value?.altKartlar.clear(); // logic.hareketler.value?.altKartlar.add(altHrkt); // await isar.writeTxn(() async { await FikoYTService.servisMesaici.isar?.modelHareketlers.put(altHrkt); // altHrkt.ustKart.value = logic.hareketler.value; // await altHrkt.ustKart.save(); // await logic.hareketler.value?.altKartlar.save(); await logic.alHareketler(); await logic.alAltHareketler(); logic.altKartlar.refresh(); logic.update(); }, ); // }); }, ); }, ), ], ), ), /** */ Obx( () => Column( children: [ AnimatedSwitcher( duration: const Duration(milliseconds: 1000), layoutBuilder: (Widget? currentChild, List previousChildren) { return Stack( alignment: Alignment.topCenter, children: [ ...previousChildren, if (currentChild != null) currentChild, ], ); }, // visible: logic.aktifHareket.value != null ? logic.aktifHareket.value!.altKartlar.isEmpty : false, child: (logic.altKartlar.value?.length != null && logic.altKartlar.value!.isEmpty) ? Column( key: const ValueKey("Kayıt Yok Listesi"), children: [ Padding( padding: const EdgeInsets.only(left: 24, right: 24, top: 15, bottom: 24), child: Stack( clipBehavior: Clip.none, children: [ Padding( padding: const EdgeInsets.only(top: 20), child: Container( decoration: BoxDecoration( color: Colors.blueAccent.shade100.withOpacity(0.2), borderRadius: const BorderRadius.only(topLeft: Radius.circular(8.0), bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topRight: Radius.circular(8.0)), border: Border.all(color: Colors.blueAccent), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.2), // offset: const Offset(0.9, 0.9), offset: const Offset(3, 3), spreadRadius: 5, blurRadius: 10.0, ), ], ), child: Padding( padding: const EdgeInsets.only(left: 46, bottom: 12, right: 16, top: 12), child: Column( children: [ Text( 'Bu Güne Ait Herhangi Bir Not / Hareket Bulunamadı.İsterseniz Ekleyebilirsiniz.', textAlign: TextAlign.left, style: TextStyle( fontWeight: FontWeight.w500, fontSize: 12, letterSpacing: 0.0, color: Theme.of(context).extension()?.hatalitextColor, ), ), // Align( // alignment: Alignment.centerRight, // child: TextButton( // // icon: const Text("💡"), // child: const Text( // "📜 Hemen Ekle", // style: TextStyle( // color: Colors.blue, // fontWeight: FontWeight.bold, // fontSize: 12, // ), // ), // onPressed: () async { // AltKart altKart1 = AltKart(); // logic.aciklamaEkle(context, altKart1).then( // (value) async { // if (value == null) return; // /** */ // await FikoYTService.servisMesaici.isar?.writeTxn( // () async { // // ModelHareketler altHrkt = ModelHareketler()..turu = KartTuru.ALT_KART; // // altHrkt.tarih = DateTime.now(); // // AltKart altKart = AltKart(); // // altKart.aciklama = altKart1.aciklama ?? ""; // // altHrkt.altKart = altKart; // // altKart.ustKartid = logic.hareketler.value?.id; // // // logic.aktifHareket.value?.altKartlar.clear(); // // logic.hareketler.value?.altKartlar.add(altHrkt); // // // await isar.writeTxn(() async { // // await FikoYTService.servisMesaici.isar?.modelHareketlers.put(altHrkt); // // altHrkt.ustKart.value = logic.hareketler.value; // // await altHrkt.ustKart.save(); // // await logic.hareketler.value?.altKartlar.save(); // // await logic.alHareketler(); // // logic.hareketler.refresh(); // }, // ); // // }); // }, // ); // }, // ), // ) ], ), ), ), ), const Positioned( top: -10, left: 0, child: SizedBox( width: 80, height: 80, child: Text( "📝", style: TextStyle(fontSize: 40), ), ), ) ], ), ), ], ) : Obx( () { logic.altKartlar.value; logic.hareketler.value; return Column( key: const ValueKey("Alt Kart Listesi1"), children: [ const SizedBox( height: 5, ), /** */ ListView.builder( itemCount: logic.altKartlar.value?.length ?? 0, physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, reverse: true, itemBuilder: (context, index) => logic.altKartlar.value != null ? KartHareket( kayit: logic.altKartlar.value?.elementAtOrNull(index).obs, callState: () async { await logic.alHareketler(); await logic.alAltHareketler(); logic.altKartlar.refresh(); logic.update(); }, ) : const SizedBox.shrink(), ), ], ); }, ), ), /** */ ], ), ), // Container( // margin: const EdgeInsets.only(top: 10, bottom: 10, right: 10, left: 10), // child: AktifKart( // kayit: CalismaKayit.fromEmbedded(aktifKart: logic.FikoYTService.servisMesaici.isar?.modelHareketlers.where().filter().calismaKarti((q) => q.tarihBetween(widget.kartId.ilkSaatler(), widget.kartId.sonSaatler())).calismaKartiProperty().findFirstSync()!).obs, // ), // ), ], headerExpandedHeight: 315, // stretchMaxHeight: 100, fullyStretchable: false, backgroundColor: Theme.of(context).extension()?.arkaPlanRenk, //Colors.grey.shade200, centerTitle: true, alwaysShowLeadingAndAction: true, appBarColor: Colors.blue.shade500, alwaysShowTitle: true, curvedBodyRadius: 0, onStretchTrigger: () async { context.vRouter.to("/"); }, ); } }