import 'dart:io'; import 'dart:ui'; import 'package:animations/animations.dart'; import 'package:fikoyt_akcali_v1/apps/finans/core/models/finans.model.dart' as semalar; import 'package:fikoyt_akcali_v1/apps/finans/core/services/para_birimleri_service.dart'; import 'package:fikoyt_akcali_v1/apps/finans/kisi/pages/ana-sayfa/ana-sayfa.dart'; import 'package:fikoyt_akcali_v1/apps/finans/kisi/pages/giris/giris.dart'; import 'package:fikoyt_akcali_v1/apps/finans/uye/hesaplar/__atik__/hesap-turleri/hesap-turleri.dart'; import 'package:fikoyt_akcali_v1/apps/finans/uye/hesaplar/_hesaplar-logic.dart'; import 'package:fikoyt_akcali_v1/apps/finans/uye/para-birimleri/para-birimleri.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; import '../../../../core/widgets/sol-menu/sol-menu.dart'; class FinansServis extends GetxService { Isar? isar; Rx aktifKullanici = Rx(null); /// NOT: Servisler HesaplarService hesaplarServis = HesaplarService(); ParaBirimleriService paraBirimleriService = ParaBirimleriService(); /// RxString baslik = RxString("Akçalı"); RxString altBaslik = RxString("Merkez"); Rx solMenu = Rx(null); Duration openContainerDuration = Duration(milliseconds: 750); Future init() async { return this; } @override void onInit() async { // TODO: implement onInit super.onInit(); await isar_init(); } isar_init() async { String executableDir; executableDir = (await FikoYTCoreService.programYolu(ekYol: "databases")); // if (Isar.getInstance("FikoYT.db")?.isOpen == true) { // if (isar != null) { // await isar?.close(); // } // } isar = Isar.getInstance("FikoYT.db") ?? await Isar.open( [ semalar.KullaniciSchema, semalar.BorcSchema, semalar.AlacakSchema, semalar.HesapSchema, semalar.FinansalHedeflerSchema, semalar.ParaBirimiSchema, semalar.CryptoAssetSchema, semalar.HareketSchema, semalar.YZTavsiyeSchema, semalar.PeriyodikIslemlerSchema, semalar.AboneliklerSchema, // semalar.FinancialStatementSchema, semalar.YatirimSchema, semalar.TaxCalculationSchema, semalar.PricingStrategySchema, semalar.FaturaSchema, semalar.InvoiceItemSchema, semalar.ProductSchema, semalar.HesapTuruSchema, ], directory: executableDir, name: "FikoYT.db", inspector: true, ); } solMenuAl(BuildContext context) { return solMenu.value = Container( constraints: BoxConstraints(maxHeight: 640), child: BackdropFilter( filter: ImageFilter.blur(sigmaX: 2, sigmaY: 2), child: FikoYTDrawer( tema: FikoYTDrawerTheme( backgroundColor: Theme.of(context).extension()?.backgroundColor?.withAlpha(230), elevation: 5, shadowColor: Theme.of(context).extension()?.shadowColor ?? Colors.white, ), childs: [ Container( padding: EdgeInsets.all(8), color: Colors.blue.withAlpha(100), child: Stack( children: [ Column( children: [ Obx( () => FikoytOvalResim( resimUrl: aktifKullanici.value?.profilResmiUrl ?? "👨🏻‍💼", tema: FikoYTOvalResimTheme(borderColor: Colors.blue, radius: 24, spacing: 5), ), ), Obx( () => FikoYTButton( text: aktifKullanici.value?.ismi ?? "", tema: FikoYTButtonTheme(textColor: Colors.black, fontWeight: FontWeight.w700, fontSize: 14), ), ), ], ), Align( alignment: Alignment.topRight, child: FikoYTButton( text: "⚙️", tema: (Theme.of(context).extension() ?? FikoYTButtonTheme()).copyWith( elevation: 0, radius: 56, edgePadding: EdgeInsets.all(5), ), onPressed: () { context.vRouter.to("/mesaici/ayarlar"); }, ), ), Align( alignment: Alignment.topLeft, child: FikoYTButton( text: Icon(Icons.power_off, color: Colors.red, applyTextScaling: true, size: 18), tema: (Theme.of(context).extension() ?? FikoYTButtonTheme()).copyWith( elevation: 0, radius: 56, edgePadding: EdgeInsets.all(0), textShadow: [], ), onPressed: () { /// Giriş Başarılı toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.error, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text("Sn. ${aktifKullanici.value?.ismi} Çıkışınız Yapıldı."), alignment: Alignment.topRight, autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); aktifKullanici.value = null; context.vRouter.to("/giris"); }, ), ), ], ), ), Expanded( child: ListView( children: [ SizedBox( height: 32, child: ShaderMask( shaderCallback: (Rect rect) { return const LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, colors: [Colors.purple, Colors.transparent, Colors.transparent, Colors.purple], stops: [0.0, 0.1, 0.9, 1.0], // 10% purple, 80% transparent, 10% purple ).createShader(rect); }, blendMode: BlendMode.dstOut, child: ListView( shrinkWrap: true, physics: const BouncingScrollPhysics(), scrollDirection: Axis.horizontal, // your ListView children: [ const SizedBox(width: 20), for (var i = 0; i < TemaModu.values.length; i++) Obx(() { Rx tmmd = TemaModu.values[i].obs; return Padding( padding: const EdgeInsets.symmetric(horizontal: 1), child: FikoYTButton( text: "${tmmd.value.simge} ${tmmd.value.ismi}", // tema: Theme.of(context).extension()?.copyWith( // borderColor: Colors.grey.shade400, // backgroundColor: // tmmd.value.ismi == FikoYTCoreService.temaModu.ismi // ? Colors.blue.withOpacity(0.7) // : Colors.black.withOpacity(0), // edgePadding: const EdgeInsets.symmetric(vertical: 2, horizontal: 5), // textColor: Theme.of(context).extension()?.textColor, // textStrokeColor: Colors.blue, // ), onLongPress: () {}, onPressed: () { FikoYTCoreService.temaModu = tmmd.value; FikoYTCoreService.parlaklik.refresh(); // FikoYTService.servisMesaici.ayarlarModel!.value.calismaSuresiAyarlari.aktifVardiya = i; }, ), ); }), const SizedBox(width: 20), ], ), ), ), animasyonluWidgetAc( routeSettings: RouteSettings(name: "/uye/akcali/ana-sayfa", arguments: null), mevcutWidget: (context, action) { // girisAction = action; return ListTile( dense: true, minVerticalPadding: 3, contentPadding: EdgeInsets.zero, minTileHeight: 0, title: FikoYTButton(text: "🏡 Ana Sayfa"), // onTap: () { // context.vRouter.to("/uye/akcali/ana-sayfa"); // }, ); }, acilacakWidget: (context, action) { return SayfaKisiAna(); }, ), /// ExpansionTile( initiallyExpanded: true, title: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Expanded(child: Divider(indent: 0.0, endIndent: 10.0, thickness: 1)), FikoYTButton( text: '🧩 Uygulamalar', tema: Theme.of(context).extension()?.copyWith( textStrokeColor: Colors.transparent, textColor: Theme.of(context).extension()?.textColor?.withAlpha(150), ), ), const Expanded(child: Divider(indent: 10.0, endIndent: 0.0, thickness: 1)), ], ), tilePadding: EdgeInsets.zero, childrenPadding: EdgeInsets.only(left: 10), dense: true, minTileHeight: 0, shape: const Border(), children: [ ExpansionTile( initiallyExpanded: true, tilePadding: EdgeInsets.zero, childrenPadding: EdgeInsets.only(left: 10), dense: true, minTileHeight: 0, shape: const Border(), title: FikoYTButton(text: "💱 FikoYT Akçalı"), children: [ animasyonluWidgetAc( routeSettings: RouteSettings(name: "/uye/akcali/ana-sayfa", arguments: null), mevcutWidget: (context, action) { // girisAction = action; return ListTile( dense: true, minVerticalPadding: 3, contentPadding: EdgeInsets.zero, minTileHeight: 0, title: FikoYTButton(text: "🏘 Ana Pano"), ); }, acilacakWidget: (context, action) { return SayfaKisiGiris(); }, ), ExpansionTile( initiallyExpanded: true, tilePadding: EdgeInsets.zero, childrenPadding: EdgeInsets.only(left: 10), dense: true, minTileHeight: 0, shape: const Border(), title: FikoYTButton(text: "👨🏼‍🔧 Sabitler"), children: [ /// animasyonluWidgetAc( routeSettings: RouteSettings(name: "/uye/akcali/hesap-turleri", arguments: null), mevcutWidget: (context, action) { // girisAction = action; return ListTile( dense: true, minVerticalPadding: 3, contentPadding: EdgeInsets.zero, minTileHeight: 0, title: FikoYTButton(text: "🏷️ Hesap Türleri"), ); }, acilacakWidget: (context, action) { return SayfaHesapTurleri(); }, ), /// animasyonluWidgetAc( routeSettings: RouteSettings(name: "/uye/akcali/para-birimleri", arguments: null), mevcutWidget: (context, action) { // girisAction = action; return ListTile( dense: true, minVerticalPadding: 3, contentPadding: EdgeInsets.zero, minTileHeight: 0, title: FikoYTButton(text: "💴 Para Birimleri"), ); }, acilacakWidget: (context, action) { return SayfaParaBirimleri(); }, ), ], ), ], ), /// ], ), /// ], ), ), /** */ ], ), ), ); } profilResmiDegistir() async { FilePickerResult? result = await FilePicker.platform.pickFiles( allowMultiple: false, type: FileType.image, lockParentWindow: true, ); print(result); if (result != null) { File storeImage = File(result.files.first.path!); // use getApplicationDocumentsDirectory() to get a directory inside the app aktifKullanici.value?.profilResmiUrl = storeImage.absolute.path; isar?.writeTxn(() async { isar?.kullanicis.put(aktifKullanici.value!); }); aktifKullanici.refresh(); } else { // profilResmi.value = null; } } profilResmiSil() async { if (aktifKullanici.value?.profilResmiUrl != null) { // use getApplicationDocumentsDirectory() to get a directory inside the app aktifKullanici.value?.profilResmiUrl = null; isar?.writeTxn(() async { isar?.kullanicis.put(aktifKullanici.value!); }); aktifKullanici.refresh(); } else { // profilResmi.value = null; } } /// List rotalar = []; animasyonluWidgetAc({ String? ozelId, required Widget Function(BuildContext, void Function()) mevcutWidget, required Widget Function(BuildContext, void Function({Never returnValue})) acilacakWidget, Color closedColor = Colors.transparent, Color openColor = Colors.white, Color? middleColor = Colors.transparent, double closedElevation = 0.0, double openElevation = 0.0, ShapeBorder closedShape = const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(0.0))), ShapeBorder openShape = const RoundedRectangleBorder(), void Function(Object?)? onClosed, bool tappable = false, Duration? transitionDuration, ContainerTransitionType transitionType = ContainerTransitionType.fade, bool useRootNavigator = false, RouteSettings? routeSettings, Clip clipBehavior = Clip.antiAlias, }) { // FikoYTRotaGecmis? kyt = rotalar.firstWhereOrNull((item) => item.ozelId == (ozelId ?? routeSettings?.name)); // if (kyt != null) { // return kyt.konteynir; // } // for (var i = rotalar.length - 1; i > 0; i--) { // FikoYTRotaGecmis element = rotalar[i]; // if (element.rota == (ozelId ?? routeSettings?.name)) { // return element.konteynir; // } // } void Function({Never returnValue})? closeAction; void Function()? openAction; OpenContainer rslt = OpenContainer( routeSettings: routeSettings, useRootNavigator: useRootNavigator, closedColor: closedColor, closedElevation: closedElevation, middleColor: middleColor, openElevation: openElevation, tappable: tappable, closedShape: closedShape, transitionDuration: transitionDuration ?? openContainerDuration, transitionType: transitionType, closedBuilder: (context, action) { openAction = action; return mevcutWidget(context, action); }, openBuilder: (context, action) { closeAction = action; return acilacakWidget(context, action); }, onClosed: (data) { rotalar.removeWhere((item) => item.ozelId == (ozelId ?? routeSettings?.name)); if (onClosed != null) onClosed(data); }, ); // rotalar.add( // FikoYTRotaGecmis( // ozelId: ozelId ?? routeSettings?.name ?? Random(5000).toString(), // rota: ozelId ?? routeSettings?.name ?? Random(5000).toString(), // konteynir: rslt, // closeAction: openAction, // openAction: closeAction, // ), // ); // print(rotalar.length); return rslt; } } class FikoYTRotaGecmis { final String ozelId; final String rota; final OpenContainer konteynir; final void Function()? closeAction; final void Function()? openAction; FikoYTRotaGecmis({required this.ozelId, required this.rota, required this.konteynir, this.closeAction, this.openAction}); }