import 'dart:convert'; import 'package:fikoyt_mesaici/apps/mesaici/base_page_mesaici_view.dart'; import 'package:fikoyt_mesaici/apps/mesaici/model/ayarlar/model_ayarlar.dart'; import 'package:fikoyt_mesaici/apps/mesaici/pages/ayarlar/maas_parametreleri/vergi_ekle.dart'; import 'package:fikoyt_mesaici/apps/mesaici/servisler/fikoyt.mesaici.service.dart'; import 'package:fikoyt_mesaici/core/fikoyt.service.dart'; import 'package:fikoyt_mesaici/core/interface/fiko_dialog_ayarlari.dart'; import 'package:fikoyt_mesaici/core/widgets/fiko_ui/fiko_button/fiko_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:get/get.dart'; class VergilerWidget extends StatelessWidget { VergilerWidget({super.key, required this.kayit}); BasePageMesaiciLogic basePageMesaiciLogic = Get.put(BasePageMesaiciLogic()); final FikoYTMesaiciService servisMesaici = Get.put(FikoYTMesaiciService()); final FikoYTService servisFikoYT = FikoYTService(); final Rx? kayit; final RxBool showToolbar = false.obs; @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Expanded( child: Divider( indent: 0.0, endIndent: 10.0, thickness: 1, ), ), FikoButton1( text: '🧾 Vergiler', // textSize: 10, textStrokeColor: Colors.transparent, textColor: Colors.black, onPressed: () { showToolbar.toggle(); }, ), const Expanded( child: Divider( indent: 10.0, endIndent: 0.0, thickness: 1, ), ), SizedBox( width: 24, child: MaterialButton( elevation: 0, minWidth: 0, shape: CircleBorder( // borderRadius: // const BorderRadius.all( // Radius.circular(5)), side: BorderSide(width: 1, color: Colors.blue.withOpacity(0.5), style: BorderStyle.solid), ), padding: const EdgeInsets.all(0), // color: Colors.white, onPressed: () async { Vergi vrg = Vergi(); FikoYTService.dialogGoster( context, SizedBox( width: 250, child: VergiEkle( vergi: vrg, ), ), FikoDialogAyarlari(baslik: "Vergi Tanımlama", baslikSimge: "🧾", altButonlar: [ FikoButton1( textColor: Colors.green, textStrokeColor: Colors.transparent, text: "Ekle", edgePadding: const EdgeInsets.symmetric(horizontal: 5, vertical: 0), onPressed: (() { List vrglr = kayit?.value!.vergiler?.toList() ?? []; vrglr.add(vrg); kayit?.value?.vergiler = vrglr; // kayit?.refresh(); servisMesaici.ayarlarModel?.refresh(); Navigator.pop( context, ); }), ), const Spacer(), FikoButton1( textColor: Colors.red, textStrokeColor: Colors.transparent, text: "Kapat", edgePadding: const EdgeInsets.symmetric(horizontal: 5, vertical: 0), onPressed: (() { Navigator.pop( context, ); }), ), ]), ); }, child: const Text( "➕", ), // const Icon(Icons.notifications, // color: Colors.lightBlue, size: 14), ), ), ], ), /** */ Obx(() => AnimatedSwitcher( duration: const Duration(seconds: 1), child: showToolbar.value == true ? Container( alignment: Alignment.centerLeft, padding: const EdgeInsets.all(1), margin: const EdgeInsets.symmetric(vertical: 5), decoration: BoxDecoration( border: Border.all(color: Colors.grey.shade300), borderRadius: BorderRadius.circular(15), color: Colors.grey.shade100, ), child: SizedBox( height: 18.0, 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, scrollDirection: Axis.horizontal, physics: const BouncingScrollPhysics(), children: [ FikoButton1( text: "🗐 Panoya Kopyala", textSize: 10, textAlign: TextAlign.start, edgePadding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 5), textStrokeWidth: 0, textColor: Colors.black87, textStrokeColor: Colors.transparent, onPressed: () { String data = json.encode(kayit?.value?.vergiler); Clipboard.setData(ClipboardData(text: data)); ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: const Text('Vergi Listesi Panoya Kopyalandı'), action: SnackBarAction( label: 'Tamam', onPressed: () { // Action butonuna tıklanınca yapılacak işlemler }, ), duration: const Duration(seconds: 2), // SnackBar'ın ekranda kalma süresi ), ); }, ), FikoButton1( text: "📋 Panodan Çek", textSize: 10, textAlign: TextAlign.start, edgePadding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 5), textStrokeWidth: 0, textColor: Colors.black87, textStrokeColor: Colors.transparent, onPressed: () async { try { List lst = []; dynamic panoData = json.decode((await Clipboard.getData(Clipboard.kTextPlain))?.text ?? "[]"); for (var i = 0; i < panoData.length; i++) { lst.add(Vergi.fromJson(panoData[i])); } kayit?.value?.vergiler = lst; servisMesaici.aktifCalisma?.refresh(); ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: const Text('Vergi Listesi Panodan Kopyalandı'), action: SnackBarAction( label: 'Tamam', onPressed: () { // Action butonuna tıklanınca yapılacak işlemler }, ), duration: const Duration(seconds: 2), // SnackBar'ın ekranda kalma süresi ), ); } catch (e) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: const Text('Veri Hatası'), action: SnackBarAction( label: 'Tamam', onPressed: () { // Action butonuna tıklanınca yapılacak işlemler }, ), duration: const Duration(seconds: 2), // SnackBar'ın ekranda kalma süresi ), ); } }, ), FikoButton1( text: "📡 İnternetten Çek", textSize: 10, textAlign: TextAlign.start, edgePadding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 5), textStrokeWidth: 0, textColor: Colors.black87, textStrokeColor: Colors.transparent, onPressed: () {}, ), FikoButton1( text: "📂 Dosyadan Çek", textSize: 10, textAlign: TextAlign.start, edgePadding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 5), textStrokeWidth: 0, textColor: Colors.black87, textStrokeColor: Colors.transparent, onPressed: () {}, ), FikoButton1( text: "🗑️ Tümünü Sil", textSize: 10, textAlign: TextAlign.start, edgePadding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 5), textStrokeWidth: 0, textColor: Colors.black87, textStrokeColor: Colors.transparent, onPressed: () async { FikoYTService.dialogGoster( context, const Text("Aktif Karttaki Tüm Vergiler Silinecek.Bu İşlem Geri Alınamaz. Onaylıyormusunuz?"), FikoDialogAyarlari(baslik: "Onay", baslikSimge: "❔", altButonlar: [ FikoButton1( textColor: Colors.green, textStrokeColor: Colors.transparent, text: "✔️ Onaylıyorum", onPressed: () { kayit?.value?.vergiler = []; servisMesaici.aktifCalisma?.refresh(); Navigator.pop( context, ); }, ), const Spacer(), FikoButton1( textColor: Colors.red, textStrokeColor: Colors.transparent, text: "❌ Onaylamıyorum", onPressed: (() { servisMesaici.ayarlarModel!.refresh(); Navigator.pop( context, ); }), ), ])); }, onLongPress: () { kayit?.value?.vergiler = []; servisMesaici.aktifCalisma?.refresh(); }, ), ], ), ), ), ) : null, )), /** */ // if ((maasObs.value.kesintiler ?? []).isEmpty) AnimatedCrossFade( crossFadeState: (kayit?.value?.vergiler ?? []).isEmpty ? CrossFadeState.showFirst : CrossFadeState.showSecond, duration: const Duration(milliseconds: 250), firstChild: Padding( padding: const EdgeInsets.only(top: 5), child: Align( alignment: const FractionalOffset(0.5, 0.5), child: Text( "Hiç Vergi Eklenmemiş", style: TextStyle(fontWeight: FontWeight.bold, color: Colors.red.shade400), textAlign: TextAlign.center, ), ), ).animate( effects: [ const FadeEffect(), const ShimmerEffect(), ], ), secondChild: Column( spacing: 2.0, children: [ for (var i = 0; i < (kayit?.value?.vergiler ?? []).length; i++) Obx( () { Vergi? vrgi__ = kayit?.value?.vergiler![i]; return FikoButton1( borderColor: Colors.grey.shade200, text: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "${vrgi__?.turu.simge} ${(vrgi__?.ismi ?? 'İsim Verilmemiş')}", ), const Spacer(), if (vrgi__?.vergiSekli == VergiSekli.SABIT) Row( children: [ FikoButton1( textColor: Colors.white, textStrokeColor: Colors.black, text: "${vrgi__?.miktar ?? '0.0'}", ), FikoButton1( textColor: Colors.amber, textStrokeColor: Colors.blue, text: "TL", ), ], ), if (vrgi__?.vergiSekli == VergiSekli.YUZDELIK) Row( children: [ FikoButton1( textColor: Colors.white, textStrokeColor: Colors.black, text: "${vrgi__?.oran ?? '0.0'}", ), FikoButton1( textColor: Colors.amber, textStrokeColor: Colors.blue, text: "%", ), ], ), if (vrgi__?.vergiSekli == VergiSekli.DIGER) Row( children: [ FikoButton1( textColor: Colors.white, textStrokeColor: Colors.black, text: "${vrgi__?.oran ?? '0.0'} % | ${vrgi__?.miktar ?? '0.0'} TL ", ), ], ), ], ), textAlign: TextAlign.start, backColor: Colors.black.withOpacity(0.0), edgePadding: const EdgeInsets.symmetric(vertical: 2, horizontal: 5), onPressed: () { FikoYTService.dialogGoster( context, SizedBox( width: 250, child: VergiEkle( vergi: vrgi__, ), ), FikoDialogAyarlari(baslik: "Vergi Düzenle", baslikSimge: "🔪", altButonlar: [ FikoButton1( textColor: Colors.red, textStrokeColor: Colors.transparent, text: "Sil", onPressed: () { List? list0 = kayit?.value?.vergiler?.toList() ?? []; list0.removeAt(i); kayit?.value?.vergiler = list0; // kayit?.refresh(); servisMesaici.ayarlarModel?.refresh(); Navigator.pop( context, ); }, ), const Spacer(), FikoButton1( textColor: Colors.green, textStrokeColor: Colors.transparent, text: "Kapat", onPressed: (() { // kayit?.refresh(); servisMesaici.ayarlarModel?.refresh(); Navigator.pop( context, ); }), ), ]), ); }, ).animate( effects: [const FadeEffect(), ShimmerEffect(delay: 1000.ms)], ); }, ), ], ), ), ], ).animate(effects: [ // FadeEffect(duration: 1000.ms, curve: Curves.easeIn), // ScaleEffect(begin: const Offset(0.2, 0.2),duration: 500.ms, curve: Curves.easeIn), FadeEffect(duration: 1000.ms), SaturateEffect(delay: 1000.ms, duration: 500.ms, curve: Curves.easeIn), BlurEffect( duration: 600.ms, begin: const Offset(3, 3), end: const Offset(0, 0), ), ShimmerEffect( delay: 1000.ms, duration: 1000.ms, curve: Curves.easeIn, ), ]); } }