import 'package:fikoyt_mesaici/apps/mesaici/base_page_mesaici_view.dart'; import 'package:fikoyt_mesaici/apps/mesaici/model/ayarlar/model_ayarlar.dart'; import 'package:fikoyt_mesaici/apps/mesaici/servisler/fikoyt.mesaici.service.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/widgets/fiko_ui/fiko_button/fiko_button.dart'; import 'package:fikoyt_mesaici/core/widgets/yazi_kutulari/yazi_kutulari.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class MolaEkleDialog extends StatelessWidget { MolaEkleDialog({super.key, required this.mola, this.ayarGizle = false}); BasePageMesaiciLogic basePageMesaiciLogic = Get.put(BasePageMesaiciLogic()); final FikoYTMesaiciService servisMesaici = Get.put(FikoYTMesaiciService()); final FikoYTService servisFikoYT = FikoYTService(); Rx mola; bool ayarGizle = false; // late Rx molaObs = mola.obs; @override Widget build(BuildContext context) { mola.listen((val) { // mola = val; servisMesaici.ayarlarModel!.refresh(); }); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( "Mola'ya Bir İsim Veriniz", ), FikoYaziKutusu( baslik: "Mola İsmi", simgeSol: const Text( "👩🏻‍🤝‍👨🏽", style: TextStyle( fontSize: 16, ), ), radius: 5.0, degeri: mola.value.ismi, degisti: (value) { if (value.isNotEmpty) { mola.value.ismi = value; } else { mola.value.ismi = null; } mola.refresh(); }, ), FikoAciklamaKutusu( baslik: "Mola Açıklama", radius: 5.0, degeri: mola.value.aciklama, yaziBoyutu: 12.0, degisti: (value) { mola.value.aciklama = value; mola.refresh(); }, ), Row( children: [ Expanded( child: Container( alignment: Alignment.center, decoration: BoxDecoration( color: Colors.grey.shade400, borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(10), topLeft: Radius.circular(10), ), ), child: const Text( "Giriş Saati", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), ), ), ), Expanded( child: Container( alignment: Alignment.center, decoration: BoxDecoration( color: Colors.grey.shade400, borderRadius: const BorderRadius.only( bottomRight: Radius.circular(10), topRight: Radius.circular(10), ), ), child: const Text( "Çıkış Saati", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), ), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: Obx( () => FikoButton1( text: mola.value.girisSaati!.formatla("dd.MM.yyyy HH:mm:ss"), textSize: 14, textColor: Colors.green, textStrokeColor: Colors.transparent, onPressed: () async { // DateTime? rslt = await FikoYTService.saatSec(context, varsayilanTarih: DateTime(0, 0, 0, 0, 0, 0, 0, 0).ayarlaGununSaati(mola.value.girisSaati!.gununSaati())); DateTime? rslt = await mola.value.girisSaati!.tarihSaatSec(context, varsayilanTarihSaat: mola.value.girisSaati); mola.refresh(); if (rslt == null) return; mola.value.girisSaati = rslt; mola.refresh(); }, ), ), ), Expanded( child: Obx( () => FikoButton1( text: mola.value.cikisSaati?.formatla("dd.MM.yyyy HH:mm:ss") ?? "Yok", textSize: 14, textColor: Colors.red, textStrokeColor: Colors.transparent, onPressed: () async { // DateTime? rslt = await FikoYTService.saatSec(context, varsayilanTarih: DateTime(0, 0, 0, 0, 0, 0, 0, 0).ayarlaGununSaati((mola.value.cikisSaati ?? DateTime(0)).gununSaati())); DateTime? rslt = await (mola.value.cikisSaati ?? DateTime.now()).tarihSaatSec(context, varsayilanTarihSaat: mola.value.cikisSaati ?? DateTime.now()); mola.refresh(); if (rslt == null) return; mola.value.cikisSaati = rslt; mola.refresh(); // showTimePicker( // context: context, // initialTime: // TimeOfDay.fromDateTime(molaObs.value.cikisSaati.value), // ).then((value) { // if (value != null) { // molaObs.value.cikisSaati.value = // DateTime(0, 0, 0, value.hour, value.minute); // } // }); }, ), ), ), ], ), Row( children: [ Expanded( child: Container( alignment: Alignment.center, decoration: BoxDecoration( color: Colors.grey.shade400, borderRadius: const BorderRadius.all( Radius.circular(10), ), ), child: const Text( "Mola Süresi", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), ), ), ), ], ), Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Obx( () => FikoButton1( text: mola.value.farkHesapla().insanize ?? 'Yok', textSize: 18, textColor: Colors.green, textStrokeColor: Colors.transparent, ), ), ], ), Visibility( visible: !ayarGizle, child: Column( children: [ Obx( () => Row( children: [ const Text("🚨 Bu Mola Çalışma Saatinden Düşer"), const Spacer(), SizedBox( height: 25, child: FittedBox( fit: BoxFit.fill, child: Switch( value: mola.value.saattenDus ?? false, onChanged: (value) { mola.value.saattenDus = value; mola.refresh(); }, ), ), ), ], ), ), Obx( () => Row( children: [ const Text("🛎️ Bu Mola İçin Bildirim Göster"), const Spacer(), SizedBox( height: 25, child: FittedBox( fit: BoxFit.fill, child: Switch( value: mola.value.bildirimGoster ?? false, onChanged: (value) { mola.value.bildirimGoster = value; mola.refresh(); }, ), ), ), ], ), ), Row( children: [ const Text("🤖 Bu Molayı Otomatik Gir"), const Spacer(), SizedBox( height: 25, child: FittedBox( fit: BoxFit.fill, child: Obx(() => Checkbox( value: mola.value.otomatikGir ?? false, onChanged: (value) { mola.value.otomatikGir = value; mola.refresh(); }, ) // Switch( // value: molaObs.value.otomatikGir ?? false, // onChanged: (value) { // molaObs.value.otomatikGir = value; // molaObs.refresh(); // }, // ), ), ), ), ], ), ], ), ), ], ); } }