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_ui/fikoyt_ui.dart'; import 'package:fikoyt_ui/ui/fikoyt_card.dart'; import 'package:fikoyt_ui/ui/yazi_kutulari/yazi_kutulari.dart'; import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; class ParaBirimleriService extends GetxService { Rx kayit = Rx(ParaBirimi()); Rx kayitEkleGoster = Rx(false); FinansServis? finansServis = FikoYTCoreService.servisler.getServis(); Isar? isar = FikoYTCoreService.servisler.getServis()?.isar; kayitKontrol() { kayit.value?.ismi != ""; } kaydet({required ParaBirimi kyt}) { isar?.writeTxn(() async { if (kyt.aciklama == "") { kyt.aciklama = null; } kyt.sahibi.value = finansServis?.aktifKullanici.value; await isar?.paraBirimis.put(kyt); await kyt.sahibi.save(); kayit.value = ParaBirimi(); kayitEkleGoster.value = false; kayitEkleGoster.refresh(); kayit.refresh(); }); } sil({required ParaBirimi kyt}) { isar?.writeTxn(() async { isar?.paraBirimis.delete(kyt.id); kayit.value = ParaBirimi(); kayitEkleGoster.value = false; kayitEkleGoster.refresh(); kayit.refresh(); }); } Future> listeAl(int page, int limit) async { return await isar?.paraBirimis .where() .filter() .sahibi((q) => q.idEqualTo(finansServis?.aktifKullanici.value?.id ?? -1)) .sortByIsmi() .offset(page * limit) .limit(limit) .findAll() ?? []; } List listeAlSync(int page, int limit) { return isar?.paraBirimis .where() .filter() .sahibi((q) => q.idEqualTo(finansServis?.aktifKullanici.value?.id ?? -1)) .offset(page * limit) .limit(limit) .findAllSync() ?? []; } FikoYTCard formParaBirimiListesi(BuildContext context) { print("sfsdfsf"); 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: "", 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: 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: listeAl(0, 1000), builder: (context, snapshot) { print(snapshot.data); 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(ParaBirimi 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: () { Navigator.of(context).pop(prbrm); }, subtitle: FikoYTButton( text: prbrm.aciklama ?? 'Açıklama Yok', tema: FikoYTButtonTheme(fontWeight: FontWeight.w200, fontSize: 12), ), ), ), ); } }