import 'dart:io'; 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/core/widgets/uygulama_baslik/uygulama_baslik.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:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:isar/isar.dart'; class SayfaKisiIlkKurulum extends StatefulWidget { const SayfaKisiIlkKurulum({super.key}); @override State createState() => _SayfaKisiIlkKurulumState(); } class _SayfaKisiIlkKurulumState extends State { final Rx kayit = Kullanici().obs; final _sirketButtonTheme = FikoYTButtonTheme( backgroundColor: Colors.blue, textColor: Colors.white, edgePadding: const EdgeInsets.only(right: 1, left: 4, top: 2, bottom: 2), borderRadius: BorderRadius.circular(10), fontSize: 10, borderColor: Colors.lightBlueAccent, ); final _tuzelButtonTheme = FikoYTButtonTheme( backgroundColor: Colors.transparent, textColor: Colors.black, edgePadding: const EdgeInsets.only(right: 4, left: 1, top: 2, bottom: 2), borderRadius: BorderRadius.circular(10), fontSize: 10, borderColor: Colors.lightBlueAccent, ); Future _selectImage() async { FilePickerResult? result = await FilePicker.platform.pickFiles( allowMultiple: false, type: FileType.image, lockParentWindow: true, ); if (result != null) { final storeImage = File(result.files.first.path!); kayit.value.profilResmiUrl = storeImage.absolute.path; kayit.refresh(); } } void _deleteImage() { kayit.value.profilResmiUrl = null; kayit.refresh(); } @override void initState() { super.initState(); SchedulerBinding.instance.addPostFrameCallback((_) { FikoYTCoreService.servisler.getServis()?.altBaslik.value = "İlk Kurulum"; }); } @override Widget build(BuildContext context) { return FikoYTSliverApp( leading: UygulamaBaslikSol(), title: const UygulamaBaslikOrta(), actions: [UygulamaBaslikSag()], backgroundColor: Theme.of(context).extension()?.backgroundColor, appBarColor: Theme.of(context).extension()?.appBarColor?.withAlpha(230), bodyColor: Colors.grey.shade300, headerExpandedHeight: 250, fullyStretchable: true, centerTitle: true, alwaysShowLeadingAndAction: true, alwaysShowTitle: true, curvedBodyRadius: 0, // onStretchTrigger: () async { // // context.vRouter.to("/"); // }, headerWidget: _HeaderWidget(), sliverAltKisimGoster: false, sliverAltKisim: null, body: [ const _BodyTopSection(), _DividerSection( sirketButtonTheme: _sirketButtonTheme, fikoTheme: Theme.of(context).extension(), buttonTheme: Theme.of(context).extension(), ), _FormSection( kayit: kayit, sirketButtonTheme: _sirketButtonTheme, tuzelButtonTheme: _tuzelButtonTheme, selectImage: _selectImage, deleteImage: _deleteImage, ), const _BottomAlert(), ], ); } } class _HeaderWidget extends StatelessWidget { const _HeaderWidget(); @override Widget build(BuildContext context) { return Column( children: [ SizedBox(height: kToolbarHeight), FikoytOvalResim( resimUrl: "packages/fikoyt_ui/assets/fitness_app/lunch.png", tema: FikoYTOvalResimTheme(borderColor: Colors.blue), ), FikoYTButton( text: "İlk Kurulum", tema: FikoYTButtonTheme(textColor: Colors.black, fontWeight: FontWeight.w700, fontSize: 18), ), FikoYTButton( text: "Sistem kurulumunu yapmak için bilgileri doldurunuz. Yönlendirmelere göre sisteminizi ayarlayınız.", tema: FikoYTButtonTheme( textColor: Colors.black38, fontWeight: FontWeight.normal, fontSize: 12, textAlign: TextAlign.center, ), ), ], ); } } class _BodyTopSection extends StatelessWidget { const _BodyTopSection(); @override Widget build(BuildContext context) { return Column( children: [ SizedBox(height: 10), FikoYTButton( text: "Aşağıdaki Formu Doldurarak Sisteminizin Kurulumuna Başlayabilirsiniz.", tema: FikoYTButtonTheme(textAlign: TextAlign.center, textColor: Colors.black38, fontSize: 12), ), SizedBox(height: 10), ], ); } } class _DividerSection extends StatelessWidget { final FikoYTButtonTheme? buttonTheme; final FikoTheme? fikoTheme; const _DividerSection({required this.buttonTheme, required this.fikoTheme, required FikoYTButtonTheme sirketButtonTheme}); @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Expanded(child: Divider(indent: 0.0, endIndent: 10.0, thickness: 1)), FikoYTButton( text: '👔 Yönetici Hesabı Tanımlama', tema: buttonTheme?.copyWith(textStrokeColor: Colors.transparent, textColor: fikoTheme?.textColor), ), const Expanded(child: Divider(indent: 10.0, endIndent: 0.0, thickness: 1)), ], ); } } class _FormSection extends StatelessWidget { final Rx kayit; final FikoYTButtonTheme _sirketButtonTheme; final FikoYTButtonTheme _tuzelButtonTheme; final VoidCallback selectImage; final VoidCallback deleteImage; const _FormSection({ required this.kayit, required FikoYTButtonTheme sirketButtonTheme, required FikoYTButtonTheme tuzelButtonTheme, required this.selectImage, required this.deleteImage, }) : _sirketButtonTheme = sirketButtonTheme, _tuzelButtonTheme = tuzelButtonTheme; @override Widget build(BuildContext context) { return FikoYTCard( theme: FikoYTCardTheme( elevation: 3, borderRadius: BorderRadius.circular(10), borderColor: Colors.blue, backgroundColor: Colors.white, padding: const EdgeInsets.all(10), spacing: 10, ), children: [ Row( spacing: 5, crossAxisAlignment: CrossAxisAlignment.start, children: [ _ProfileImageSection(kayit: kayit, selectImage: selectImage, deleteImage: deleteImage), Expanded( child: Column( spacing: 5, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ FikoYaziKutusu( baslik: "Kullanıcı Adı", simgeSol: const Text("👩🏻‍🤝‍👨🏽", style: TextStyle(fontSize: 14)), yaziBoyutu: 12.0, radius: 5.0, degeri: kayit.value.ismi, degisti: (value) => kayit.value.ismi = value, oneriOtomatikDoldurma: const [AutofillHints.username], ), FikoYaziKutusu( baslik: "E-Posta", simgeSol: const Text("📧", style: TextStyle(fontSize: 14)), yaziBoyutu: 12.0, radius: 5.0, degeri: kayit.value.eposta, degisti: (value) => kayit.value.eposta = value, oneriOtomatikDoldurma: const [AutofillHints.email], ), FikoYaziKutusu( baslik: "Parola", simgeSol: const Text("🔐", style: TextStyle(fontSize: 14)), gizli: true, yaziBoyutu: 12.0, radius: 5.0, degeri: kayit.value.parola, degisti: (value) => kayit.value.parola = value, oneriOtomatikDoldurma: const [AutofillHints.email], ), Obx( () => Row( mainAxisAlignment: MainAxisAlignment.center, children: [ FikoYTButton( text: "👨‍👨‍👦‍👦 Şirket", tema: kayit.value.kullaniciTipi == KullaniciTipi.sirket ? _sirketButtonTheme : _tuzelButtonTheme, onPressed: () { kayit.value.kullaniciTipi = KullaniciTipi.sirket; kayit.refresh(); }, ), FikoYTButton( text: "💼 Tüzel", tema: kayit.value.kullaniciTipi == KullaniciTipi.bireysel ? _sirketButtonTheme : _tuzelButtonTheme, onPressed: () { kayit.value.kullaniciTipi = KullaniciTipi.bireysel; kayit.refresh(); }, ), ], ), ), const SizedBox(height: 5), _CreateButton(kayit: kayit), ], ), ), ], ), ], ); } } class _ProfileImageSection extends StatelessWidget { final Rx kayit; final VoidCallback selectImage; final VoidCallback deleteImage; const _ProfileImageSection({required this.kayit, required this.selectImage, required this.deleteImage}); @override Widget build(BuildContext context) { return Obx( () => Column( children: [ FikoytOvalResim( key: ValueKey(kayit.value.profilResmiUrl), resimUrl: kayit.value.profilResmiUrl ?? "🎓", tema: FikoYTOvalResimTheme(borderColor: Colors.blue, radius: 36, spacing: 7), ), const SizedBox(height: 5), _VisibilityButton( visible: kayit.value.profilResmiUrl == null, child: FikoYTButton( key: const ValueKey("Resim Seç Button"), text: "Resim Seç", tema: FikoYTButtonTheme( textColor: Colors.white, backgroundColor: Colors.blue, edgePadding: EdgeInsets.all(3), borderColor: Colors.blueAccent, elevation: 3, fontSize: 10, ), onPressed: selectImage, ), ), _VisibilityButton( visible: kayit.value.profilResmiUrl != null, child: FikoYTButton( key: const ValueKey("Resim Sil Button"), text: "Resim Sil", tema: FikoYTButtonTheme( textColor: Colors.white, backgroundColor: Colors.red, edgePadding: EdgeInsets.all(3), borderColor: Colors.redAccent, elevation: 3, fontSize: 10, ), onPressed: deleteImage, ), ), ], ), ); } } class _VisibilityButton extends StatelessWidget { final bool visible; final Widget child; const _VisibilityButton({required this.visible, required this.child}); @override Widget build(BuildContext context) { return Visibility(visible: visible, child: child); } } class _CreateButton extends StatelessWidget { final Rx kayit; const _CreateButton({required this.kayit}); @override Widget build(BuildContext context) { return Row( children: [ const Spacer(), FikoYTButton( text: "✨ Oluştur", tema: FikoYTButtonTheme( textColor: Colors.white, backgroundColor: Colors.blue, edgePadding: EdgeInsets.all(3), borderColor: Colors.blueAccent, elevation: 3, fontSize: 12, ), onPressed: () { if (kayit.value.bosMu) { toastification.show( context: FikoYTCoreService.navigatorKey.currentContext!, type: ToastificationType.error, style: ToastificationStyle.fillColored, description: const Text("Tüm Boş Alanları Doldurun."), alignment: Alignment.topRight, autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); return; } Isar? isar = FikoYTCoreService.servisler.getServis()?.isar; isar?.writeTxn(() async { await isar.kullanicis.put(kayit.value); kayit.value = Kullanici(); kayit.refresh(); context.vRouter.to("/giris"); }); }, ), ], ); } } class _BottomAlert extends StatelessWidget { const _BottomAlert(); @override Widget build(BuildContext context) { return const Padding( padding: EdgeInsets.all(8.0), child: FikoYTAlert( description: "Bu Oluşturacağınız Hesap Sisteminizin Yönetici Hesabı Olacak Tüm Yetkilere Sahip Olacak Bu Yüzden Parolayı Kesinlikle Unutmayınız.Bilgileriniz Bizimle Paylaşılmaz Tüm Bilgileriniz Cihazınızda Kayıtlı Kalır.", emoji: "🚨", ), ); } }