2018-09-15 15:01:45 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-08-27 21:43:11 +00:00
|
|
|
import 'package:provider/provider.dart';
|
2019-03-18 15:30:54 +00:00
|
|
|
|
2022-04-12 23:02:16 +00:00
|
|
|
import 'package:vikunja_app/pages/landing_page.dart';
|
2018-09-22 20:56:16 +00:00
|
|
|
import 'package:vikunja_app/global.dart';
|
2023-07-22 20:55:25 +00:00
|
|
|
import 'package:vikunja_app/pages/project/overview.dart';
|
2022-04-12 22:32:21 +00:00
|
|
|
import 'package:vikunja_app/pages/settings.dart';
|
2023-07-22 23:50:55 +00:00
|
|
|
|
|
|
|
import '../stores/project_store.dart';
|
2018-09-15 15:01:45 +00:00
|
|
|
|
|
|
|
class HomePage extends StatefulWidget {
|
|
|
|
@override
|
2021-03-15 07:31:38 +00:00
|
|
|
State<StatefulWidget> createState() => HomePageState();
|
2018-09-15 15:01:45 +00:00
|
|
|
}
|
|
|
|
|
2023-05-15 22:26:01 +00:00
|
|
|
class HomePageState extends State<HomePage> {
|
2023-05-13 23:28:30 +00:00
|
|
|
int _selectedDrawerIndex = 0, _previousDrawerIndex = 0;
|
2022-08-27 21:04:43 +00:00
|
|
|
Widget? drawerItem;
|
2018-09-15 15:01:45 +00:00
|
|
|
|
2023-05-15 22:26:01 +00:00
|
|
|
List<Widget> widgets = [
|
2023-07-22 23:50:55 +00:00
|
|
|
ChangeNotifierProvider<ProjectProvider>(
|
|
|
|
create: (_) => new ProjectProvider(),
|
2023-05-15 22:26:01 +00:00
|
|
|
child: LandingPage(),
|
|
|
|
),
|
2023-07-22 20:55:25 +00:00
|
|
|
ProjectOverviewPage(),
|
2023-05-15 22:26:01 +00:00
|
|
|
SettingsPage()
|
|
|
|
];
|
|
|
|
|
2023-07-23 15:25:58 +00:00
|
|
|
List<NavigationDestination> navbarItems = [
|
|
|
|
NavigationDestination(icon: Icon(Icons.home), label: "Home"),
|
|
|
|
NavigationDestination(icon: Icon(Icons.list), label: "Projects"),
|
|
|
|
NavigationDestination(icon: Icon(Icons.settings), label: "Settings"),
|
2023-05-13 23:28:30 +00:00
|
|
|
];
|
|
|
|
|
2019-03-18 16:56:15 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-09-03 15:43:16 +00:00
|
|
|
final currentUser = VikunjaGlobal.of(context).currentUser;
|
2022-08-27 21:43:11 +00:00
|
|
|
if (_selectedDrawerIndex != _previousDrawerIndex || drawerItem == null)
|
2022-04-25 21:48:07 +00:00
|
|
|
drawerItem = _getDrawerItemWidget(_selectedDrawerIndex);
|
2019-03-18 16:56:15 +00:00
|
|
|
|
2018-09-15 15:01:45 +00:00
|
|
|
return new Scaffold(
|
2023-07-23 15:25:58 +00:00
|
|
|
bottomNavigationBar: NavigationBar(
|
|
|
|
destinations: navbarItems,
|
|
|
|
selectedIndex: _selectedDrawerIndex,
|
|
|
|
onDestinationSelected: (index) {
|
2023-05-13 23:28:30 +00:00
|
|
|
setState(() {
|
|
|
|
_selectedDrawerIndex = index;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
2022-04-25 21:48:07 +00:00
|
|
|
body: drawerItem,
|
2018-09-15 15:01:45 +00:00
|
|
|
);
|
|
|
|
}
|
2019-03-18 15:30:54 +00:00
|
|
|
|
2024-06-04 18:42:57 +00:00
|
|
|
_getDrawerItemWidget(int pos) {
|
2022-04-25 21:48:07 +00:00
|
|
|
_previousDrawerIndex = pos;
|
2023-05-15 22:26:01 +00:00
|
|
|
return widgets[pos];
|
2019-03-18 15:30:54 +00:00
|
|
|
}
|
2018-09-15 15:10:34 +00:00
|
|
|
}
|