1
0
mirror of https://github.com/go-vikunja/app synced 2024-11-08 05:50:00 +00:00
app-mirror-github/lib/pages/home.dart

60 lines
1.7 KiB
Dart
Raw Permalink Normal View History

2018-09-15 15:01:45 +00:00
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:vikunja_app/pages/landing_page.dart';
2018-09-22 20:56:16 +00:00
import 'package:vikunja_app/global.dart';
import 'package:vikunja_app/pages/project/overview.dart';
2022-04-12 22:32:21 +00:00
import 'package:vikunja_app/pages/settings.dart';
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
}
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
List<Widget> widgets = [
ChangeNotifierProvider<ProjectProvider>(
create: (_) => new ProjectProvider(),
child: LandingPage(),
),
ProjectOverviewPage(),
SettingsPage()
];
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;
if (_selectedDrawerIndex != _previousDrawerIndex || drawerItem == null)
drawerItem = _getDrawerItemWidget(_selectedDrawerIndex);
2019-03-18 16:56:15 +00:00
2018-09-15 15:01:45 +00:00
return new Scaffold(
bottomNavigationBar: NavigationBar(
destinations: navbarItems,
selectedIndex: _selectedDrawerIndex,
onDestinationSelected: (index) {
2023-05-13 23:28:30 +00:00
setState(() {
_selectedDrawerIndex = index;
});
},
),
body: drawerItem,
2018-09-15 15:01:45 +00:00
);
}
2024-06-04 18:42:57 +00:00
_getDrawerItemWidget(int pos) {
_previousDrawerIndex = pos;
return widgets[pos];
}
2018-09-15 15:10:34 +00:00
}