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; static final FikoYTButtonTheme _sirketButtonTheme = FikoYTButtonTheme( backgroundColor: Colors.blue, textColor: Colors.white, edgePadding: EdgeInsets.only(right: 1, left: 4, top: 2, bottom: 2), borderRadius: BorderRadius.only( topLeft: Radius.circular(5), bottomLeft: Radius.circular(5), bottomRight: Radius.zero, topRight: Radius.zero, ), fontSize: 10, borderColor: Colors.lightBlueAccent, ); static final FikoYTButtonTheme _tuzelButtonTheme = FikoYTButtonTheme( backgroundColor: Colors.transparent, textColor: Colors.black, edgePadding: EdgeInsets.only(right: 4, left: 1, top: 2, bottom: 2), borderRadius: BorderRadius.only( topLeft: Radius.circular(5), bottomLeft: Radius.circular(5), bottomRight: Radius.zero, topRight: Radius.zero, ), 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) { final fikoTheme = Theme.of(context).extension(); final buttonTheme = Theme.of(context).extension(); return FikoYTSliverApp( leading: UygulamaBaslikSol(), title: const UygulamaBaslikOrta(), actions: [UygulamaBaslikSag()], backgroundColor: fikoTheme?.backgroundColor, appBarColor: fikoTheme?.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: const _HeaderWidget(), sliverAltKisimGoster: false, sliverAltKisim: null, body: [ const SizedBox(height: 10), FikoYTButton( text: "Aşağıdaki Formu Doldurarak Sisteminizin Kurulumuna Başlayabilirsiniz.", tema: FikoYTButtonTheme( textAlign: TextAlign.center, textColor: Colors.black38, fontSize: 12), ), const SizedBox(height: 10), 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)), ], ), FikoYTCard( children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ _ProfileImageSection(kayit: kayit, selectImage: _selectImage, deleteImage: _deleteImage,), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, 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), ], ), ), ], ), ], ), const SizedBox(height: 5), 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: "🚨", ), ), ], ); } } class _CreateButton extends StatelessWidget { const _CreateButton({ required this.kayit, }); final Rx 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 _ProfileImageSection extends StatelessWidget { const _ProfileImageSection({ required this.kayit, required this.selectImage, required this.deleteImage, }); final Rx kayit; final VoidCallback selectImage; final VoidCallback deleteImage; @override Widget build(BuildContext context) { return Column( children: [ Obx( () => FikoytOvalResim( key: ValueKey(kayit.value.profilResmiUrl), resimUrl: kayit.value.profilResmiUrl ?? "🎓", tema: FikoYTOvalResimTheme( borderColor: Colors.blue, radius: 36, spacing: 7), ), ), const SizedBox(height: 5), Obx( () => 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, ), ), Obx( () => 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 _HeaderWidget extends StatelessWidget { const _HeaderWidget({super.key}); @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, ), ), ], ); } }