mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
111 lines
4.0 KiB
Dart
111 lines
4.0 KiB
Dart
import 'package:flutter/gestures.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
|
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
|
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:syncrow_web/services/locator.dart';
|
|
import 'package:syncrow_web/utils/app_routes.dart';
|
|
import 'package:syncrow_web/utils/color_manager.dart';
|
|
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
initialSetup();
|
|
String checkToken = await AuthBloc.getTokenAndValidate();
|
|
GoRouter router = GoRouter(
|
|
initialLocation:
|
|
checkToken == 'Success' ? RoutesConst.home : RoutesConst.auth,
|
|
routes: AppRoutes.getRoutes(),
|
|
);
|
|
runApp(MyApp(
|
|
router: router,
|
|
));
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
final GoRouter router;
|
|
const MyApp({
|
|
super.key,
|
|
required this.router,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MultiBlocProvider(
|
|
providers: [
|
|
BlocProvider(create: (context) => HomeBloc()),
|
|
BlocProvider<VisitorPasswordBloc>(
|
|
create: (context) => VisitorPasswordBloc(),
|
|
)
|
|
],
|
|
child: MaterialApp.router(
|
|
debugShowCheckedModeBanner: false, // Hide debug banner
|
|
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
|
dragDevices: {
|
|
PointerDeviceKind.mouse,
|
|
PointerDeviceKind.touch,
|
|
PointerDeviceKind.stylus,
|
|
PointerDeviceKind.unknown,
|
|
},
|
|
),
|
|
|
|
theme: ThemeData(
|
|
fontFamily: 'Aftika',
|
|
textTheme: const TextTheme(
|
|
bodySmall: TextStyle(
|
|
fontSize: 13,
|
|
color: ColorsManager.whiteColors,
|
|
fontWeight: FontWeight.bold),
|
|
bodyMedium: TextStyle(color: Colors.black87, fontSize: 14),
|
|
bodyLarge: TextStyle(fontSize: 16, color: Colors.white),
|
|
headlineSmall: TextStyle(color: Colors.black87, fontSize: 18),
|
|
headlineMedium: TextStyle(color: Colors.black87, fontSize: 20),
|
|
headlineLarge: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
colorScheme: ColorScheme.fromSeed(
|
|
seedColor: ColorsManager.blueColor,
|
|
primary: ColorsManager.blueColor,
|
|
onSurface: Colors.grey.shade400,
|
|
),
|
|
switchTheme: SwitchThemeData(
|
|
thumbColor: WidgetStateProperty.resolveWith((states) {
|
|
if (states.contains(WidgetState.selected)) {
|
|
return ColorsManager.blueColor;
|
|
}
|
|
return ColorsManager.whiteColors;
|
|
}),
|
|
trackColor: WidgetStateProperty.resolveWith((states) {
|
|
if (states.contains(WidgetState.selected)) {
|
|
return ColorsManager.blueColor.withOpacity(0.5);
|
|
}
|
|
return ColorsManager.whiteColors;
|
|
}),
|
|
),
|
|
checkboxTheme: CheckboxThemeData(
|
|
fillColor: WidgetStateProperty.resolveWith((states) {
|
|
if (states.contains(WidgetState.selected)) {
|
|
return ColorsManager.blueColor;
|
|
}
|
|
return Colors.grey.shade200;
|
|
}),
|
|
checkColor: WidgetStateProperty.all(Colors.white),
|
|
side: const BorderSide(color: ColorsManager.whiteColors),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
),
|
|
),
|
|
|
|
routeInformationProvider: router.routeInformationProvider,
|
|
routerDelegate: router.routerDelegate,
|
|
routeInformationParser: router.routeInformationParser,
|
|
));
|
|
}
|
|
}
|