mirror of
https://github.com/go-vikunja/app
synced 2024-06-06 20:49:48 +00:00
fixed default list add requiring a widget rebuild to change color
This commit is contained in:
parent
008cc875b4
commit
e44c68ac35
|
@ -27,9 +27,10 @@ class HomePageState extends State<HomePage> with AfterLayoutMixin<HomePage> {
|
|||
_selectedDrawerIndex >= 0 && _selectedDrawerIndex < _namespaces.length
|
||||
? _namespaces[_selectedDrawerIndex]
|
||||
: null;
|
||||
int _selectedDrawerIndex = -1;
|
||||
int _selectedDrawerIndex = -1, _previousDrawerIndex = -1;
|
||||
bool _loading = true;
|
||||
bool _showUserDetails = false;
|
||||
Widget drawerItem;
|
||||
|
||||
@override
|
||||
void afterFirstLayout(BuildContext context) {
|
||||
|
@ -72,7 +73,13 @@ class HomePageState extends State<HomePage> with AfterLayoutMixin<HomePage> {
|
|||
title: Text('Settings'),
|
||||
leading: Icon(Icons.settings),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => SettingsPage()));
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => SettingsPage()))
|
||||
.whenComplete(() =>
|
||||
setState((){
|
||||
//returning from settings, this needs to be force-refreshed
|
||||
drawerItem = _getDrawerItemWidget(_selectedDrawerIndex, forceReload: true);
|
||||
}));
|
||||
},
|
||||
)
|
||||
]);
|
||||
|
@ -81,6 +88,8 @@ class HomePageState extends State<HomePage> with AfterLayoutMixin<HomePage> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var currentUser = VikunjaGlobal.of(context).currentUser;
|
||||
if(_selectedDrawerIndex != _previousDrawerIndex)
|
||||
drawerItem = _getDrawerItemWidget(_selectedDrawerIndex);
|
||||
|
||||
return new Scaffold(
|
||||
appBar: AppBar(
|
||||
|
@ -151,13 +160,14 @@ class HomePageState extends State<HomePage> with AfterLayoutMixin<HomePage> {
|
|||
),
|
||||
),
|
||||
])),
|
||||
body: _getDrawerItemWidget(_selectedDrawerIndex),
|
||||
body: drawerItem,
|
||||
);
|
||||
}
|
||||
|
||||
_getDrawerItemWidget(int pos) {
|
||||
_getDrawerItemWidget(int pos, {bool forceReload = false}) {
|
||||
_previousDrawerIndex = pos;
|
||||
if (pos == -1) {
|
||||
return new LandingPage();
|
||||
return forceReload ? new LandingPage(key: UniqueKey()) : new LandingPage();
|
||||
}
|
||||
return new NamespacePage(namespace: _namespaces[pos]);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:vikunja_app/global.dart';
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import '../components/AddDialog.dart';
|
||||
import '../components/TaskTile.dart';
|
||||
import '../models/task.dart';
|
||||
|
||||
class LandingPage extends StatefulWidget {
|
||||
|
||||
const LandingPage(
|
||||
{Key key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => LandingPageState();
|
||||
|
||||
|
@ -15,12 +22,20 @@ class LandingPageState extends State<LandingPage> {
|
|||
int defaultList;
|
||||
List<Task> _list;
|
||||
|
||||
void _updateDefaultList() {
|
||||
VikunjaGlobal.of(context)
|
||||
.listService
|
||||
.getDefaultList()
|
||||
.then((value) => setState(() => defaultList = value == null ? null : int.tryParse(value)));
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
Future.delayed(Duration.zero, () =>
|
||||
VikunjaGlobal.of(context).listService.getDefaultList().then((value) => setState(() => defaultList = value == null ? null : int.tryParse(value))));
|
||||
Future.delayed(Duration.zero, () => _updateDefaultList());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if(_list == null)
|
||||
|
|
|
@ -27,7 +27,7 @@ class SettingsPageState extends State<SettingsPage> {
|
|||
ListTile(
|
||||
title: Text("Default List"),
|
||||
trailing: DropdownButton(
|
||||
items: taskListList.map((e) => DropdownMenuItem(child: Text(e.title), value: e.id)).toList(),
|
||||
items: [DropdownMenuItem(child: Text("None"), value: null,), ...taskListList.map((e) => DropdownMenuItem(child: Text(e.title), value: e.id)).toList()],
|
||||
value: defaultList,
|
||||
onChanged: (value){
|
||||
setState(() => defaultList = value);
|
||||
|
|
Loading…
Reference in New Issue
Block a user