Merge branch 'main' into bottom_navigation_bar
This commit is contained in:
commit
c2d976ac89
|
@ -1 +1 @@
|
|||
enum PageStatus { built, loading, success, error }
|
||||
enum PageStatus { built, loading, success, error, empty }
|
||||
|
|
|
@ -121,7 +121,23 @@ class NotificationClass {
|
|||
|
||||
|
||||
Future<void> scheduleDueNotifications(TaskService taskService) async {
|
||||
final tasks = await taskService.getAll();
|
||||
final tasks = await taskService.getByOptions(new TaskServiceOptions(newOptions: [
|
||||
TaskServiceOption<TaskServiceOptionFilterBy>("filter_by", [
|
||||
TaskServiceOptionFilterBy.done,
|
||||
TaskServiceOptionFilterBy.due_date
|
||||
]),
|
||||
TaskServiceOption<TaskServiceOptionFilterComparator>(
|
||||
"filter_comparator", [
|
||||
TaskServiceOptionFilterComparator.equals,
|
||||
TaskServiceOptionFilterComparator.greater
|
||||
]),
|
||||
TaskServiceOption<TaskServiceOptionFilterConcat>(
|
||||
"filter_concat", TaskServiceOptionFilterConcat.and),
|
||||
TaskServiceOption<TaskServiceOptionFilterValue>("filter_value", [
|
||||
TaskServiceOptionFilterValue.enum_false,
|
||||
DateTime.now().toUtc().toIso8601String()
|
||||
]),
|
||||
]));
|
||||
if (tasks == null) {
|
||||
print("did not receive tasks on notification update");
|
||||
return;
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:after_layout/after_layout.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:vikunja_app/global.dart';
|
||||
import 'package:vikunja_app/service/services.dart';
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
|
@ -90,6 +91,12 @@ class LandingPageState extends State<LandingPage>
|
|||
Center(child: Text("There was an error loading this view"))
|
||||
]);
|
||||
break;
|
||||
case PageStatus.empty:
|
||||
body = new Stack(children: [
|
||||
ListView(),
|
||||
Center(child: Text("This view is empty"))
|
||||
]);
|
||||
break;
|
||||
case PageStatus.success:
|
||||
body = ListView(
|
||||
scrollDirection: Axis.vertical,
|
||||
|
@ -176,10 +183,12 @@ class LandingPageState extends State<LandingPage>
|
|||
VikunjaGlobal.of(context).notifications.scheduleDueNotifications(VikunjaGlobal.of(context).taskService);
|
||||
return VikunjaGlobal.of(context)
|
||||
.taskService
|
||||
.getByOptions(VikunjaGlobal.of(context).taskServiceOptions)
|
||||
.getByOptions(TaskServiceOptions())
|
||||
.then<Future<void>?>((taskList) {
|
||||
if (taskList != null && taskList.isEmpty) {
|
||||
landingPageStatus = PageStatus.error;
|
||||
setState(() {
|
||||
landingPageStatus = PageStatus.empty;
|
||||
});
|
||||
return null;
|
||||
}
|
||||
return VikunjaGlobal.of(context).listService.getAll().then((lists) {
|
||||
|
|
|
@ -126,6 +126,12 @@ class _ListPageState extends State<ListPage> {
|
|||
Center(child: Text('This list is empty.'))
|
||||
]);
|
||||
break;
|
||||
case PageStatus.empty:
|
||||
body = new Stack(children: [
|
||||
ListView(),
|
||||
Center(child: Text("This view is empty"))
|
||||
]);
|
||||
break;
|
||||
}
|
||||
|
||||
return new Scaffold(
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:after_layout/after_layout.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:vikunja_app/components/AddDialog.dart';
|
||||
|
@ -26,7 +25,6 @@ class NamespacePage extends StatefulWidget {
|
|||
class _NamespacePageState extends State<NamespacePage> {
|
||||
List<TaskList> _lists = [];
|
||||
PageStatus namespacestatus = PageStatus.loading;
|
||||
bool _loading = true;
|
||||
|
||||
/////
|
||||
// This essentially shows the lists.
|
||||
|
@ -84,6 +82,12 @@ class _NamespacePageState extends State<NamespacePage> {
|
|||
))).toList(),
|
||||
);
|
||||
break;
|
||||
case PageStatus.empty:
|
||||
body = new Stack(children: [
|
||||
ListView(),
|
||||
Center(child: Text("This view is empty"))
|
||||
]);
|
||||
break;
|
||||
}
|
||||
return new Scaffold(
|
||||
body: RefreshIndicator(onRefresh: () => _loadLists(), child: body),
|
||||
|
@ -93,49 +97,6 @@ class _NamespacePageState extends State<NamespacePage> {
|
|||
child: const Icon(Icons.add))),
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
body: !this._loading
|
||||
? RefreshIndicator(
|
||||
child: _lists.length > 0
|
||||
? new ListView(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
children: ListTile.divideTiles(
|
||||
context: context,
|
||||
tiles: _lists.map((ls) => Dismissible(
|
||||
key: Key(ls.id.toString()),
|
||||
direction: DismissDirection.startToEnd,
|
||||
child: ListTile(
|
||||
title: new Text(ls.title),
|
||||
onTap: () => _openList(context, ls),
|
||||
trailing: Icon(Icons.arrow_right),
|
||||
),
|
||||
background: Container(
|
||||
color: Colors.red,
|
||||
child: const ListTile(
|
||||
leading: Icon(Icons.delete,
|
||||
color: Colors.white, size: 36.0)),
|
||||
),
|
||||
onDismissed: (direction) {
|
||||
_removeList(ls).then((_) =>
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
"${ls.title} removed"))));
|
||||
},
|
||||
))).toList(),
|
||||
)
|
||||
: Stack(children: [
|
||||
ListView(),
|
||||
Center(child: Text('This namespace is empty.'))
|
||||
]),
|
||||
onRefresh: _loadLists,
|
||||
)
|
||||
: Center(child: CircularProgressIndicator()),
|
||||
floatingActionButton: Builder(
|
||||
builder: (context) => FloatingActionButton(
|
||||
onPressed: () => _addListDialog(context),
|
||||
child: const Icon(Icons.add))),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -71,37 +71,42 @@ class TaskServiceOption<T> {
|
|||
}
|
||||
}
|
||||
|
||||
List<TaskServiceOption> defaultOptions = [
|
||||
TaskServiceOption<TaskServiceOptionSortBy>("sort_by",
|
||||
[TaskServiceOptionSortBy.due_date, TaskServiceOptionSortBy.id]),
|
||||
TaskServiceOption<TaskServiceOptionOrderBy>(
|
||||
"order_by", TaskServiceOptionOrderBy.asc),
|
||||
TaskServiceOption<TaskServiceOptionFilterBy>("filter_by", [
|
||||
TaskServiceOptionFilterBy.done,
|
||||
TaskServiceOptionFilterBy.due_date
|
||||
]),
|
||||
TaskServiceOption<TaskServiceOptionFilterValue>("filter_value", [
|
||||
TaskServiceOptionFilterValue.enum_false,
|
||||
'0001-01-02T00:00:00.000Z'
|
||||
]),
|
||||
TaskServiceOption<TaskServiceOptionFilterComparator>(
|
||||
"filter_comparator", [
|
||||
TaskServiceOptionFilterComparator.equals,
|
||||
TaskServiceOptionFilterComparator.greater
|
||||
]),
|
||||
TaskServiceOption<TaskServiceOptionFilterConcat>(
|
||||
"filter_concat", TaskServiceOptionFilterConcat.and),
|
||||
];
|
||||
|
||||
class TaskServiceOptions {
|
||||
List<TaskServiceOption>? options;
|
||||
|
||||
TaskServiceOptions({this.options}) {
|
||||
if (this.options == null)
|
||||
options = [
|
||||
TaskServiceOption<TaskServiceOptionSortBy>("sort_by",
|
||||
[TaskServiceOptionSortBy.due_date, TaskServiceOptionSortBy.id]),
|
||||
TaskServiceOption<TaskServiceOptionOrderBy>(
|
||||
"order_by", TaskServiceOptionOrderBy.asc),
|
||||
TaskServiceOption<TaskServiceOptionFilterBy>("filter_by", [
|
||||
TaskServiceOptionFilterBy.done,
|
||||
TaskServiceOptionFilterBy.due_date
|
||||
]),
|
||||
TaskServiceOption<TaskServiceOptionFilterValue>("filter_value", [
|
||||
TaskServiceOptionFilterValue.enum_false,
|
||||
'0001-01-02T00:00:00.000Z'
|
||||
]),
|
||||
TaskServiceOption<TaskServiceOptionFilterComparator>(
|
||||
"filter_comparator", [
|
||||
TaskServiceOptionFilterComparator.equals,
|
||||
TaskServiceOptionFilterComparator.greater
|
||||
]),
|
||||
TaskServiceOption<TaskServiceOptionFilterConcat>(
|
||||
"filter_concat", TaskServiceOptionFilterConcat.and),
|
||||
];
|
||||
TaskServiceOptions({List<TaskServiceOption>? newOptions}) {
|
||||
options = [...defaultOptions];
|
||||
if (newOptions != null) {
|
||||
for (TaskServiceOption custom_option in newOptions) {
|
||||
int index = options!.indexWhere((element) => element.name == custom_option.name);
|
||||
options!.removeAt(index);
|
||||
options!.insert(index, custom_option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setOption(TaskServiceOption option, dynamic value) {
|
||||
options?.firstWhere((element) => element.name == option.name).value = value;
|
||||
}
|
||||
|
||||
String getOptions() {
|
||||
String result = '';
|
||||
|
@ -239,10 +244,8 @@ class SettingsManager {
|
|||
|
||||
void applydefaults() {
|
||||
defaults.forEach((key, value) {
|
||||
_storage.containsKey(key: key).then((is_created) async {
|
||||
if (!is_created) {
|
||||
print("iscreated $is_created");
|
||||
print("default not set, writing $value to $key");
|
||||
_storage.containsKey(key: key).then((isCreated) async {
|
||||
if (!isCreated) {
|
||||
await _storage.write(key: key, value: value);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue