import 'dart:async'; import 'package:fikoyt_ui/core/fiko_scroll_behaviour.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:fikoyt_ui/pages/bilinmeyen_rota_widget.dart'; import 'package:fikoyt_ui/pages/fikoyt_login/signup.screen.dart'; import 'package:fikoyt_ui/pages/fikoyt_ui_ornekler/ana.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; class FikoYTApp extends StatefulWidget { final FikoYTAppSettings ayarlar; FikoYTApp({ super.key, ayarlar, }) : ayarlar = ayarlar ?? FikoYTCoreService.serviceSettings.appSettings; @override State createState() => _FikoYTAppState(); } class _FikoYTAppState extends State with WidgetsBindingObserver { @override void initState() { WidgetsBinding.instance.addObserver(this); super.initState(); } @override void dispose() { WidgetsBinding.instance.removeObserver(this); super.dispose(); } @override void didChangePlatformBrightness() { setState(() { FikoYTCoreService.parlaklik.value = Theme.of(context).brightness; FikoYTCoreService.parlaklik.refresh(); }); super.didChangePlatformBrightness(); } @override Widget build(BuildContext context) { return Obx( () { FikoYTCoreService.parlaklik.value; return VRouterScope( vRouterMode: VRouterMode.history, child: ToastificationWrapper( child: GetMaterialApp.router( title: widget.ayarlar.title, // customTransition: StaggeredTransition(), defaultTransition: Transition.fade, routerDelegate: VRouterDelegate( // onSystemPop: widget.ayarlar.onSystemPushed, // onPop: widget.ayarlar.onPushed, transitionDuration: const Duration(seconds: 1), reverseTransitionDuration: const Duration(seconds: 1), buildTransition: widget.ayarlar.rotaGecisHareketi, afterEnter: widget.ayarlar.rotaGecitenSonra, navigatorKey: FikoYTCoreService.navigatorKey, routes: [ ...widget.ayarlar.routes, VWidget( path: '/fikoyt_ui_ornekler', widget: const FikoYTUiOrnekler(), ), VWidget( path: '/fikoyt-login', widget: const FikoYTLoginScreen(), ), VWidget( path: '/fikoyt-signup', widget: const FikoYTSignUpScreen(), ), VWidget( path: r':_(.*)', widget: const BilinmeyenRota(), ), ], initialUrl: widget.ayarlar.firstRouteUrl, logs: [], ), routeInformationParser: VRouteInformationParser(), // backButtonDispatcher: VBackButtonDispatcher(), // unknownRoute: GetPage( // name: "/Bilinmeyen_Url", // page: () => Text("Hatalı Sayfa"), // ), themeMode: FikoYTCoreService.temaModu.temaModu, darkTheme: FikoytDarkTheme(), theme: FikoYTLightTheme(), // translations: Translate(), localizationsDelegates: const [ GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], supportedLocales: widget.ayarlar.languages, locale: widget.ayarlar.language, // supportedLocales: const [ Locale('tr', 'TR')], fallbackLocale: widget.ayarlar.defaultLanguage, scrollBehavior: FikoScrollBehavior(), debugShowCheckedModeBanner: false, debugShowMaterialGrid: false, showSemanticsDebugger: false, smartManagement: SmartManagement.full, opaqueRoute: true, backButtonDispatcher: RootBackButtonDispatcher(),popGesture: false, ), ), ); }, ); } } class FikoYTAppSettings { final String uygulamaIsmi; final List routes; final Iterable languages; final Locale language; final Locale defaultLanguage; final String firstRouteUrl; final String title; final Widget unknownRouteWidget; List? themeLightEx; List? themeDarkEx; final List? translationFiles; final List>? routeTransitionEffects; final Future Function(VRedirector redirector) onSystemPushed; final Future Function(VRedirector redirector) onPushed; final Widget Function(Animation animation, Animation secondaryAnimation, Widget child) rotaGecisHareketi; final void Function(BuildContext context, String? from, String to) rotaGecitenSonra; FikoYTAppSettings({ this.uygulamaIsmi = "FikoYT", this.routes = const [], this.languages = const [Locale('tr')], this.language = const Locale('tr'), this.defaultLanguage = const Locale('tr'), this.firstRouteUrl = "/", this.title = "FikoYT", this.unknownRouteWidget = const BilinmeyenRota(), this.themeLightEx, this.themeDarkEx, this.translationFiles = const [], List>? routeTransitionEffects, Future Function(VRedirector redirector)? onSystemBackButton, Future Function(VRedirector redirector)? onBackButton, Widget Function(Animation animation, Animation secondaryAnimation, Widget child)? routeTransition, void Function(BuildContext context, String? from, String to)? afterRouteTransition, }) : onSystemPushed = onSystemBackButton ?? defaultSystemPop, onPushed = onBackButton ?? defaultSystemPop, rotaGecisHareketi = routeTransition ?? defaultRouteTransition, rotaGecitenSonra = afterRouteTransition ?? defaultAfterRouteTransition, routeTransitionEffects = routeTransitionEffects ?? [ FadeEffect(duration: 500.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), ]; static Future Function(VRedirector redirector) defaultSystemPop = (redirector) async { // vRedirector.stopRedirection(); if (redirector.historyCanBack()) { if (kDebugMode) { // print("History Can Back ${redirector.fromUrl}, ${redirector.toUrl}"); } return redirector.historyBack(); } else { if (kDebugMode) { // print("History Can Not Back ${redirector.fromUrl}, ${redirector.toUrl}"); } return redirector.stopRedirection(); } }; static Widget Function(Animation animation, Animation secondaryAnimation, Widget child) defaultRouteTransition = (Animation animation, Animation secondaryAnimation, Widget child) { return // StaggeredChildAnimator( // animation: animation, // effect: AnimationEffect.slide, // child: child.animate( effects: [ FadeEffect(duration: 750.ms), MoveEffect(begin: Offset(0, 50),duration: 300.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), ], // ), ); }; static void Function(BuildContext context, String? from, String to) defaultAfterRouteTransition = (BuildContext context, String? from, String to) {}; }