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/uye/hesaplar/_hesaplar-logic.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/Extensions/fiko_datetime.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:fikoyt_ui/ui/dialogs/fiko_dialog_ayarlari.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 SayfaUyeKrediliHesapEkle extends StatefulWidget { const SayfaUyeKrediliHesapEkle({super.key}); @override State createState() => _SayfaUyeKrediliHesapEkleState(); } class _SayfaUyeKrediliHesapEkleState extends State { FinansServis? finansServis; late HesaplarService logicHesaplar; @override void initState() { super.initState(); finansServis = FikoYTCoreService.servisler.getServis(); logicHesaplar = Get.put(HesaplarService()); SchedulerBinding.instance.addPostFrameCallback((_) { finansServis?.altBaslik.value = "Yeni Kredi Hesabı"; }); } @override void dispose() { Get.delete(); super.dispose(); } @override Widget build(BuildContext context) { return FikoYTSliverApp( leading: UygulamaBaslikSol(), title: UygulamaBaslikOrta(), actions: [UygulamaBaslikSag()], drawer: finansServis?.solMenuAl(context), backgroundColor: Theme.of(context).extension()?.backgroundColor, appBarColor: Theme.of(context).extension()?.appBarColor?.withAlpha(230), headerExpandedHeight: 230, // stretchMaxHeight: 100, fullyStretchable: true, centerTitle: true, alwaysShowLeadingAndAction: true, alwaysShowTitle: true, curvedBodyRadius: 0, golgeGoster: false, sliverAltKisim: SizedBox.shrink(), /// headerWidget: Obx( () => HeaderWidget( ovalResimUrl: finansServis?.aktifKullanici.value?.profilResmiUrl ?? "🎫", baslik: finansServis?.aktifKullanici.value?.ismi, baslikTheme: Theme.of(context).extension()?.copyWith( textColor: Theme.of(context).extension()?.secondaryTextColor, fontWeight: FontWeight.bold, fontSize: 16, ), altBaslik: "Sisteminizde Yeni Bir Kredi Hesabı Ekleyin.", altBaslikTheme: Theme.of(context).extension()?.copyWith( textColor: Theme.of(context).extension()?.tertiaryTextColor, fontWeight: FontWeight.normal, fontSize: 12, ), ovalResimTiklandi: finansServis?.profilResmiDegistir, ovalResimCiftTiklandi: finansServis?.profilResmiSil, ), ), /// body: [ const SizedBox(height: 10), /** */ FikoYTCard( theme: FikoYTCardTheme(boxConstraints: BoxConstraints(maxWidth: 300)), children: [ Column( spacing: 5, mainAxisSize: MainAxisSize.max, children: [ Center(child: Text('🎫', style: TextStyle(fontSize: 54))), FikoYTButton( text: 'Yeni Kredi Hesabı', tema: Theme.of(context).extension()?.copyWith( textStrokeColor: Colors.transparent, textColor: Theme.of(context).extension()?.textColor, ), ), FikoYaziKutusu( baslik: "Hesap İsmi", simgeSol: const Text("✏️", style: TextStyle(fontSize: 14)), yaziBoyutu: 12.0, radius: 5.0, degeri: logicHesaplar.hesap.value.ismi, degisti: (value) { logicHesaplar.hesap.value.ismi = value; }, ), FikoYaziKutusu( baslik: "Hesap No", simgeSol: const Text("🧬", style: TextStyle(fontSize: 14)), yaziBoyutu: 12.0, radius: 5.0, degeri: logicHesaplar.hesap.value.hesapNo, degisti: (value) { logicHesaplar.hesap.value.hesapNo = value; }, ), FikoYaziKutusu( baslik: "Hesap Emoji", simgeSol: const Text("⭐", style: TextStyle(fontSize: 14)), yaziBoyutu: 12.0, radius: 5.0, degeri: logicHesaplar.hesap.value.simgesi, degisti: (value) { logicHesaplar.hesap.value.simgesi = value; }, ), Obx( () => FikoYTButtonKutu( baslik: "Son Ödeme Günü", simgeSol: "📅", radius: 5.0, deger: logicHesaplar.hesap.value.krediliSonOdemeTarihi?.formatla("dd.MM.yyyy"), onPressed: () async { await (logicHesaplar.hesap.value.krediliSonOdemeTarihi ?? DateTime.now()) .tarihSec(context, ayarlar: FikoDialogAyarlari()) .then((value) { logicHesaplar.hesap.value.krediliSonOdemeTarihi = value; logicHesaplar.hesap.refresh(); }); }, ), ), FikoYaziKutusu( baslik: "Kredi Limiti", simgeSol: const Text("〽️", style: TextStyle(fontSize: 14)), yaziBoyutu: 12.0, radius: 5.0, degeri: logicHesaplar.hesap.value.krediLimiti?.toString(), degisti: (value) { logicHesaplar.hesap.value.krediLimiti = double.tryParse(value) ?? 0.0; }, ), Obx( () => FikoYTButtonKutu( baslik: "Para Birimi", simgeSol: "⛃", sonEk: Text(logicHesaplar.hesap.value.paraBirimi.value?.sembol ?? ""), // yaziBoyutu: 12.0, radius: 5.0, deger: logicHesaplar.hesap.value.paraBirimi.value?.ismi, onPressed: () { FikoYTCoreService.dialogGoster(context, formParaBirimiListesi(context), null); // showGeneralDialog( // context: context, // barrierDismissible: true, // barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, // transitionDuration: const Duration(milliseconds: 400), // pageBuilder: (context, animation, secondaryAnimation) { // return Center( // child: Material( // color: Colors.transparent, // child: SingleChildScrollView( // child: Column( // mainAxisSize: MainAxisSize.min, // Küçük diyalog olacak // children: [formParaBirimiListesi(context)], // ), // İçeriği buraya koyuyoruz // ), // ), // ); // }, // transitionBuilder: (context, animation, secondaryAnimation, child) { // return ScaleTransition( // scale: Tween( // begin: 0.7, // end: 1.0, // ).animate(CurvedAnimation(parent: animation, curve: Curves.easeOutBack)), // child: FadeTransition(opacity: animation, child: child), // ); // }, // ).then((value) {}); }, ), ), FikoAciklamaKutusu( baslik: "Açıklama", yaziBoyutu: 12.0, radius: 5.0, degeri: logicHesaplar.hesap.value.aciklama, degisti: (value) { logicHesaplar.hesap.value.aciklama = value; }, ), /// SizedBox(height: 5), Row( children: [ Spacer(), FikoYTButton( text: "🚪 Kaydet", tema: FikoYTButtonTheme( textColor: Colors.white, backgroundColor: Colors.blue, // fontWeight: FontWeight.w700, edgePadding: EdgeInsets.all(3), borderColor: Colors.blueAccent, elevation: 3, fontSize: 12, ), onPressed: () async { if (logicHesaplar.hesap.value.krediliBosMu) { /// 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; } int? yeniHesapId = await logicHesaplar.kaydet(hesapTipi: IHesapTipi.kredili); /// Başarılı toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.success, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text("Hesap 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.to("/uye/hesaplar/hesap/$yeniHesapId"); logicHesaplar.guncelle.refresh(); }, ), ], ), ], ), ], ), ], ); } FikoYTCard formParaBirimiListesi(BuildContext context) { return FikoYTCard( key: ValueKey("ParaBirimiListesiDialog"), theme: (Theme.of(context).extension() ?? FikoYTCardTheme()).copyWith( boxConstraints: BoxConstraints(maxWidth: 300), backgroundColor: Theme.of(context).extension()?.backgroundColor, ), children: [ Center(child: Text('💸', style: TextStyle(fontSize: 54))), Center( child: FikoYTButton( text: 'Para Birimi Seç', 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), Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, spacing: 5, children: [ FikoYaziKutusu( baslik: "Arama Yap", simgeSol: const Text("✏️", style: TextStyle(fontSize: 14)), yaziBoyutu: 12.0, radius: 5.0, degeri: logicHesaplar.hesap.value.ismi, degisti: (value) {}, ), Divider(height: 4), /// AnimatedSwitcher( duration: const Duration(milliseconds: 500), layoutBuilder: (Widget? currentChild, List previousChildren) { return Stack( alignment: Alignment.topCenter, children: [...previousChildren, if (currentChild != null) currentChild], ); }, transitionBuilder: (Widget child, Animation animation) { return FadeTransition( opacity: animation, child: SizeTransition(sizeFactor: animation, axisAlignment: 1.0, child: Center(child: child)), ); }, // visible: logic.aktifHareket.value != null ? logic.aktifHareket.value!.altKartlar.isEmpty : false, child: (logicHesaplar.logicParaBirimi?.listeAlSync(0, 1000) ?? []).isEmpty ? Container( // width: double.infinity, padding: const EdgeInsets.only(bottom: 20, top: 20, left: 5, right: 5), margin: EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.transparent, border: Border.all(color: Colors.grey.shade400), boxShadow: [ BoxShadow(color: Colors.teal.withOpacity(0.15), spreadRadius: -15.0, blurRadius: 12.0), const BoxShadow(color: Colors.transparent, spreadRadius: -5.0, blurRadius: 12.0), ], ), child: Column( children: [ const Row( mainAxisAlignment: MainAxisAlignment.center, children: [Text("💸", style: TextStyle(fontSize: 36))], ), FikoYTButton( text: "Para Birimi Yok", tema: Theme.of(context).extension()?.copyWith( textColor: Theme.of(context).extension()?.errorTextColor, textStrokeColor: Colors.white, fontSize: 16, ), ), /** */ ], ), ) : FutureBuilder( future: logicHesaplar.logicParaBirimi?.listeAl(0, 1000), builder: (context, snapshot) { return Column( children: [ if (snapshot.data != null) if (snapshot.data!.isNotEmpty) Material( color: Colors.transparent, child: ListView.builder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemCount: snapshot.data?.length, itemBuilder: (context, index) { return paraBirimiItem(snapshot.data![index], index, context); // FikoYTButton( // text: // "${snapshot[index].kod} ${snapshot[index].ismi} ${snapshot[index].sembol} -> ${snapshot[index].oran}", // ); }, ), ), /** */ ], ); }, ), ), /// 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 { context.vRouter.pop(); }, ), Spacer(), ], ), ], ), ), ], ); } Container paraBirimiItem(Kategori prbrm, int index, BuildContext context) { return Container( padding: EdgeInsets.all(3), child: ListTileTheme( contentPadding: EdgeInsets.zero, dense: true, horizontalTitleGap: 0, minVerticalPadding: 0, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), child: ListTile( leading: FikoYTButton(text: "${prbrm.sembol}"), title: FikoYTButton(text: "${prbrm.ismi} ${prbrm.kod}"), trailing: FikoYTButton(text: "${prbrm.oran}"), tileColor: Theme.of(context).extension()?.cardBackgroundColor, isThreeLine: false, onTap: () { logicHesaplar.hesap.value.paraBirimi.value = prbrm; logicHesaplar.hesap.refresh(); context.vRouter.pop(); }, subtitle: FikoYTButton( text: prbrm.aciklama ?? 'Açıklama Yok', tema: FikoYTButtonTheme(fontWeight: FontWeight.w200, fontSize: 12), ), ), ), ); } }