import 'dart:ui'; import 'package:fikoyt_akcali_v1/apps/finans/core/services/finans.servis.dart'; import 'package:fikoyt_akcali_v1/apps/finans/core/widgets/akcali-ui/mini-hesap-kart.dart'; import 'package:fikoyt_akcali_v1/apps/finans/kisi/pages/ana-sayfa/hesap_ekle_dialog_widget.dart'; import 'package:fikoyt_akcali_v1/apps/finans/uye/hesaplar/_hesaplar-logic.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; class HesapListesiWidget extends StatelessWidget { HesapListesiWidget({super.key}); FinansServis? finansServis; HesaplarService? hesaplarServis; @override StatelessElement createElement() { // TODO: implement createElement finansServis = FikoYTCoreService.servisler.getServis(); hesaplarServis = Get.put(HesaplarService()); return super.createElement(); } @override Widget build(BuildContext context) { return Column( children: [ Container( margin: EdgeInsets.symmetric(vertical: 10), child: Row( children: [ FikoYTButton(text: "Hesaplarınız", tema: FikoYTButtonTheme(fontSize: 12)), Spacer(), FikoYTButton( text: "➜", onPressed: () { hesaplarServis?.guncelle.refresh(); }, ), ], ), ), /// // if ((finansServis?.isar?.hesaps.countSync() ?? 0) > 0) Obx(() { hesaplarServis?.guncelle.value; return FutureBuilder( future: finansServis?.aktifKullanici.value?.hesaplar .filter() .offset(0) .limit(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: 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: 48))], ), FikoYTButton( text: "Hiç Hesabınız 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: TextButton( // icon: const Text("💡"), child: const Text( "💡 Şimdi Ekle", style: TextStyle(color: Colors.blue, fontWeight: FontWeight.bold, fontSize: 14), ), onPressed: () async { dialogHesapEkle(context); }, ), ), ], ), ], ), ), ), /// Visibility( visible: snapshot.hasData, child: Wrap( spacing: 2, runSpacing: 2, children: (snapshot.data ?? []) .asMap() .entries .map((entry) { int index = entry.key; var hesap = entry.value; return MiniHesapKart( baslik: hesap.ismi, altBaslik: "0 ${hesap.paraBirimi.value?.kod ?? ''}", sagUstBaslik: hesap.paraBirimi.value?.sembol, onPressed: () { context.vRouter.to("/uye/hesaplar/hesap/${hesap.id}"); }, ).animate( effects: [FadeEffect(begin: 0, end: 1, delay: Duration(milliseconds: (index) * 50 + 250))], ); }) .toList() .cast(), ), ), SizedBox(height: 5), Row( children: [ Visibility( visible: (hesaplarServis?.limit.value ?? 0) > (hesaplarServis?.sayi.value ?? 3), child: Column( children: [ FikoYTButton( text: "Daha Az", tema: FikoYTButtonTheme( textColor: Theme.of(context).extension()?.infoTextColor, fontSize: 14, ), onPressed: () { hesaplarServis?.limit.value -= hesaplarServis?.sayi.value ?? 1; hesaplarServis?.guncelle.refresh(); }, ), ], ), ), Spacer(), Visibility( visible: (hesaplarServis?.limit.value ?? 0) > (hesaplarServis?.sayi.value ?? 3), child: Column( children: [ FikoYTButton( text: "Sıfırla", tema: FikoYTButtonTheme( textColor: Theme.of(context).extension()?.infoTextColor, fontSize: 14, ), onPressed: () { hesaplarServis?.limit.value = hesaplarServis?.sayi.value ?? 1; hesaplarServis?.guncelle.refresh(); }, ), ], ), ), if (((hesaplarServis?.limit.value ?? 0) < (finansServis?.aktifKullanici.value?.hesaplar.filter().countSync() ?? 0))) Spacer(), Visibility( visible: (hesaplarServis?.limit.value ?? 0) < (finansServis?.aktifKullanici.value?.hesaplar.filter().countSync() ?? 0), child: Column( children: [ FikoYTButton( text: "Daha Fazla", tema: FikoYTButtonTheme( textColor: Theme.of(context).extension()?.infoTextColor, fontSize: 14, ), onPressed: () { hesaplarServis?.limit.value += hesaplarServis?.sayi.value ?? 1; hesaplarServis?.guncelle.refresh(); }, ), ], ), ), ], ), BalloonWidget( balloonContent: Row( children: [ Icon(Icons.star, color: Colors.white), SizedBox(width: 5), Text('Bu bir örnek widget!', style: TextStyle(color: Colors.white)), ], ), child: Icon(Icons.info_outline, size: 50, color: Colors.blue), ), ], ); }, ); }), /// const SizedBox(height: 5), // if ((finansServis?.isar?.hesaps.countSync() ?? 0) > 0) Align( alignment: Alignment.centerRight, child: SizedBox( // width: 130, child: FikoYTButton( text: "🎫 Hesap Ekle", tema: FikoYTButtonTheme( fontSize: 10, textColor: Colors.blueAccent, textStrokeColor: Colors.transparent, backgroundColor: Colors.white.withValues(alpha: 180), borderColor: Colors.lightBlueAccent, edgePadding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10), textStrokeWidth: 0, textAlign: TextAlign.center, ), onPressed: () { dialogHesapEkle(context); }, ), ), ), ], ); } Future dialogHesapEkle(BuildContext context) { return showModalBottomSheet( context: context, showDragHandle: true, isScrollControlled: true, constraints: BoxConstraints(maxHeight: 560, maxWidth: 420), // backgroundColor: Colors.white.withAlpha(230), elevation: 5, useSafeArea: true, builder: (BuildContext context) { return GestureDetector( behavior: HitTestBehavior.opaque, child: BackdropFilter(filter: ImageFilter.blur(sigmaX: 1, sigmaY: 1), child: HesapEkleDialogWidget()), ); }, ); } } /// class BalloonWidget extends StatefulWidget { final Widget child; final Widget balloonContent; const BalloonWidget({super.key, required this.child, required this.balloonContent}); @override _BalloonWidgetState createState() => _BalloonWidgetState(); } class _BalloonWidgetState extends State { bool _isOpen = false; late double _childPositionY; void _toggleBalloon() { setState(() { _isOpen = !_isOpen; }); } @override Widget build(BuildContext context) { return GestureDetector( onTap: _toggleBalloon, child: Builder( builder: (context) { final renderBox = context.findRenderObject() as RenderBox?; _childPositionY = renderBox?.localToGlobal(Offset.zero).dy ?? 0.0; return Stack( clipBehavior: Clip.none, children: [ widget.child, if (_isOpen) Positioned( top: _childPositionY - (_childPositionY > 200 ? 0 : 50), left: 20, child: Material( color: Colors.transparent, child: Container( padding: EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.blueAccent, borderRadius: BorderRadius.circular(8), boxShadow: [BoxShadow(blurRadius: 5, color: Colors.black.withOpacity(0.2), offset: Offset(0, 4))], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ widget.balloonContent, SizedBox(height: 10), Positioned( left: 50, child: CustomPaint(size: Size(10, 10), painter: _ArrowPainter(isAbove: _childPositionY > 200)), ), ], ), ), ), ), ], ); }, ), ); } } class _ArrowPainter extends CustomPainter { final bool isAbove; _ArrowPainter({required this.isAbove}); @override void paint(Canvas canvas, Size size) { final paint = Paint()..color = Colors.blueAccent; final path = Path(); if (isAbove) { path.moveTo(0, 10); path.lineTo(10, 10); path.lineTo(5, 0); } else { path.moveTo(0, 0); path.lineTo(10, 0); path.lineTo(5, 10); } path.close(); canvas.drawPath(path, paint); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) { return false; } }