| 1 | import 'package:plane_pal/client/pocketbase.dart'; |
| 2 | import 'package:plane_pal/constants/main.dart'; |
| 3 | import 'package:plane_pal/db/main.dart'; |
| 4 | import 'package:plane_pal/routes/main.dart'; |
| 5 | import 'package:plane_pal/screens/home/service.dart'; |
| 6 | import 'package:flutter/material.dart'; |
| 7 | import 'package:pocketbase/pocketbase.dart'; |
| 8 | import 'package:shared_preferences/shared_preferences.dart'; |
| 9 | import 'package:sqflite/sqflite.dart'; |
| 10 | import 'package:path/path.dart'; |
| 11 | |
| 12 | void main() async { |
| 13 | WidgetsFlutterBinding.ensureInitialized(); |
| 14 | final prefs = await SharedPreferences |
| 15 | |
| 16 | final store = AsyncAuthStore( |
| 17 | save: (String data) async { |
| 18 | await prefs.setString('pb_auth', |
| 19 | }, |
| 20 | initial: prefs.getString('pb_auth') |
| 21 | ); |
| 22 | pb = PocketBase( |
| 23 | POCKETBASE_URL, |
| 24 | authStore: store, |
| 25 | ); |
| 26 | database = await openDatabase( |
| 27 | join(await getDatabasesPath() |
| 28 | version: 1, |
| 29 | onOpen: (db) async { |
| 30 | await db.execute(Airport |
| 31 | }, |
| 32 | ); |
| 33 | runApp(const MainApp |
| 34 | } |
| 35 | |
| 36 | class MainApp extends StatelessWidget |
| 37 | const MainApp({super |
| 38 | |
| 39 | @override |
| 40 | Widget build(BuildContext |
| 41 | return MaterialApp.router |
| 42 | routerConfig: AeroRouter.router, |
| 43 | debugShowCheckedModeBanner: false, |
| 44 | theme: ThemeData( |
| 45 | useMaterial3: true, |
| 46 | scaffoldBackgroundColor: Colors.white, |
| 47 | fontFamily: "Geist", |
| 48 | brightness: Brightness.light, |
| 49 | primaryColor: Colors.blueAccent, |
| 50 | navigationBarTheme: NavigationBarThemeData( |
| 51 | labelTextStyle: const WidgetStatePropertyAll( |
| 52 | TextStyle( |
| 53 | fontSize: 14, |
| 54 | ), |
| 55 | ), |
| 56 | backgroundColor: const Color( |
| 57 | indicatorColor: Colors.blueAccent.withValues |
| 58 | alpha: .4, |
| 59 | ), |
| 60 | ), |
| 61 | appBarTheme: const AppBarTheme( |
| 62 | elevation: 0, |
| 63 | scrolledUnderElevation: 0, |
| 64 | titleTextStyle: TextStyle( |
| 65 | fontFamily: "CalSans", |
| 66 | fontSize: 20, |
| 67 | color: Colors.black, |
| 68 | ), |
| 69 | toolbarHeight: 50, |
| 70 | backgroundColor: Colors.white, |
| 71 | ), |
| 72 | textTheme: const TextTheme( |
| 73 | labelMedium: TextStyle( |
| 74 | fontSize: 20, |
| 75 | ), |
| 76 | titleLarge: TextStyle( |
| 77 | fontSize: 32, |
| 78 | fontWeight: FontWeight.bold, |
| 79 | ), |
| 80 | titleSmall: TextStyle( |
| 81 | fontSize: 16, |
| 82 | color: SECONDARY_TEXT_COLOR, |
| 83 | ), |
| 84 | titleMedium: TextStyle( |
| 85 | fontSize: 20, |
| 86 | ), |
| 87 | bodyMedium: TextStyle( |
| 88 | color: Colors.black87, |
| 89 | fontSize: 14, |
| 90 | ), |
| 91 | ), |
| 92 | elevatedButtonTheme: ElevatedButtonThemeData( |
| 93 | style: ElevatedButton.styleFrom( |
| 94 | backgroundColor: Colors.blueAccent, |
| 95 | foregroundColor: Colors.black, |
| 96 | shape: RoundedRectangleBorder( |
| 97 | borderRadius: BorderRadius.circular( |
| 98 | 10, |
| 99 | ), |
| 100 | ), |
| 101 | ), |
| 102 | ), |
| 103 | outlinedButtonTheme: OutlinedButtonThemeData( |
| 104 | style: OutlinedButton.styleFrom( |
| 105 | foregroundColor: Colors.black, |
| 106 | side: const BorderSide( |
| 107 | color: Colors.blueAccent, |
| 108 | width: 2, |
| 109 | ), |
| 110 | shape: RoundedRectangleBorder( |
| 111 | borderRadius: BorderRadius.circular( |
| 112 | ), |
| 113 | padding: const EdgeInsets. |
| 114 | vertical: 12, |
| 115 | horizontal: 16, |
| 116 | ), |
| 117 | ), |
| 118 | ), |
| 119 | ), |
| 120 | ); |
| 121 | } |
| 122 | } |