Skip to content

Commit b0d60e1

Browse files
committed
fixed kanban by moving is_default_bucket from bucket to list
1 parent ae34f6b commit b0d60e1

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

lib/components/KanbanWidget.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class KanbanClass {
4545
if (_pageController == null || _pageController!.viewportFraction != bucketFraction)
4646
_pageController = PageController(viewportFraction: bucketFraction);
4747

48+
print(_list.doneBucketId);
4849

4950
return ReorderableListView.builder(
5051
scrollDirection: Axis.horizontal,
@@ -170,6 +171,11 @@ class KanbanClass {
170171
),
171172
));
172173
}
174+
Future<void> _setDoneBucket(BuildContext context, int bucketId) async {
175+
//setState(() {});
176+
_list = (await VikunjaGlobal.of(context).projectService.update(_list.copyWith(doneBucketId: bucketId)))!;
177+
notify();
178+
}
173179

174180
Future<void> _addBucket(
175181
String title, BuildContext context) async {
@@ -277,7 +283,7 @@ class KanbanClass {
277283
minLeadingWidth: 15,
278284
horizontalTitleGap: 4,
279285
contentPadding: const EdgeInsets.only(left: 16, right: 10),
280-
leading: bucket.isDoneBucket
286+
leading: bucket.id == _list.doneBucketId
281287
? Icon(
282288
Icons.done_all,
283289
color: Colors.green,
@@ -347,8 +353,11 @@ class KanbanClass {
347353
});
348354
break;
349355
case BucketMenu.done:
350-
bucket.isDoneBucket = !bucket.isDoneBucket;
351-
_updateBucket(context, bucket);
356+
//bucket.isDoneBucket = !(bucket.id == _list.doneBucketId);
357+
_list = _list.copyWith(doneBucketId: bucket.id);
358+
_setDoneBucket(context, bucket.id);
359+
notify();
360+
//_updateBucket(context, bucket);
352361
break;
353362
case BucketMenu.delete:
354363
_deleteBucket(context, bucket);
@@ -370,7 +379,7 @@ class KanbanClass {
370379
padding: const EdgeInsets.only(right: 4),
371380
child: Icon(
372381
Icons.done_all,
373-
color: bucket.isDoneBucket
382+
color: bucket.id == _list.doneBucketId
374383
? Colors.green
375384
: null,
376385
),

lib/models/bucket.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Bucket {
1010
double? position;
1111
final DateTime created, updated;
1212
User createdBy;
13-
bool isDoneBucket;
13+
bool? isDoneBucket;
1414
final List<Task> tasks;
1515

1616
Bucket({

lib/models/project.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Project {
1212
final DateTime created, updated;
1313
final Color? color;
1414
final bool isArchived, isFavourite;
15+
final int? doneBucketId;
1516

1617
Iterable<Project>? subprojects;
1718

@@ -22,6 +23,7 @@ class Project {
2223
this.parentProjectId = 0,
2324
this.description = '',
2425
this.position = 0,
26+
this.doneBucketId,
2527
this.color,
2628
this.isArchived = false,
2729
this.isFavourite = false,
@@ -38,6 +40,7 @@ class Project {
3840
position = json['position'].toDouble(),
3941
isArchived = json['is_archived'],
4042
isFavourite = json['is_archived'],
43+
doneBucketId = json['done_bucket_id'],
4144
parentProjectId = json['parent_project_id'],
4245
created = DateTime.parse(json['created']),
4346
updated = DateTime.parse(json['updated']),
@@ -57,6 +60,7 @@ class Project {
5760
'hex_color': color?.value.toRadixString(16).padLeft(8, '0').substring(2),
5861
'is_archived': isArchived,
5962
'is_favourite': isFavourite,
63+
'done_bucket_id': doneBucketId,
6064
'position': position
6165
};
6266

@@ -71,6 +75,7 @@ class Project {
7175
Color? color,
7276
bool? isArchived,
7377
bool? isFavourite,
78+
int? doneBucketId,
7479
double? position,
7580

7681
}) {
@@ -82,6 +87,7 @@ class Project {
8287
owner: owner ?? this.owner,
8388
description: description ?? this.description,
8489
parentProjectId: parentProjectId ?? this.parentProjectId,
90+
doneBucketId: doneBucketId ?? this.doneBucketId,
8591
color: color ?? this.color,
8692
isArchived: isArchived ?? this.isArchived,
8793
isFavourite: isFavourite ?? this.isFavourite,

lib/pages/list/task_edit.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,18 +426,20 @@ class _TaskEditPageState extends State<TaskEditPage> {
426426
title: Text(widget.task.attachments[index].file.name),
427427
trailing: IconButton(
428428
icon: Icon(Icons.download),
429-
onPressed: () {
429+
onPressed: () async {
430430
String url = VikunjaGlobal.of(context).client.base;
431431
url += '/tasks/${widget.task.id}/attachments/${widget.task.attachments[index].id}';
432432
print(url);
433-
final taskId = FlutterDownloader.enqueue(
433+
final taskId = await FlutterDownloader.enqueue(
434434
url: url,
435435
fileName: widget.task.attachments[index].file.name,
436436
headers: VikunjaGlobal.of(context).client.headers, // optional: header send with url (auth token etc)
437437
savedDir: '/storage/emulated/0/Download/',
438438
showNotification: true, // show download progress in status bar (for Android)
439439
openFileFromNotification: true, // click on notification to open downloaded file (for Android)
440440
);
441+
if(taskId == null) return;
442+
FlutterDownloader.open(taskId: taskId);
441443
},
442444
),
443445
);

lib/pages/user/login_webview.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class LoginWithWebViewState extends State<LoginWithWebView> {
2727
void initState() {
2828
super.initState();
2929
webViewController = WebViewController()
30+
..clearLocalStorage()
3031
..setJavaScriptMode(JavaScriptMode.unrestricted)
3132
..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")
3233
..setNavigationDelegate(NavigationDelegate(

0 commit comments

Comments
 (0)