prototype complete
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:qpay/screens/confirm/confirm_screen.dart';
|
||||
import 'package:qpay/screens/gateway/gateway_screen.dart';
|
||||
import 'package:qpay/screens/pay/pay_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/home/home_screen.dart';
|
||||
import 'screens/pay/pay_screen.dart';
|
||||
import 'screens/history_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:qpay/screens/pay/pay_controller.dart';
|
||||
|
||||
const String testEnv = "assets/.env";
|
||||
const String liveEnv = "assets/.env";
|
||||
@@ -16,20 +21,45 @@ void main() async {
|
||||
await dotenv.load(fileName: testEnv);
|
||||
runApp(
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => PayController(),
|
||||
create: (context) => TransactionController(),
|
||||
child: const MyApp(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
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: 'Peak',
|
||||
theme: AppTheme.lightTheme,
|
||||
themeMode: ThemeMode.light,
|
||||
home: SplashScreen(onSplashComplete: _onSplashComplete),
|
||||
debugShowCheckedModeBanner: false,
|
||||
);
|
||||
}
|
||||
|
||||
return MaterialApp.router(
|
||||
title: 'QPay',
|
||||
title: 'Peak',
|
||||
theme: AppTheme.lightTheme,
|
||||
themeMode: ThemeMode.light, // Force light mode regardless of OS setting
|
||||
debugShowCheckedModeBanner: false,
|
||||
routerConfig: GoRouter(
|
||||
initialLocation: '/',
|
||||
routes: [
|
||||
@@ -46,6 +76,24 @@ class MyApp extends StatelessWidget {
|
||||
path: '/make-payment',
|
||||
builder: (context, state) => const PayScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/confirm',
|
||||
builder: (context, state) => const ConfirmScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/gateway',
|
||||
builder:
|
||||
(context, state) =>
|
||||
GatewayScreen(url: state.extra as String),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/receipt',
|
||||
builder: (context, state) => const ReceiptScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/recipients',
|
||||
builder: (context, state) => const RecipientsScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/history',
|
||||
builder: (context, state) => const HistoryScreen(),
|
||||
@@ -77,15 +125,15 @@ class ScaffoldWithNavBar extends StatelessWidget {
|
||||
case 0:
|
||||
context.go('/');
|
||||
break;
|
||||
// case 1:
|
||||
// context.go('/recipients');
|
||||
// break;
|
||||
case 1:
|
||||
context.go('/make-payment');
|
||||
break;
|
||||
case 2:
|
||||
context.go('/history');
|
||||
break;
|
||||
case 3:
|
||||
context.go('/profile');
|
||||
break;
|
||||
// case 2:
|
||||
// context.go('/profile');
|
||||
// break;
|
||||
}
|
||||
},
|
||||
selectedIndex: _calculateSelectedIndex(context),
|
||||
@@ -95,21 +143,21 @@ class ScaffoldWithNavBar extends StatelessWidget {
|
||||
selectedIcon: Icon(Icons.home),
|
||||
label: 'Home',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.payment_outlined),
|
||||
selectedIcon: Icon(Icons.payment),
|
||||
label: 'Pay',
|
||||
),
|
||||
// NavigationDestination(
|
||||
// icon: Icon(Icons.contacts_outlined),
|
||||
// selectedIcon: Icon(Icons.contacts),
|
||||
// label: 'Recipients',
|
||||
// ),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.history_outlined),
|
||||
selectedIcon: Icon(Icons.history),
|
||||
label: 'History',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.person_outline),
|
||||
selectedIcon: Icon(Icons.person),
|
||||
label: 'Profile',
|
||||
),
|
||||
// NavigationDestination(
|
||||
// icon: Icon(Icons.person_outline),
|
||||
// selectedIcon: Icon(Icons.person),
|
||||
// label: 'Profile',
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -117,9 +165,9 @@ class ScaffoldWithNavBar extends StatelessWidget {
|
||||
|
||||
int _calculateSelectedIndex(BuildContext context) {
|
||||
final String location = GoRouterState.of(context).uri.path;
|
||||
if (location.startsWith('/make-payment')) return 1;
|
||||
if (location.startsWith('/history')) return 2;
|
||||
if (location.startsWith('/profile')) return 3;
|
||||
// if (location.startsWith('/recipients')) return 1;
|
||||
if (location.startsWith('/history')) return 1;
|
||||
// if (location.startsWith('/profile')) return 2;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user