import 'package:fikoyt_mesaici/apps/mesaici/model/model_hareketler.dart'; import 'package:fikoyt_mesaici/apps/mesaici/servisler/fikoyt.mesaici.service.dart'; import 'package:fikoyt_mesaici/core/fikoyt.service.dart'; import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:get/get.dart'; import 'package:isar/isar.dart'; import '../../model/calisma_kayit/calisma_kayit.dart'; class GirisCikisButonlari extends StatelessWidget { GirisCikisButonlari({super.key, required this.kayit}); final Rx? kayit; /** */ FikoYTMesaiciService servisMesaici = Get.put(FikoYTMesaiciService()); FikoYTService servisFikoYT = FikoYTService(); @override Widget build(BuildContext context) { return Row( children: [ Obx( () => Visibility( visible: kayit?.value?.giris == null && !kayit!.value!.raporlu && !kayit!.value!.gunlukIzinli && !kayit!.value!.yillikIzinli, child: TextButton( onPressed: () { kayit?.value?.girisYap(); kayit?.refresh(); }, style: TextButton.styleFrom( alignment: Alignment.center, fixedSize: const Size.fromHeight(16), backgroundColor: Colors.blue.shade400, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.horizontal( left: Radius.circular(50), right: Radius.circular(50), ), ), textStyle: const TextStyle( fontSize: 10, color: Colors.white, ), ), child: const Padding( padding: EdgeInsets.symmetric(horizontal: 10), child: Text( "Giriş Yap", style: TextStyle( color: Colors.white, ), ), ), ).animate(effects: [ const ScaleEffect(), const FadeEffect(), ]), ), ), // Obx( // () => Visibility( // visible: kayit?.value?.giris != null && kayit?.value?.cikis != null, // child: TextButton( // onPressed: () { // kayit?.value?.sil(); // kayit?.refresh(); // }, // style: TextButton.styleFrom( // alignment: Alignment.center, // fixedSize: const Size.fromHeight(16), // backgroundColor: Colors.red.shade400, // shape: const RoundedRectangleBorder( // borderRadius: BorderRadius.horizontal( // left: Radius.circular(50), // right: Radius.circular(50), // ), // ), // textStyle: const TextStyle( // fontSize: 10, // color: Colors.white, // ), // ), // child: const Padding( // padding: EdgeInsets.symmetric(horizontal: 10), // child: Text( // "🗑️ Kartı Sil", // style: TextStyle( // color: Colors.white, // ), // ), // ), // ).animate(effects: [ // const ScaleEffect(), // const FadeEffect(), // ]), // ), // ), const Spacer(), Obx( () => Visibility( visible: kayit!.value!.giris == null && !!kayit!.value!.raporlu && !!kayit!.value!.gunlukIzinli && !!kayit!.value!.yillikIzinli && !!kayit!.value!.resmiTatil && (kayit!.value!.gunTuru != GunTuru.DINLENME_GUNU && kayit!.value!.gunTuru != GunTuru.HAFTA_TATILI), child: TextButton( onPressed: () { kayit?.value?.sil(); kayit?.refresh(); }, style: TextButton.styleFrom( alignment: Alignment.center, fixedSize: const Size.fromHeight(16), backgroundColor: Colors.red.shade400, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.horizontal( left: Radius.circular(50), right: Radius.circular(50), ), ), textStyle: const TextStyle( fontSize: 10, color: Colors.white, ), ), child: const Padding( padding: EdgeInsets.symmetric(horizontal: 10), child: Text( "🗑️ Kartı Sil", style: TextStyle( color: Colors.white, ), ), ), ).animate(effects: [ const ScaleEffect(), const FadeEffect(), ]), ), ), Obx( () => Visibility( visible: (kayit!.value!.giris != null && kayit!.value!.cikis == null) && (!kayit!.value!.raporlu && !kayit!.value!.gunlukIzinli && !kayit!.value!.yillikIzinli), child: TextButton( onPressed: () { kayit?.value?.cikisYap(); kayit?.refresh(); }, style: TextButton.styleFrom( alignment: Alignment.center, fixedSize: const Size.fromHeight(16), backgroundColor: Colors.red.shade400, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.horizontal( left: Radius.circular(50), right: Radius.circular(50), ), ), textStyle: const TextStyle( fontSize: 10, color: Colors.white, ), ), child: const Padding( padding: EdgeInsets.symmetric(horizontal: 10), child: Text( "Çıkış Yap", style: TextStyle( color: Colors.white, ), ), ), ).animate(effects: [ const ScaleEffect(), const FadeEffect(), ]), ), ), Obx( () => Visibility( visible: kayit?.value?.kartKaydedilebilir() ?? false, child: Row( children: [ TextButton( onPressed: () { kayit?.value?.sil(); kayit?.refresh(); }, style: TextButton.styleFrom( alignment: Alignment.center, fixedSize: const Size.fromHeight(16), backgroundColor: Colors.red.shade400, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.horizontal( left: Radius.circular(50), right: Radius.circular(50), ), ), textStyle: const TextStyle( fontSize: 10, color: Colors.white, ), ), child: const Padding( padding: EdgeInsets.symmetric(horizontal: 10), child: Text( "🗑️ Kartı Sil", style: TextStyle( color: Colors.white, ), ), ), ).animate(effects: [ const ScaleEffect(), const FadeEffect(), ]), TextButton( onPressed: () { ModelHareketler yeniHareket = kayit!.value!.toModelHareket(); servisMesaici.isar.writeTxn( () async { await Future.delayed(const Duration(milliseconds: 500)); return servisMesaici.isar.modelHareketlers.put(yeniHareket); }, ); }, style: TextButton.styleFrom( alignment: Alignment.center, fixedSize: const Size.fromHeight(16), backgroundColor: Colors.green.shade400, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.horizontal( left: Radius.circular(50), right: Radius.circular(50), ), ), textStyle: const TextStyle( fontSize: 10, color: Colors.white, ), ), child: const Padding( padding: EdgeInsets.symmetric(horizontal: 10), child: Text( "💾 Kaydet", style: TextStyle( color: Colors.white, ), ), ), ).animate(effects: [ const ScaleEffect(), const FadeEffect(), ]), ], ), ), ), ], ); } }