mirror of
https://github.com/go-vikunja/app
synced 2024-06-02 18:49:47 +00:00
removed drawer, moved drawer info to settings
This commit is contained in:
parent
c2d976ac89
commit
7cbc0361bb
|
@ -21,14 +21,10 @@ class HomePage extends StatefulWidget {
|
|||
State<StatefulWidget> createState() => HomePageState();
|
||||
}
|
||||
|
||||
class HomePageState extends State<HomePage> {
|
||||
class HomePageState extends State<HomePage> {
|
||||
int _selectedDrawerIndex = 0, _previousDrawerIndex = 0;
|
||||
bool _loading = true;
|
||||
bool _showUserDetails = false;
|
||||
Widget? drawerItem;
|
||||
|
||||
|
||||
|
||||
Widget _userDetailsWidget(BuildContext context) {
|
||||
return ListView(padding: EdgeInsets.zero, children: <Widget>[
|
||||
ListTile(
|
||||
|
@ -38,22 +34,18 @@ class HomePageState extends State<HomePage> {
|
|||
VikunjaGlobal.of(context).logoutUser(context);
|
||||
},
|
||||
),
|
||||
/*ListTile(
|
||||
title: Text('Settings'),
|
||||
leading: Icon(Icons.settings),
|
||||
onTap: () {
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => SettingsPage()))
|
||||
.whenComplete(() => setState(() {
|
||||
//returning from settings, this needs to be force-refreshed
|
||||
drawerItem = _getDrawerItemWidget(_selectedDrawerIndex,
|
||||
forceReload: true);
|
||||
}));
|
||||
},
|
||||
)*/
|
||||
]);
|
||||
}
|
||||
|
||||
List<Widget> widgets = [
|
||||
ChangeNotifierProvider<ListProvider>(
|
||||
create: (_) => new ListProvider(),
|
||||
child: LandingPage(),
|
||||
),
|
||||
NamespaceOverviewPage(),
|
||||
SettingsPage()
|
||||
];
|
||||
|
||||
List<BottomNavigationBarItem> navbarItems = [
|
||||
BottomNavigationBarItem(icon: Icon(Icons.home), label: "Home"),
|
||||
BottomNavigationBarItem(icon: Icon(Icons.list), label: "Namespaces"),
|
||||
|
@ -77,96 +69,14 @@ class HomePageState extends State<HomePage> {
|
|||
},
|
||||
),
|
||||
appBar: AppBar(
|
||||
title: new Text(navbarItems[_selectedDrawerIndex].label ?? "Vikunja"),
|
||||
/*actions: _currentNamespace == null
|
||||
? null
|
||||
: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.edit),
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => NamespaceEditPage(
|
||||
namespace: _currentNamespace!,
|
||||
))).whenComplete(() => _loadNamespaces()))
|
||||
],*/
|
||||
title: new Text("Vikunja"),
|
||||
),
|
||||
drawer: Drawer(
|
||||
child: Column(children: <Widget>[
|
||||
UserAccountsDrawerHeader(
|
||||
accountName: currentUser != null ? Text(currentUser.username) : null,
|
||||
accountEmail: currentUser != null ? Text(currentUser.name) : null,
|
||||
currentAccountPicture: currentUser == null
|
||||
? null
|
||||
: CircleAvatar(
|
||||
backgroundImage: NetworkImage(currentUser.avatarUrl(context)),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage("assets/graphics/hypnotize.png"),
|
||||
repeat: ImageRepeat.repeat,
|
||||
colorFilter: ColorFilter.mode(
|
||||
Theme.of(context).primaryColor, BlendMode.multiply)),
|
||||
),
|
||||
),
|
||||
Builder(
|
||||
builder: (BuildContext context) => Expanded(
|
||||
child: _userDetailsWidget(context))),
|
||||
/*Align(
|
||||
alignment: FractionalOffset.bottomLeft,
|
||||
child: Builder(
|
||||
builder: (context) => ListTile(
|
||||
leading: Icon(Icons.house),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
setState(() => _selectedDrawerIndex = -1);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: FractionalOffset.bottomCenter,
|
||||
child: Builder(
|
||||
builder: (context) => ListTile(
|
||||
leading: const Icon(Icons.add),
|
||||
title: const Text('Add namespace...'),
|
||||
onTap: () => _addNamespaceDialog(context),
|
||||
),
|
||||
),
|
||||
),*/
|
||||
])),
|
||||
body: drawerItem,
|
||||
);
|
||||
}
|
||||
|
||||
_getDrawerItemWidget(int pos, {bool forceReload = false}) {
|
||||
_previousDrawerIndex = pos;
|
||||
|
||||
switch (pos) {
|
||||
case 0:
|
||||
return ChangeNotifierProvider<ListProvider>(
|
||||
create: (_) => new ListProvider(),
|
||||
child: forceReload ? LandingPage(key: UniqueKey()) : LandingPage(),
|
||||
);
|
||||
case 1:
|
||||
return NamespaceOverviewPage();
|
||||
case 2:
|
||||
return SettingsPage();
|
||||
}
|
||||
return null;
|
||||
if (pos == -1) {
|
||||
//return forceReload
|
||||
// ? new LandingPage(key: UniqueKey())
|
||||
// : new LandingPage();
|
||||
|
||||
return ChangeNotifierProvider<ListProvider>(
|
||||
create: (_) => new ListProvider(),
|
||||
child: forceReload ? LandingPage(key: UniqueKey()) : LandingPage(),
|
||||
);
|
||||
}
|
||||
return widgets[pos];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,8 +11,21 @@ import '../components/TaskTile.dart';
|
|||
import '../components/pagestatus.dart';
|
||||
import '../models/task.dart';
|
||||
|
||||
class LandingPage extends StatefulWidget {
|
||||
const LandingPage({Key? key}) : super(key: key);
|
||||
class HomeScreenWidget extends StatefulWidget {
|
||||
HomeScreenWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
// TODO: implement createState
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class LandingPage extends HomeScreenWidget {
|
||||
LandingPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => LandingPageState();
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:permission_handler/permission_handler.dart';
|
|||
import 'package:vikunja_app/global.dart';
|
||||
import 'package:vikunja_app/models/list.dart';
|
||||
|
||||
|
||||
class SettingsPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => SettingsPageState();
|
||||
|
@ -53,10 +54,28 @@ class SettingsPageState extends State<SettingsPage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final currentUser = VikunjaGlobal.of(context).currentUser;
|
||||
|
||||
if (!initialized) init();
|
||||
return new Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
UserAccountsDrawerHeader(
|
||||
accountName: currentUser != null ? Text(currentUser.username) : null,
|
||||
accountEmail: currentUser != null ? Text(currentUser.name) : null,
|
||||
currentAccountPicture: currentUser == null
|
||||
? null
|
||||
: CircleAvatar(
|
||||
backgroundImage: NetworkImage(currentUser.avatarUrl(context)),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage("assets/graphics/hypnotize.png"),
|
||||
repeat: ImageRepeat.repeat,
|
||||
colorFilter: ColorFilter.mode(
|
||||
Theme.of(context).primaryColor, BlendMode.multiply)),
|
||||
),
|
||||
),
|
||||
taskListList != null
|
||||
? ListTile(
|
||||
title: Text("Default List"),
|
||||
|
@ -83,6 +102,7 @@ class SettingsPageState extends State<SettingsPage> {
|
|||
: ListTile(
|
||||
title: Text("..."),
|
||||
),
|
||||
Divider(),
|
||||
ignoreCertificates != null
|
||||
? CheckboxListTile(
|
||||
title: Text("Ignore Certificates"),
|
||||
|
@ -92,6 +112,7 @@ class SettingsPageState extends State<SettingsPage> {
|
|||
VikunjaGlobal.of(context).client.reload_ignore_certs(value);
|
||||
})
|
||||
: ListTile(title: Text("...")),
|
||||
Divider(),
|
||||
Padding(padding: EdgeInsets.only(left: 15, right: 15),
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
|
@ -108,8 +129,8 @@ class SettingsPageState extends State<SettingsPage> {
|
|||
.setWorkmanagerDuration(Duration(
|
||||
minutes: int.parse(durationTextController.text))).then((value) => VikunjaGlobal.of(context).updateWorkmanagerDuration()),
|
||||
child: Text("Save")),
|
||||
]))
|
||||
,
|
||||
])),
|
||||
Divider(),
|
||||
getVersionNotifications != null
|
||||
? CheckboxListTile(
|
||||
title: Text("Get Version Notifications"),
|
||||
|
@ -141,7 +162,11 @@ class SettingsPageState extends State<SettingsPage> {
|
|||
Text("Current version: ${versionTag ?? "loading"}"),
|
||||
Text(newestVersionTag != null
|
||||
? "Latest version: $newestVersionTag"
|
||||
: "")
|
||||
: ""),
|
||||
Divider(),
|
||||
TextButton(
|
||||
onPressed: () => VikunjaGlobal.of(context).logoutUser(context),
|
||||
child: Text("Logout")),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user