mirror of
https://github.com/go-vikunja/app
synced 2024-06-01 02:06:51 +00:00
added option to select what to see on landing page
This commit is contained in:
parent
c7a556311d
commit
6b276e511d
|
@ -19,11 +19,8 @@ class HomeScreenWidget extends StatefulWidget {
|
|||
// TODO: implement createState
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class LandingPage extends HomeScreenWidget {
|
||||
LandingPage({Key? key}) : super(key: key);
|
||||
|
||||
|
@ -31,10 +28,10 @@ class LandingPage extends HomeScreenWidget {
|
|||
State<StatefulWidget> createState() => LandingPageState();
|
||||
}
|
||||
|
||||
|
||||
class LandingPageState extends State<LandingPage>
|
||||
with AfterLayoutMixin<LandingPage> {
|
||||
int? defaultList;
|
||||
bool onlyDueDate = true;
|
||||
List<Task> _tasks = [];
|
||||
PageStatus landingPageStatus = PageStatus.built;
|
||||
static const platform = const MethodChannel('vikunja');
|
||||
|
@ -56,6 +53,7 @@ class LandingPageState extends State<LandingPage>
|
|||
} catch (e) {
|
||||
log(e.toString());
|
||||
}
|
||||
VikunjaGlobal.of(context).settingsManager.getLandingPageOnlyDueDateTasks().then((value) => onlyDueDate = value);
|
||||
}));
|
||||
super.initState();
|
||||
}
|
||||
|
@ -105,10 +103,8 @@ class LandingPageState extends State<LandingPage>
|
|||
]);
|
||||
break;
|
||||
case PageStatus.empty:
|
||||
body = new Stack(children: [
|
||||
ListView(),
|
||||
Center(child: Text("This view is empty"))
|
||||
]);
|
||||
body = new Stack(
|
||||
children: [ListView(), Center(child: Text("This view is empty"))]);
|
||||
break;
|
||||
case PageStatus.success:
|
||||
body = ListView(
|
||||
|
@ -121,8 +117,7 @@ class LandingPageState extends State<LandingPage>
|
|||
break;
|
||||
}
|
||||
return new Scaffold(
|
||||
body:
|
||||
RefreshIndicator(onRefresh: () => _loadList(context), child: body),
|
||||
body: RefreshIndicator(onRefresh: () => _loadList(context), child: body),
|
||||
floatingActionButton: Builder(
|
||||
builder: (context) => FloatingActionButton(
|
||||
onPressed: () {
|
||||
|
@ -132,8 +127,34 @@ class LandingPageState extends State<LandingPage>
|
|||
)),
|
||||
appBar: AppBar(
|
||||
title: Text("Vikunja"),
|
||||
actions: [
|
||||
PopupMenuButton(itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem(
|
||||
child:
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
bool newval = !onlyDueDate;
|
||||
VikunjaGlobal.of(context).settingsManager.setLandingPageOnlyDueDateTasks(newval).then((value) {
|
||||
setState(() {
|
||||
onlyDueDate = newval;
|
||||
_loadList(context);
|
||||
});
|
||||
});
|
||||
},
|
||||
child:
|
||||
Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
||||
Text("Only show tasks with due date"),
|
||||
Checkbox(
|
||||
value: onlyDueDate,
|
||||
onChanged: (bool? value) { },
|
||||
)
|
||||
])))
|
||||
];
|
||||
}),
|
||||
],
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -196,16 +217,31 @@ class LandingPageState extends State<LandingPage>
|
|||
_tasks = [];
|
||||
landingPageStatus = PageStatus.loading;
|
||||
// FIXME: loads and reschedules tasks each time list is updated
|
||||
VikunjaGlobal.of(context).notifications.scheduleDueNotifications(VikunjaGlobal.of(context).taskService);
|
||||
VikunjaGlobal.of(context)
|
||||
.notifications
|
||||
.scheduleDueNotifications(VikunjaGlobal.of(context).taskService);
|
||||
return VikunjaGlobal.of(context)
|
||||
.settingsManager
|
||||
.getLandingPageOnlyDueDateTasks()
|
||||
.then((showOnlyDueDateTasks) {
|
||||
if (!showOnlyDueDateTasks) {
|
||||
return VikunjaGlobal.of(context).taskService.getAll().then((value) => _handleTaskList(value));
|
||||
} else {
|
||||
return VikunjaGlobal
|
||||
.of(context)
|
||||
.taskService
|
||||
.getByOptions(TaskServiceOptions())
|
||||
.then<Future<void>?>((taskList) {
|
||||
.then<Future<void>?>((taskList) => _handleTaskList(taskList));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _handleTaskList(List<Task>? taskList) {
|
||||
if (taskList != null && taskList.isEmpty) {
|
||||
setState(() {
|
||||
landingPageStatus = PageStatus.empty;
|
||||
});
|
||||
return null;
|
||||
return Future.value();
|
||||
}
|
||||
//taskList.forEach((task) {task.list = lists.firstWhere((element) => element.id == task.list_id);});
|
||||
setState(() {
|
||||
|
@ -216,7 +252,6 @@ class LandingPageState extends State<LandingPage>
|
|||
landingPageStatus = PageStatus.error;
|
||||
}
|
||||
});
|
||||
return null;
|
||||
});
|
||||
return Future.value();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -259,6 +259,7 @@ class SettingsManager {
|
|||
"workmanager-duration": "0",
|
||||
"recent-servers": "[\"https://try.vikunja.io\"]",
|
||||
"theme_mode": "system",
|
||||
"landing-page-due-date-tasks": "1"
|
||||
};
|
||||
|
||||
void applydefaults() {
|
||||
|
@ -283,6 +284,13 @@ class SettingsManager {
|
|||
_storage.write(key: "ignore-certificates", value: value ? "1" : "0");
|
||||
}
|
||||
|
||||
Future<bool> getLandingPageOnlyDueDateTasks() {
|
||||
return _storage.read(key: "landing-page-due-date-tasks").then((value) => value == "1");
|
||||
}
|
||||
Future<void> setLandingPageOnlyDueDateTasks(bool value) {
|
||||
return _storage.write(key: "landing-page-due-date-tasks", value: value ? "1" : "0");
|
||||
}
|
||||
|
||||
|
||||
Future<String?> getVersionNotifications() {
|
||||
return _storage.read(key: "get-version-notifications");
|
||||
|
|
Loading…
Reference in New Issue
Block a user