import 'package:fikoyt_akcali_v1/apps/finans/core/models/finans.model.dart'; import 'package:fikoyt_akcali_v1/apps/finans/core/services/finans.servis.dart'; import 'package:fikoyt_akcali_v1/apps/finans/core/services/kategoriler_service.dart'; import 'package:fikoyt_akcali_v1/apps/finans/uye/hesaplar/_hesaplar-logic.dart'; import 'package:fikoyt_akcali_v1/apps/finans/uye/para-birimleri/para-birimi-sec-dialog.dart'; import 'package:fikoyt_akcali_v1/core/widgets/header_widget/header_widget.dart'; import 'package:fikoyt_akcali_v1/core/widgets/uygulama_baslik/uygulama_baslik.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:fikoyt_ui/ui/fikoyt_card.dart'; import 'package:fikoyt_ui/ui/yazi_kutulari/fikoyt_button_kutu.dart'; import 'package:fikoyt_ui/ui/yazi_kutulari/yazi_kutulari.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; class SayfaKategoriEkle extends StatefulWidget { SayfaKategoriEkle({super.key, Rx? kyt, this.animClose}) : yeni = kyt == null ? true : false, kyt = kyt ?? Kategori().obs; Rx kyt = Kategori().obs; bool? yeni; void Function({Never returnValue})? animClose; @override State createState() => _SayfaKategoriEkleState(); } class _SayfaKategoriEkleState extends State { FinansServis? finansServis = FikoYTCoreService.servisler.getServis(); KategorilerService? logicKategoriler; @override void initState() { super.initState(); // finansServis = FikoYTCoreService.servisler.getServis(); logicKategoriler = Get.put(KategorilerService()); SchedulerBinding.instance.addPostFrameCallback((_) { // logic.gun.value = widget.gun; // widget.kyt.value = logicHesaplar?.hesapByIdSync(int.tryParse(widget.hesapId ?? "-1") ?? -1); // await logic.alHareketler(); // await logic.alAltHareketler(); // logic.gun.refresh(); // finansServis?.altBaslik.value = widget.yeni == true ? "Yeni Hesap" : "Hesap Düzenle"; finansServis?.solMenuAl(context); }); } @override void dispose() { // Get.delete(); super.dispose(); } @override Widget build(BuildContext context) { return FikoYTSliverApp( leading: UygulamaBaslikSol( simge: Icon(Icons.keyboard_double_arrow_left, color: Colors.orangeAccent, size: 36), onPressedSimge: () { if (widget.animClose != null) widget.animClose!(); }, ), title: UygulamaBaslikOrta(altBaslik: widget.yeni == true ? "Yeni Hesap" : widget.kyt.value.ismi), actions: [UygulamaBaslikSag()], drawer: finansServis?.solMenu.value, backgroundColor: Theme.of(context).extension()?.backgroundColor, appBarColor: Theme.of(context).extension()?.appBarColor?.withAlpha(230), headerExpandedHeight: 250, // stretchMaxHeight: 100, fullyStretchable: true, centerTitle: true, alwaysShowLeadingAndAction: true, alwaysShowTitle: true, curvedBodyRadius: 0, // onStretchTrigger: () async { // context.vRouter.to("/"); // }, /// floatingActionButton: Container( decoration: BoxDecoration( color: Theme.of(context).extension()?.cardBackgroundColor, borderRadius: BorderRadius.circular(50), boxShadow: Theme.of(context).extension()?.boxShadow, ), child: FloatingActionButton( backgroundColor: Theme.of(context).extension()?.successTextColor, elevation: 5, shape: CircleBorder(), splashColor: Colors.black.withAlpha(100), child: FikoYTButton( text: widget.yeni == true ? "💾" : "💫", tema: FikoYTButtonTheme( fontSize: 24, // radius: 80, // edgePadding: EdgeInsets.all(15), // backgroundColor: Theme.of(context).extension()?.successTextColor, ), ), onPressed: () async { // kaydet(); if (widget.kyt.value.bosMu) { toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.error, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text("Tüm Boş Alanları Doldurun."), alignment: Alignment.topRight, autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); return; } await logicKategoriler?.kaydet(kyt: widget.kyt.value); toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.success, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text(widget.yeni == true ? "Hesabınız Oluşturuldu." : "Hesabınız Güncellendi."), alignment: Alignment.topRight, autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); // logicKategoriler?.guncelle.refresh(); if (widget.animClose != null && !(widget.kyt.value.bosMu)) widget.animClose!(); }, ), ).animate(effects: [SlideEffect(begin: Offset(20, 0), delay: 50.ms, duration: 1000.ms)]), headerWidget: Obx(() { widget.kyt.value; return HeaderWidget( ovalResimUrl: widget.yeni == true ? "💳" : widget.kyt.value.simge, baslik: widget.yeni == true ? "Yeni Hesap" : widget.kyt.value.ismi, baslikTheme: Theme.of(context).extension()?.copyWith( textColor: Theme.of(context).extension()?.secondaryTextColor, fontWeight: FontWeight.bold, fontSize: 16, ), altBaslik: widget.yeni == true ? "Sisteminize Yeni Hesap Ekleyin" : "${widget.kyt.value.ismi != null ? '${widget.kyt.value.ismi} İsimli' : 'İsim Verilmemiş'} Hesabınızı Düzenleyin", altBaslikTheme: Theme.of(context).extension()?.copyWith( textColor: Theme.of(context).extension()?.tertiaryTextColor, fontWeight: FontWeight.normal, fontSize: 12, ), // ustKisim: Row( // mainAxisAlignment: MainAxisAlignment.center, // crossAxisAlignment: CrossAxisAlignment.center, // children: [ // Spacer(), // FikoYTButton( // text: "${widget.kyt.value.hesapTipi.emoji ?? ''}${widget.kyt.value.hesapTipi.isim ?? ''}", // tema: Theme.of(context).extension()?.copyWith( // textColor: Theme.of(context).extension()?.secondaryTextColor, // fontWeight: FontWeight.normal, // textShadow: [], // fontSize: 12, // ), // ).animate(effects: [MoveEffect(begin: Offset(150, 0), duration: Duration(milliseconds: 750))]), // ], // ), // ovalResimTiklandi: finansServis?.profilResmiDegistir, ovalResimCiftTiklandi: finansServis?.profilResmiSil, ); }), // headerBottomBar: Container( // color: Theme.of(context).extension()?.cardBackgroundColor?.withAlpha(200), // child: Row( // children: [ // Obx( // () => FikoYTButton( // text: // "${widget.kyt.value.paraBirimi.value?.sembol ?? ""} ${widget.kyt.value.paraBirimi.value?.ismi ?? ""} ${widget.kyt.value.paraBirimi.value?.kod ?? ""}", // tema: Theme.of(context).extension()?.copyWith( // textColor: Theme.of(context).extension()?.tertiaryTextColor, // ), // onPressed: () {}, // ), // ), // Spacer(), // ], // ), // ), /// golgeGoster: false, bodyColor: Colors.transparent, bodyMaxWidth: 400, sliverAltKisimGoster: false, sliverAltKisim: SizedBox.shrink(), body: [ SizedBox(height: 300), FikoYTCard( key: ValueKey("KategoriEkleDialog"), theme: (Theme.of(context).extension() ?? FikoYTCardTheme()).copyWith( boxConstraints: BoxConstraints(maxWidth: 300), ), children: [ Center(child: Text('⛓', style: TextStyle(fontSize: 54))), Center( child: FikoYTButton( text: widget.yeni==true ? 'Yeni Kategori' : 'Kategori Güncelle', tema: Theme.of(context).extension()?.copyWith( textAlign: TextAlign.center, textStrokeColor: Colors.transparent, textColor: Theme.of(context).extension()?.infoTextColor, // textShadow: Theme.of(context).extension()?.textShadow, ), ), ), Divider(height: 4), Obx( () => Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, spacing: 5, children: [ FikoYaziKutusu( baslik: "Kategori İsmi", simgeSol: const Text("✏️", style: TextStyle(fontSize: 14)), yaziBoyutu: 12.0, radius: 5.0, degeri: widget.kyt.value.ismi, degisti: (value) { widget.kyt.value.ismi = value; }, ), FikoYaziKutusu( baslik: "Kod", simgeSol: const Text("🏷️", style: TextStyle(fontSize: 14)), yaziBoyutu: 12.0, radius: 5.0, degeri: widget.kyt.value.kod, degisti: (value) { widget.kyt.value.kod = value; }, ), FikoYaziKutusu( baslik: "Sembol", simgeSol: const Text("⭐", style: TextStyle(fontSize: 14)), yaziBoyutu: 12.0, radius: 5.0, degeri: widget.kyt.value.simge, degisti: (value) { widget.kyt.value.simge = value; }, ), FikoAciklamaKutusu( baslik: "Açıklama", yaziBoyutu: 12.0, radius: 5.0, degeri: widget.kyt.value.aciklama, degisti: (value) { widget.kyt.value.aciklama = value; }, ), Row( children: [ FikoYTButton( text: "❌ Kapat", tema: FikoYTButtonTheme( // textColor: Colors.white, backgroundColor: Colors.transparent, // fontWeight: FontWeight.w700, edgePadding: EdgeInsets.all(3), borderColor: Colors.red, elevation: 3, fontSize: 12, ), onPressed: () async { logicKategoriler?.kayitEkleGoster.value = false; logicKategoriler?.kayitEkleGoster.refresh(); context.vRouter.pop(); }, ), Spacer(), if (widget.kyt.value != null) FikoYTIconButton( text: "Sil", icon: Icons.delete, tema: FikoYTButtonTheme( // textColor: Colors.white, backgroundColor: Colors.transparent, // fontWeight: FontWeight.w700, edgePadding: EdgeInsets.all(3), borderColor: Colors.blueAccent, elevation: 3, fontSize: 12, ), onPressed: () async { AwesomeDialog( context: context, dialogType: DialogType.question, animType: AnimType.scale, headerAnimationLoop: false, title: 'Silme Onayı', titleTextStyle: TextStyle( color: Theme.of(context).extension()?.infoTextColor, fontSize: 16, ), desc: '${widget.kyt.value.ismi ?? ""} Kategorisi Silinecek. Onaylıyormusunuz?', btnCancelOnPress: () { // context.vRouter.pop(); }, btnCancelColor: Colors.green, btnCancelText: "İptal", btnOkOnPress: () { logicKategoriler?.sil(kyt: widget.kyt.value); widget.kyt.refresh(); /// Başarılı toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.warning, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text("Kategori Silindi."), alignment: Alignment.topRight, autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); context.vRouter.pop(); }, btnOkColor: Colors.red, btnOkText: "Sil", ).show(); }, ), FikoYTIconButton( text: (widget.yeni==false) ? "Güncelle" : "Ekle", icon: (widget.yeni==false) ? Icons.update : Icons.add, tema: FikoYTButtonTheme( // textColor: Colors.white, backgroundColor: Colors.transparent, // fontWeight: FontWeight.w700, edgePadding: EdgeInsets.all(3), borderColor: Colors.blueAccent, elevation: 3, fontSize: 12, ), onPressed: () async { if (widget.kyt.value.bosMu) { /// Boş toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.error, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text("Tüm Boş Alanları Doldurun."), alignment: Alignment.topRight, autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); return; } logicKategoriler?.kaydet(kyt: widget.kyt.value); /// Başarılı toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.success, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text("Kategori Tanımlandı."), alignment: Alignment.topRight, autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); context.vRouter.pop(); }, ), ], ), ], ), ), ), ], ), ], ); } }