Skip to content

Commit

Permalink
fixed kanban by moving is_default_bucket from bucket to list
Browse files Browse the repository at this point in the history
  • Loading branch information
Benimautner committed Jan 6, 2024
1 parent ae34f6b commit b0d60e1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
17 changes: 13 additions & 4 deletions lib/components/KanbanWidget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -170,6 +171,11 @@ class KanbanClass {
),
));
}
Future<void> _setDoneBucket(BuildContext context, int bucketId) async {
//setState(() {});
_list = (await VikunjaGlobal.of(context).projectService.update(_list.copyWith(doneBucketId: bucketId)))!;
notify();
}

Future<void> _addBucket(
String title, BuildContext context) async {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/models/bucket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Bucket {
double? position;
final DateTime created, updated;
User createdBy;
bool isDoneBucket;
bool? isDoneBucket;
final List<Task> tasks;

Bucket({
Expand Down
6 changes: 6 additions & 0 deletions lib/models/project.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Project {
final DateTime created, updated;
final Color? color;
final bool isArchived, isFavourite;
final int? doneBucketId;

Iterable<Project>? subprojects;

Expand All @@ -22,6 +23,7 @@ class Project {
this.parentProjectId = 0,
this.description = '',
this.position = 0,
this.doneBucketId,
this.color,
this.isArchived = false,
this.isFavourite = false,
Expand All @@ -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']),
Expand All @@ -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
};

Expand All @@ -71,6 +75,7 @@ class Project {
Color? color,
bool? isArchived,
bool? isFavourite,
int? doneBucketId,
double? position,

}) {
Expand All @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions lib/pages/list/task_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -426,18 +426,20 @@ class _TaskEditPageState extends State<TaskEditPage> {
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)
savedDir: '/storage/emulated/0/Download/',
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);
},
),
);
Expand Down
1 change: 1 addition & 0 deletions lib/pages/user/login_webview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class LoginWithWebViewState extends State<LoginWithWebView> {
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(
Expand Down

0 comments on commit b0d60e1

Please sign in to comment.