import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:google_fonts/google_fonts.dart'; import 'app_cubit.dart'; import 'router.dart'; import '../core/i18n/app_strings.dart'; import '../core/theme/app_colors.dart'; class WalkGuideApp extends StatelessWidget { const WalkGuideApp({super.key}); @override Widget build(BuildContext context) { const seed = AppColors.primary; return BlocProvider( create: (_) => AppCubit(), child: BlocBuilder( builder: (context, state) => MaterialApp.router( title: 'WalkGuide', debugShowCheckedModeBanner: false, routerConfig: appRouter, builder: (context, child) { final media = MediaQuery.of(context); return MediaQuery( data: media.copyWith( textScaler: media.textScaler.clamp( minScaleFactor: 0.9, maxScaleFactor: 1.15, ), ), child: child ?? const SizedBox.shrink(), ); }, locale: state.localeCode == 'en-US' ? const Locale('en', 'US') : const Locale('id', 'ID'), supportedLocales: AppStrings.supportedLocales, localizationsDelegates: const [ AppStringsDelegate(), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], theme: ThemeData( useMaterial3: true, visualDensity: VisualDensity.adaptivePlatformDensity, colorScheme: ColorScheme.fromSeed( seedColor: seed, brightness: Brightness.light, primary: seed, secondary: AppColors.accent, error: AppColors.danger, ), scaffoldBackgroundColor: AppColors.surface, textTheme: GoogleFonts.interTextTheme().apply( bodyColor: AppColors.text, displayColor: AppColors.text, ), pageTransitionsTheme: const PageTransitionsTheme( builders: { TargetPlatform.android: ZoomPageTransitionsBuilder(), TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), TargetPlatform.windows: FadeUpwardsPageTransitionsBuilder(), }, ), appBarTheme: const AppBarTheme( centerTitle: false, backgroundColor: AppColors.surface, foregroundColor: AppColors.text, elevation: 0, surfaceTintColor: Colors.transparent, ), cardTheme: CardThemeData( elevation: 0, color: AppColors.surfaceRaised, surfaceTintColor: Colors.transparent, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), side: const BorderSide(color: AppColors.border), ), ), dividerTheme: const DividerThemeData( color: AppColors.border, thickness: 1, space: 1, ), iconButtonTheme: IconButtonThemeData( style: IconButton.styleFrom( foregroundColor: AppColors.text, backgroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), side: const BorderSide(color: AppColors.border), ), ), ), navigationBarTheme: NavigationBarThemeData( elevation: 0, height: 76, backgroundColor: Colors.white, indicatorColor: const Color(0xFFDDEAFE), surfaceTintColor: Colors.transparent, labelTextStyle: WidgetStateProperty.resolveWith( (states) => TextStyle( fontSize: 12, fontWeight: states.contains(WidgetState.selected) ? FontWeight.w800 : FontWeight.w500, ), ), ), filledButtonTheme: FilledButtonThemeData( style: FilledButton.styleFrom( backgroundColor: seed, foregroundColor: Colors.white, minimumSize: const Size(0, 50), textStyle: const TextStyle(fontWeight: FontWeight.w800), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), ), ), outlinedButtonTheme: OutlinedButtonThemeData( style: OutlinedButton.styleFrom( minimumSize: const Size(0, 50), foregroundColor: seed, textStyle: const TextStyle(fontWeight: FontWeight.w800), side: const BorderSide(color: AppColors.border), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), ), ), snackBarTheme: SnackBarThemeData( behavior: SnackBarBehavior.floating, backgroundColor: AppColors.text, contentTextStyle: GoogleFonts.inter( color: Colors.white, fontWeight: FontWeight.w600, ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), ), ), inputDecorationTheme: InputDecorationTheme( filled: true, fillColor: Colors.white, contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: const BorderSide(color: AppColors.border), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: const BorderSide(color: AppColors.border), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: const BorderSide(color: seed, width: 1.5), ), ), ), ), ), ); } }