Robo-advisory-dart/lib/screens/dashboard/dashboard.dart
2022-09-11 15:39:48 +01:00

52 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:robo_advisory/providers/user_provider.dart';
import 'package:robo_advisory/screens/dashboard/local_widgets/bottom_navigation.dart';
import 'package:robo_advisory/screens/home/home.dart';
import 'package:robo_advisory/screens/fund_transfer/fund_transfer.dart';
import 'package:robo_advisory/screens/settlement/settlement.dart';
import 'package:robo_advisory/screens/history/history.dart';
import 'package:robo_advisory/widgets/drawer.dart';
import 'package:provider/provider.dart';
class DashboardScreen extends StatefulWidget {
@override
_DashboardScreenState createState() => _DashboardScreenState();
}
class _DashboardScreenState extends State<DashboardScreen> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
void _openEndDrawer() {
_scaffoldKey.currentState?.openEndDrawer();
}
@override
Widget build(BuildContext context) {
int _selectedIndex =
Provider.of<UserProvider>(context, listen: true).selectedTabIndex;
void _onItemTapped(int index) {
Provider.of<UserProvider>(context, listen: false)
.setSelectedTabIndex(index);
}
var currentTab = [
HomeScreen(
toggleDrawer: _openEndDrawer,
),
FundTransferScreen(),
SettlementScreen(),
HistoryScreen(),
];
return Scaffold(
key: _scaffoldKey,
backgroundColor: Colors.white,
body: currentTab[_selectedIndex],
endDrawer: AppDrawer(),
bottomNavigationBar: BottomNavigation(
selectedIndex: _selectedIndex,
onItemTapped: _onItemTapped,
));
}
}