// ignore_for_file: library_private_types_in_public_api import 'dart:io'; import 'package:fikoyt_mesaici/apps/mesaici/widgets/ozet_aylik/ozet_aylik.dart'; import 'package:fikoyt_mesaici/apps/mesaici/widgets/uygulama_baslik/uygulama_baslik.dart'; import 'package:fikoyt_mesaici/core/interface/fiko_dialog_ayarlari.dart'; import 'package:fikoyt_ui/Extensions/fiko_datetime.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:fikoyt_ui/ui/themes/fikoyt_button_theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart' as sc; import 'package:isar/isar.dart'; // import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import '../../../../core/widgets/base_page/base_page_view.dart'; import '../../core/fikoyt.service.dart'; import 'model/alt_kart/alt_kart.dart'; import 'model/model_hareketler.dart'; import 'pages/hareketler/hareket_kart/hareket_kart.dart'; import 'pages/hareketler/pages/gun_hareketler/aciklama_ekle.dart'; import 'pages/raporlar/aylik_grafik.dart'; import 'widgets/aktif_kart/aktif_kart.dart'; import 'widgets/kullanici_bilgi_navigasyon/kullanici_bilgi_navigasyon.dart'; class PageMesaiciHomeLogic extends GetxController { 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()); 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, AciklamaEkleWidget( altKart: altKart, ), FikoDialogAyarlari(baslik: "Açıklama Ekle", baslikSimge: "➕", arkaPlanaTiklanincaKapansin: false, altButonlar: [ FikoYTButton( text: "Ekle", tema: Theme.of(context).extension()?.copyWith( textColor: Colors.green, textStrokeColor: Colors.transparent, edgePadding: const EdgeInsets.symmetric(horizontal: 5, vertical: 0), ), onPressed: (() { Navigator.pop(context, altKart); }), ), const Spacer(), FikoYTButton( text: "Kapat", tema: Theme.of(context).extension()?.copyWith( textColor: Colors.red, textStrokeColor: Colors.transparent, edgePadding: const EdgeInsets.symmetric(horizontal: 5, vertical: 0), ), onPressed: () async { if (altKart.ek?.id != null) { String appDir = await FikoYTService.programYolu(ekYol: "medya_hareketler"); File file = File("$appDir${altKart.ek?.id}"); try { if (await file.exists()) { await file.delete(); altKart.ek = null; } } catch (e) { /// } } Navigator.pop(context); }, ), ]), ); } } class PageMesaiciHome extends StatefulWidget { const PageMesaiciHome({super.key}); @override _PageMesaiciHomeState createState() => _PageMesaiciHomeState(); } class _PageMesaiciHomeState extends State { PageMesaiciHomeLogic logic = Get.put(PageMesaiciHomeLogic()); BasePageLogic basePageLogic = Get.put(BasePageLogic()); // final FikoYTMesaiciService FikoYTService.servisMesaici = Get.put(FikoYTMesaiciService()); final FikoYTService servisFikoYT = FikoYTService(); //---> int touchedIndex = 0; @override void initState() { sc.SchedulerBinding.instance.addPostFrameCallback((_) { FikoYTService.servisMesaici.aktifAy.value = DateTime.now(); }); super.initState(); } @override Widget build(BuildContext context) { sc.SchedulerBinding.instance.addPostFrameCallback((_) { basePageLogic.subTitle.value = "🏠 Merkez"; }); sc.SchedulerBinding.instance.addPostFrameCallback((_) async { logic.gun.value = DateTime.now().formatla('dd.MM.yyyy EEEE'); await logic.alHareketler(); await logic.alAltHareketler(); logic.gun.refresh(); basePageLogic.subTitle.value = "🏠 Merkez"; }); // ScreenSizeTypes screenType = FikoYTElastic.getScreenSizeType(context); // [ // // ScreenSizeTypes.small, // ScreenSizeTypes.mini, // ScreenSizeTypes.extraMini // ].contains(screenType); return FikoYTSliverApp( leading: const UygulamaBaslikSol(), title: UygulamaBaslikOrta(), actions: const [ UygulamaBaslikSag(), ], headerWidget: PageView( children: [ /** */ /** */ Column( children: [ const SizedBox( height: kToolbarHeight, ), Container( color: Colors.transparent, //Colors.orange, height: 280, // margin: const EdgeInsets.only(top: kToolbarHeight, bottom: 10, right: 10, left: 10), child: Obx( () => KullaniciBilgiNavigasyon( cap: 76.0, simge: FikoYTService.servisMesaici.profilResmi.value == null ? FikoYTButton( onPressed: () async { await FikoYTService.servisMesaici.profilResmiSec(); }, onLongPress: () async { await FikoYTService.servisMesaici.profilResmiSil(); FikoYTService.servisMesaici.profilResmi.refresh(); }, text: "🏠", tema: Theme.of(context).extension()?.copyWith( radius: 64, fontSize: 64, ), ).animate(effects: [ const FadeEffect(), const ShimmerEffect( delay: Duration(seconds: 1), ), ]) : GestureDetector( onTap: () async { await FikoYTService.servisMesaici.profilResmiSec(); }, onLongPress: () async { await FikoYTService.servisMesaici.profilResmiSil(); FikoYTService.servisMesaici.profilResmi.refresh(); }, child: Image.memory( FikoYTService.servisMesaici.profilResmi.value!, fit: BoxFit.cover, width: double.infinity, height: double.infinity, ).animate(effects: [ const FadeEffect(), const ShimmerEffect( delay: Duration(seconds: 1), ), ]), ), ), ), ), ], ), /** */ // Container( // color: Colors.transparent, //Colors.orange, // height: 300 - kToolbarHeight - 10, // margin: const EdgeInsets.only(top: kToolbarHeight, bottom: 10, right: 10, left: 10), // child: PieChart( // PieChartData( // pieTouchData: PieTouchData( // touchCallback: (FlTouchEvent event, pieTouchResponse) { // setState(() { // if (!event.isInterestedForInteractions || pieTouchResponse == null || pieTouchResponse.touchedSection == null) { // touchedIndex = -1; // return; // } // touchedIndex = pieTouchResponse.touchedSection!.touchedSectionIndex; // }); // }, // ), // borderData: FlBorderData( // show: false, // ), // startDegreeOffset: 0, // titleSunbeamLayout: true, // sectionsSpace: 0, // centerSpaceRadius: 80, // sections: showingSections(), // ), // ), // ), ], ), // headerBottomBar: Container( // padding: EdgeInsets.zero, // margin: EdgeInsets.zero, // height: kToolbarHeight, // color: Colors.transparent, // child: Row( // crossAxisAlignment: CrossAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.start, // children: [ // // IconButton( // // onPressed: () {}, // // icon: const Image( // // image: AssetImage('assets/core/icons/logo.png'), // // filterQuality: FilterQuality.high, // // ), // // iconSize: kToolbarHeight, // // splashRadius: 20, // // color: Colors.blue.shade300, // // ), // // const Expanded( // // child: Image( // // image: AssetImage('assets/core/icons/fikoyt.png'), // // filterQuality: FilterQuality.high, // // height: 32, // // // width: widget.logoWidth * cardWidth, // // ), // // ), // const Spacer(), // // IconButton( // // onPressed: () {}, // // icon: const Icon( // // Icons.help_outline_rounded, // // ), // // color: Colors.blue.shade300, // // iconSize: 22, // // splashRadius: 20, // // ), // ], // ), // ), body: [ Row( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end, children: [ FikoYTButton( text: Icon( Icons.help_outline_rounded, color: Colors.blue.withAlpha(100), size: 24, ), tema: Theme.of(context).extension()?.copyWith( radius: 32, ), // backColor: Colors.amber.withAlpha(80), // borderColor: Colors.amber.withAlpha(200), route: "/mesaici/yardim/konu=ana_sayfa", ), ], ), // Column( // 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 Ay Devamsızlığınız Oldukça Fazla.İş Yerinizde Hayaletleşmeyin', // textAlign: TextAlign.left, // style: TextStyle( // fontWeight: FontWeight.w500, // fontSize: 12, // letterSpacing: 0.0, // color: Colors.blueAccent.shade700, // ), // ), // Align( // alignment: Alignment.centerRight, // child: TextButton( // // icon: const Text("💡"), // child: const Text( // "💡 Öneriler", // style: TextStyle( // color: Colors.blue, // fontWeight: FontWeight.bold, // fontSize: 12, // ), // ), // onPressed: () {}, // ), // ) // ], // ), // ), // ), // ), // const Positioned( // top: -10, // left: 0, // child: SizedBox( // width: 80, // height: 80, // child: Text( // "👻", // style: TextStyle(fontSize: 40), // ), // ), // ) // ], // ), // ), // ], // ), Container( margin: const EdgeInsets.only(top: 10, bottom: 10, right: 10, left: 10), child: AktifKart( kayit: FikoYTService.servisMesaici.aktifCalisma, ), ), Obx( () { FikoYTService.servisMesaici.aktifCalisma?.value; return Container( margin: const EdgeInsets.only(top: 0, bottom: 10, right: 10, left: 10), // ignore: prefer_const_constructors child: OzetAylik(), ); }, ), Obx( () { FikoYTService.servisMesaici.aktifCalisma?.value; return Container( margin: const EdgeInsets.only(top: 0, bottom: 10, right: 10, left: 10), // ignore: prefer_const_constructors child: const AylikGrafik(), ); }, ), /** */ ], headerExpandedHeight: 340, // stretchMaxHeight: 100, fullyStretchable: false, backgroundColor: Theme.of(context).extension()?.backgroundColor, // Colors.grey.shade200, centerTitle: true, alwaysShowLeadingAndAction: true, appBarColor: Theme.of(context).extension()?.appBarColor, alwaysShowTitle: true, curvedBodyRadius: 0, onStretchTrigger: () async { context.vRouter.to("/"); }, sliverAltKisim: SingleChildScrollView( child: Obx( () => Column( children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Expanded( child: Divider( indent: 0.0, endIndent: 10.0, thickness: 1, ), ), Obx( () => FikoYTButton( text: '➕ ${logic.gun.value != null ? 'Bugünün' : 'Bugünün'} Hareketleri', tema: Theme.of(context).extension()?.copyWith( textStrokeColor: Colors.transparent, textColor: Theme.of(context).extension()?.textColor, )), ), const Expanded( child: Divider( indent: 10.0, endIndent: 0.0, thickness: 1, ), ), FikoYTButton( 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); altHrkt.kayitTarih = DateTime.now(); AltKart altKart = AltKart(); altKart.aciklama = value.aciklama ?? ""; altKart.ek = value.ek; 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(); }, ); // }); }, ); }, ), ], ), ), 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()?.errorTextColor, ), ), ], ), ), ), ), 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 { print("Burada"); await logic.alHareketler(); await logic.alAltHareketler(); logic.altKartlar.refresh(); logic.update(); }, ) : const SizedBox.shrink(), ), ], ); }, ), ), /** */ ], ), ), ), // sliverAltKisim: FittedBox( // fit: BoxFit.scaleDown, // child: Column( // children: [ // // const Image( // // image: AssetImage('assets/core/icons/fikoyt.png'), // // filterQuality: FilterQuality.high, // // height: 72, // // // width: widget.logoWidth * cardWidth, // // ), // Center( // child: KullaniciBilgiNavigasyon(), // ), // ], // ), // ), ); } @override void dispose() { Get.delete(); super.dispose(); } }