diff --git a/lib/components/KanbanWidget.dart b/lib/components/KanbanWidget.dart index f3d2368..d327423 100644 --- a/lib/components/KanbanWidget.dart +++ b/lib/components/KanbanWidget.dart @@ -45,6 +45,7 @@ class KanbanClass { if (_pageController == null || _pageController!.viewportFraction != bucketFraction) _pageController = PageController(viewportFraction: bucketFraction); + print(_list.doneBucketId); return ReorderableListView.builder( scrollDirection: Axis.horizontal, @@ -170,6 +171,11 @@ class KanbanClass { ), )); } + Future _setDoneBucket(BuildContext context, int bucketId) async { + //setState(() {}); + _list = (await VikunjaGlobal.of(context).projectService.update(_list.copyWith(doneBucketId: bucketId)))!; + notify(); + } Future _addBucket( String title, BuildContext context) async { @@ -277,7 +283,7 @@ class KanbanClass { minLeadingWidth: 15, horizontalTitleGap: 4, contentPadding: const EdgeInsets.only(left: 16, right: 10), - leading: bucket.isDoneBucket + leading: bucket.id == _list.doneBucketId ? Icon( Icons.done_all, color: Colors.green, @@ -347,8 +353,11 @@ class KanbanClass { }); break; case BucketMenu.done: - bucket.isDoneBucket = !bucket.isDoneBucket; - _updateBucket(context, bucket); + //bucket.isDoneBucket = !(bucket.id == _list.doneBucketId); + _list = _list.copyWith(doneBucketId: bucket.id); + _setDoneBucket(context, bucket.id); + notify(); + //_updateBucket(context, bucket); break; case BucketMenu.delete: _deleteBucket(context, bucket); @@ -370,7 +379,7 @@ class KanbanClass { padding: const EdgeInsets.only(right: 4), child: Icon( Icons.done_all, - color: bucket.isDoneBucket + color: bucket.id == _list.doneBucketId ? Colors.green : null, ), diff --git a/lib/models/bucket.dart b/lib/models/bucket.dart index f6ed3e6..879a86d 100644 --- a/lib/models/bucket.dart +++ b/lib/models/bucket.dart @@ -10,7 +10,7 @@ class Bucket { double? position; final DateTime created, updated; User createdBy; - bool isDoneBucket; + bool? isDoneBucket; final List tasks; Bucket({ diff --git a/lib/models/project.dart b/lib/models/project.dart index 0eaf64a..1e7e634 100644 --- a/lib/models/project.dart +++ b/lib/models/project.dart @@ -12,6 +12,7 @@ class Project { final DateTime created, updated; final Color? color; final bool isArchived, isFavourite; + final int? doneBucketId; Iterable? subprojects; @@ -22,6 +23,7 @@ class Project { this.parentProjectId = 0, this.description = '', this.position = 0, + this.doneBucketId, this.color, this.isArchived = false, this.isFavourite = false, @@ -38,6 +40,7 @@ class Project { position = json['position'].toDouble(), isArchived = json['is_archived'], isFavourite = json['is_archived'], + doneBucketId = json['done_bucket_id'], parentProjectId = json['parent_project_id'], created = DateTime.parse(json['created']), updated = DateTime.parse(json['updated']), @@ -57,6 +60,7 @@ class Project { 'hex_color': color?.value.toRadixString(16).padLeft(8, '0').substring(2), 'is_archived': isArchived, 'is_favourite': isFavourite, + 'done_bucket_id': doneBucketId, 'position': position }; @@ -71,6 +75,7 @@ class Project { Color? color, bool? isArchived, bool? isFavourite, + int? doneBucketId, double? position, }) { @@ -82,6 +87,7 @@ class Project { owner: owner ?? this.owner, description: description ?? this.description, parentProjectId: parentProjectId ?? this.parentProjectId, + doneBucketId: doneBucketId ?? this.doneBucketId, color: color ?? this.color, isArchived: isArchived ?? this.isArchived, isFavourite: isFavourite ?? this.isFavourite, diff --git a/lib/pages/list/task_edit.dart b/lib/pages/list/task_edit.dart index f553025..56271fb 100644 --- a/lib/pages/list/task_edit.dart +++ b/lib/pages/list/task_edit.dart @@ -426,11 +426,11 @@ class _TaskEditPageState extends State { title: Text(widget.task.attachments[index].file.name), trailing: IconButton( icon: Icon(Icons.download), - onPressed: () { + onPressed: () async { String url = VikunjaGlobal.of(context).client.base; url += '/tasks/${widget.task.id}/attachments/${widget.task.attachments[index].id}'; print(url); - final taskId = FlutterDownloader.enqueue( + final taskId = await FlutterDownloader.enqueue( url: url, fileName: widget.task.attachments[index].file.name, headers: VikunjaGlobal.of(context).client.headers, // optional: header send with url (auth token etc) @@ -438,6 +438,8 @@ class _TaskEditPageState extends State { showNotification: true, // show download progress in status bar (for Android) openFileFromNotification: true, // click on notification to open downloaded file (for Android) ); + if(taskId == null) return; + FlutterDownloader.open(taskId: taskId); }, ), ); diff --git a/lib/pages/user/login_webview.dart b/lib/pages/user/login_webview.dart index 7aec8fa..b05e57d 100644 --- a/lib/pages/user/login_webview.dart +++ b/lib/pages/user/login_webview.dart @@ -27,6 +27,7 @@ class LoginWithWebViewState extends State { void initState() { super.initState(); webViewController = WebViewController() + ..clearLocalStorage() ..setJavaScriptMode(JavaScriptMode.unrestricted) ..setUserAgent("Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Mobile Safari/537.36") ..setNavigationDelegate(NavigationDelegate(