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/hareketler/hareket-ekle/hareket-ekle.dart'; import 'package:fikoyt_akcali_v1/apps/finans/uye/hesaplar/_hesaplar-logic.dart'; import 'package:fikoyt_akcali_v1/apps/finans/uye/hesaplar/hesap/pages/hesap-ekle.dart'; import 'package:fikoyt_akcali_v1/apps/finans/uye/hesaplar/hesap/widgets/hareketler_item.dart'; import 'package:fikoyt_akcali_v1/apps/finans/uye/hesaplar/hesap/widgets/hesap.fab.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:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:isar/isar.dart'; class SayfaHesap extends StatefulWidget { SayfaHesap({super.key, required this.hesapId}); String? hesapId; @override State createState() => _SayfaHesapState(); } class _SayfaHesapState extends State { FinansServis? finansServis = FikoYTCoreService.servisler.getServis(); HesaplarService? logicHesaplar; Rx hesap = Rx(null); Rx hesaplama = Rx(""); bool isOpenFab = false; final fabPageViewController = PageController(viewportFraction: 1, keepPage: true); @override void initState() { super.initState(); // finansServis = FikoYTCoreService.servisler.getServis(); logicHesaplar = Get.put(HesaplarService()); SchedulerBinding.instance.addPostFrameCallback((_) { // logic.gun.value = widget.gun; hesap.value = logicHesaplar?.hesapByIdSync(int.tryParse(widget.hesapId ?? "-1") ?? -1); // await logic.alHareketler(); // await logic.alAltHareketler(); // logic.gun.refresh(); // finansServis?.altBaslik.value = "Hesap Yönetimi"; finansServis?.solMenuAl(context); }); } @override void dispose() { // Get.delete(); super.dispose(); } @override Widget build(BuildContext context) { return FikoYTSliverApp( leading: UygulamaBaslikSol(), title: UygulamaBaslikOrta(altBaslik: "Hesap Yönetimi"), 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: Obx(() => HesapFab(hesap: hesap.value)), headerWidget: Obx( () => HeaderWidget( ovalResimUrl: hesap.value?.simgesi ?? "💳", ovalResimTheme: FikoYTOvalResimTheme(borderColor: hesap.value?.rengi), baslik: hesap.value?.ismi ?? "İsimsiz Hesap", baslikTheme: Theme.of(context).extension()?.copyWith( textColor: Theme.of(context).extension()?.secondaryTextColor, fontWeight: FontWeight.bold, fontSize: 16, ), altBaslik: (hesap.value?.aciklama != null && hesap.value?.aciklama != "") ? "${(hesap.value?.ismi != null && hesap.value?.ismi != "") ? '${hesap.value?.ismi} İsimli' : 'İsim Verilmemiş'} Finansal Hesabınızı Yönetin" : hesap.value?.aciklama, 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: "${hesap.value?.hesapTipi.emoji ?? ''}${hesap.value?.hesapTipi.isim ?? ''}", tema: Theme.of(context).extension()?.copyWith( textColor: Theme.of(context).extension()?.secondaryTextColor, fontWeight: FontWeight.normal, textShadow: [], fontSize: 12, ), ), ], ), // ovalResimTiklandi: finansServis?.profilResmiDegistir, ovalResimCiftTiklandi: finansServis?.profilResmiSil, ), ), headerBottomBar: Container( color: Theme.of(context).extension()?.cardBackgroundColor?.withAlpha(200), child: Row( children: [ FikoYTButton( text: "🗑", tema: Theme.of(context).extension()?.copyWith(edgePadding: EdgeInsets.all(5)), 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: '${hesap.value!.ismi ?? ""} Hesabı Silinecek. Onaylıyormusunuz?', btnCancelOnPress: () { // context.vRouter.pop(); }, btnCancelColor: Colors.green, btnCancelText: "İptal", btnOkOnPress: () async { await logicHesaplar?.isar?.writeTxn(() async { await logicHesaplar?.hesapSilById(hesap.value!.id); /// Başarılı toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.warning, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text("${hesap.value!.ismi ?? ""} Hesabı Silindi."), alignment: Alignment.topRight, autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); // widget.animClose != null ? widget.animClose!() : null; Navigator.pop(context); }); }, btnOkColor: Colors.red, btnOkText: "Sil", ).show(); }, ), Spacer(), finansServis?.animasyonluWidgetAc( routeSettings: RouteSettings( name: "/uye/hesaplar/hesap/:hesapId/duzenle", arguments: {"hesapId": widget.hesapId.toString()}, ), mevcutWidget: (context, action) => FikoYTButton( text: "🖋", tema: Theme.of(context).extension()?.copyWith(edgePadding: EdgeInsets.all(5)), onPressed: action, // () { // context.vRouter.to("/uye/hesaplar/hesap/${widget.hesapId}/duzenle"); // }, ), acilacakWidget: (context, action) => SayfaHesapEkle(kyt: hesap.value?.obs, animClose: action), onClosed: (p0) { hesap.value = logicHesaplar?.hesapByIdSync(int.tryParse(widget.hesapId ?? "-1") ?? -1); hesap.refresh(); setState(() {}); }, ), ], ), ), /// golgeGoster: false, bodyColor: Colors.transparent, bodyMaxWidth: 400, body: [ // SizedBox(height: 15), /** */ Container( decoration: BoxDecoration( color: Theme.of(context).extension()?.cardBackgroundColor, borderRadius: BorderRadius.circular(0), border: Border.all(color: Colors.grey.shade400), ), padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), margin: EdgeInsets.symmetric(vertical: 0, horizontal: 0), child: Row( children: [ FikoYTButton(text: "Hesap Hareketleri", tema: FikoYTButtonTheme(fontSize: 12)), Spacer(), finansServis?.animasyonluWidgetAc( mevcutWidget: (context, action) { // girisAction = action; return FikoYTButton(text: "+", tema: FikoYTButtonTheme(fontSize: 18)); }, acilacakWidget: (context, action) => SayfaHareketEkle(animClose: action, hesap: hesap.value, hareketTuru: "Gelir"), onClosed: (p0) { hesap.refresh(); }, ), // FikoYTButton( // text: "➜", // onPressed: () { // // hesaplarServis?.guncelle.refresh(); // }, // ), ], ), ), /// Obx(() { finansServis?.hesaplarServis.guncelle.value; return FutureBuilder( future: hesap.value?.islemler .filter() .offset(0) .limit(finansServis?.hesaplarServis.limit.value ?? 99999999) .findAll(), //,hesaplarServis?.listeAl(0, 1000), builder: (context, snapshot) { return Column( children: [ Visibility( visible: snapshot.data?.isEmpty ?? true, child: 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: Theme.of(context).extension()?.cardBackgroundColor, border: Border.all(color: Colors.grey.shade400), ), child: Column( children: [ const Row( mainAxisAlignment: MainAxisAlignment.center, children: [Text("🙅‍♀️", style: TextStyle(fontSize: 48))], ), FikoYTButton( text: "Hiç Hareketiniz Yok", tema: Theme.of(context).extension()?.copyWith( textColor: Colors.black, textStrokeColor: Colors.white, fontSize: 20, ), ), Wrap( alignment: WrapAlignment.center, crossAxisAlignment: WrapCrossAlignment.center, children: [ Align( alignment: Alignment.center, child: finansServis?.animasyonluWidgetAc( ozelId: "Hesap-HareketEkle-1", routeSettings: RouteSettings(name: "/uye/akcali/hesap-turleri", arguments: null), mevcutWidget: (context, action) { return FikoYTButton( text: "🛒 Hareket Ekle", tema: FikoYTButtonTheme( // backgroundColor: Colors.amberAccent, radius: 0, edgePadding: EdgeInsets.symmetric(horizontal: 1, vertical: 3), fontWeight: FontWeight.bold, textShadow: List.empty(), fontSize: 14, textColor: Colors.blue, ), ); }, acilacakWidget: (context, action) { return SayfaHareketEkle(animClose: action, hesap: hesap.value!); }, onClosed: (p0) { finansServis?.hesaplarServis.guncelle.refresh(); }, ), // TextButton( // // icon: const Text("💡"), // child: const Text( // "💡 Şimdi Ekle", // style: TextStyle(color: Colors.blue, fontWeight: FontWeight.bold, fontSize: 14), // ), // onPressed: () async { // dialogHesapEkle(context); // }, // ), ), ], ), ], ), ), ), ], ); }, ); }), ...[1, 2, 3, 4, 5, 6] .asMap() .entries .map((entry) { int index = entry.key; return finansServis?.animasyonluWidgetAc( ozelId: "RotaWidgetAbur.$index", mevcutWidget: (context, action) => Container( padding: EdgeInsets.all(1), child: ListTileTheme( contentPadding: EdgeInsets.all(2), dense: true, horizontalTitleGap: 0, minVerticalPadding: 5, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0)), child: HareketlerItem(animClose: action), ), ), acilacakWidget: (context, action) => Scaffold(body: Container()), ); }) .toList() .cast(), ], sliverAltKisim: SizedBox.shrink(), ); } }