2026-04-01 17:58:59 +00:00
|
|
|
import 'package:e_receipt_mobile/core/theme/app_colors.dart';
|
|
|
|
|
import 'package:e_receipt_mobile/domain/entities/terminal.dart';
|
|
|
|
|
import 'package:e_receipt_mobile/presentation/auth/session_controller.dart';
|
|
|
|
|
import 'package:e_receipt_mobile/presentation/home/home_screen.dart';
|
|
|
|
|
import 'package:e_receipt_mobile/presentation/login/login_page.dart';
|
|
|
|
|
import 'package:e_receipt_mobile/presentation/settings/theme_mode_provider.dart';
|
|
|
|
|
import 'package:e_receipt_mobile/presentation/terminal/terminal_next_screen.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
|
|
|
|
SystemChrome.setEnabledSystemUIMode(
|
|
|
|
|
SystemUiMode.manual,
|
|
|
|
|
overlays: SystemUiOverlay.values,
|
|
|
|
|
);
|
|
|
|
|
SystemChrome.setSystemUIOverlayStyle(
|
|
|
|
|
const SystemUiOverlayStyle(
|
|
|
|
|
statusBarColor: AppColors.primary,
|
|
|
|
|
statusBarIconBrightness: Brightness.light,
|
|
|
|
|
statusBarBrightness: Brightness.dark,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
runApp(const ProviderScope(child: EReceiptApp()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class EReceiptApp extends ConsumerWidget {
|
|
|
|
|
const EReceiptApp({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
|
final themeMode = ref.watch(appThemeModeProvider);
|
|
|
|
|
|
|
|
|
|
return MaterialApp(
|
|
|
|
|
title: 'E-Receipt',
|
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
|
themeMode: themeMode,
|
|
|
|
|
theme: ThemeData(
|
|
|
|
|
colorScheme: ColorScheme.fromSeed(
|
|
|
|
|
seedColor: AppColors.primary,
|
|
|
|
|
),
|
|
|
|
|
primaryColor: AppColors.primary,
|
|
|
|
|
appBarTheme: const AppBarTheme(
|
|
|
|
|
backgroundColor: AppColors.primary,
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
systemOverlayStyle: SystemUiOverlayStyle(
|
|
|
|
|
statusBarColor: AppColors.primary,
|
|
|
|
|
statusBarIconBrightness: Brightness.light,
|
|
|
|
|
statusBarBrightness: Brightness.dark,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
useMaterial3: true,
|
|
|
|
|
),
|
|
|
|
|
darkTheme: ThemeData(
|
|
|
|
|
colorScheme: ColorScheme.fromSeed(
|
|
|
|
|
seedColor: AppColors.primary,
|
|
|
|
|
brightness: Brightness.dark,
|
|
|
|
|
),
|
|
|
|
|
appBarTheme: const AppBarTheme(
|
|
|
|
|
backgroundColor: AppColors.primary,
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
systemOverlayStyle: SystemUiOverlayStyle(
|
|
|
|
|
statusBarColor: AppColors.primary,
|
|
|
|
|
statusBarIconBrightness: Brightness.light,
|
|
|
|
|
statusBarBrightness: Brightness.dark,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
useMaterial3: true,
|
|
|
|
|
),
|
|
|
|
|
home: const AppRoot(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AppRoot extends ConsumerWidget {
|
|
|
|
|
const AppRoot({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
|
final user = ref.watch(sessionControllerProvider);
|
|
|
|
|
if (user == null) {
|
|
|
|
|
return const LoginPage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final role = user.role.trim().toLowerCase();
|
|
|
|
|
if (role == 'cashier') {
|
|
|
|
|
final serial = user.username.trim().toUpperCase();
|
|
|
|
|
final terminal = Terminal(serial: serial, name: serial);
|
|
|
|
|
return TerminalNextScreen(merchantName: serial, terminal: terminal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return HomeScreen(user: user);
|
|
|
|
|
}
|
|
|
|
|
}
|