199 lines
6.6 KiB
Dart
199 lines
6.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:qpay/navbar.dart';
|
|
import 'package:qpay/screens/confirm/confirm_screen.dart';
|
|
import 'package:qpay/screens/gateway/gateway_redirect.dart';
|
|
import 'package:qpay/screens/gateway/gateway_screen.dart';
|
|
import 'package:qpay/screens/integration/integration_screen.dart';
|
|
import 'package:qpay/screens/onboarding/complete_screen.dart';
|
|
import 'package:qpay/screens/onboarding/landing/landing_screen.dart';
|
|
import 'package:qpay/screens/onboarding/login/login_screen.dart';
|
|
import 'package:qpay/screens/onboarding/onboarding_controller.dart';
|
|
import 'package:qpay/screens/onboarding/password/password_screen.dart';
|
|
import 'package:qpay/screens/onboarding/phone/phone_screen.dart';
|
|
import 'package:qpay/screens/onboarding/register/register_screen.dart';
|
|
import 'package:qpay/screens/onboarding/verify/verify_screen.dart';
|
|
import 'package:qpay/screens/pay/pay_screen.dart';
|
|
import 'package:qpay/screens/poll/poll_screen.dart';
|
|
import 'package:qpay/screens/receipt/receipt_screen.dart';
|
|
import 'package:qpay/screens/recipient/recipients_screen.dart';
|
|
import 'package:qpay/screens/transaction_controller.dart';
|
|
import 'screens/gateway/gateway_web_screen.dart';
|
|
import 'screens/home/home_screen.dart';
|
|
import 'screens/history/history_screen.dart';
|
|
import 'screens/profile_screen.dart';
|
|
import 'screens/splash_screen.dart';
|
|
import 'theme/app_theme.dart';
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'firebase_options.dart';
|
|
|
|
const String testEnv = 'assets/.env.test';
|
|
const String liveEnv = 'assets/.env.live';
|
|
const String appEnv = String.fromEnvironment('APP_ENV', defaultValue: 'test');
|
|
|
|
String resolveEnvFile(String env) {
|
|
switch (env.toLowerCase()) {
|
|
case 'live':
|
|
return liveEnv;
|
|
case 'test':
|
|
default:
|
|
return testEnv;
|
|
}
|
|
}
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
|
|
|
await dotenv.load(fileName: resolveEnvFile(appEnv));
|
|
runApp(
|
|
MultiProvider(
|
|
providers: [
|
|
ChangeNotifierProvider<TransactionController>(
|
|
create: (_) => TransactionController(),
|
|
),
|
|
ChangeNotifierProvider<OnboardingController>(
|
|
create: (_) => OnboardingController(),
|
|
),
|
|
],
|
|
child: const MyApp(),
|
|
),
|
|
);
|
|
}
|
|
|
|
class MyApp extends StatefulWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
State<MyApp> createState() => _MyAppState();
|
|
}
|
|
|
|
class _MyAppState extends State<MyApp> {
|
|
bool _showSplash = false;
|
|
|
|
void _onSplashComplete() {
|
|
setState(() {
|
|
_showSplash = false;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (_showSplash) {
|
|
return MaterialApp(
|
|
title: 'Velocity',
|
|
theme: AppTheme.lightTheme,
|
|
themeMode: ThemeMode.light,
|
|
home: SplashScreen(onSplashComplete: _onSplashComplete),
|
|
debugShowCheckedModeBanner: false,
|
|
);
|
|
}
|
|
|
|
return MaterialApp.router(
|
|
title: 'Velocity',
|
|
theme: AppTheme.lightTheme,
|
|
themeMode: ThemeMode.light, // Force light mode regardless of OS setting
|
|
debugShowCheckedModeBanner: false,
|
|
routerConfig: GoRouter(
|
|
initialLocation: '/',
|
|
routes: [
|
|
ShellRoute(
|
|
builder: (context, state, child) {
|
|
// If the current location is an onboarding route, don't show the navbar
|
|
final location = GoRouterState.of(context).uri.toString();
|
|
if (location.startsWith('/onboarding/')) {
|
|
return child;
|
|
}
|
|
return ScaffoldWithNavBar(child: child);
|
|
},
|
|
routes: [
|
|
GoRoute(
|
|
path: '/',
|
|
builder: (context, state) => const HomeScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/home',
|
|
builder: (context, state) => const HomeScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/make-payment',
|
|
builder: (context, state) => const PayScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/confirm',
|
|
builder: (context, state) => const ConfirmScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/gateway',
|
|
builder: (context, state) => const GatewayScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/gateway-web',
|
|
builder: (context, state) => const GatewayWebScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/gateway-redirect',
|
|
builder: (context, state) => const GatewayRedirectScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/poll',
|
|
builder: (context, state) => const PollScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/receipt',
|
|
builder: (context, state) => const ReceiptScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/integration',
|
|
builder: (context, state) => const IntegrationScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/recipients',
|
|
builder: (context, state) => const RecipientsScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/history',
|
|
builder: (context, state) => const HistoryScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/profile',
|
|
builder: (context, state) => const ProfileScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/onboarding/landing',
|
|
builder: (context, state) => const LandingScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/onboarding/register',
|
|
builder: (context, state) => const RegisterScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/onboarding/phone',
|
|
builder: (context, state) => const PhoneScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/onboarding/verify',
|
|
builder: (context, state) => const VerifyScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/onboarding/password',
|
|
builder: (context, state) => const PasswordScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/onboarding/login',
|
|
builder: (context, state) => const LoginScreen(),
|
|
),
|
|
GoRoute(
|
|
path: '/onboarding/complete',
|
|
builder: (context, state) => const CompleteScreen(),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|