From fae495cb18cba45fcdf4b09d0f05bdf19f16f941 Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Thu, 25 Apr 2024 11:27:10 +0200 Subject: [PATCH] Allow changing group and place in event creation dialog --- api/lib/models/event/item/model.g.dart | 32 +++++++++-------- api/lib/models/label/model.g.dart | 2 +- api/lib/models/note/model.g.dart | 2 +- app/lib/pages/events/event.dart | 34 ++++++++++--------- app/lib/pages/groups/select.dart | 10 ++++++ .../metadata/android/en-US/changelogs/7.txt | 1 + 6 files changed, 49 insertions(+), 32 deletions(-) diff --git a/api/lib/models/event/item/model.g.dart b/api/lib/models/event/item/model.g.dart index 5a702c0b663..1921e07385a 100644 --- a/api/lib/models/event/item/model.g.dart +++ b/api/lib/models/event/item/model.g.dart @@ -18,8 +18,9 @@ _$FixedCalendarItemImpl _$$FixedCalendarItemImplFromJson( json['eventId'], const MultihashConverter().fromJson), status: $enumDecodeNullable(_$EventStatusEnumMap, json['status']) ?? EventStatus.confirmed, - start: const DateTimeConverter().fromJson(json['start'] as int?), - end: const DateTimeConverter().fromJson(json['end'] as int?), + start: + const DateTimeConverter().fromJson((json['start'] as num?)?.toInt()), + end: const DateTimeConverter().fromJson((json['end'] as num?)?.toInt()), $type: json['runtimeType'] as String?, ); @@ -69,17 +70,19 @@ _$RepeatingCalendarItemImpl _$$RepeatingCalendarItemImplFromJson( json['eventId'], const MultihashConverter().fromJson), status: $enumDecodeNullable(_$EventStatusEnumMap, json['status']) ?? EventStatus.confirmed, - start: const DateTimeConverter().fromJson(json['start'] as int?), - end: const DateTimeConverter().fromJson(json['end'] as int?), + start: + const DateTimeConverter().fromJson((json['start'] as num?)?.toInt()), + end: const DateTimeConverter().fromJson((json['end'] as num?)?.toInt()), repeatType: $enumDecodeNullable(_$RepeatTypeEnumMap, json['repeatType']) ?? RepeatType.daily, - interval: json['interval'] as int? ?? 1, - variation: json['variation'] as int? ?? 0, - count: json['count'] as int? ?? 0, - until: const DateTimeConverter().fromJson(json['until'] as int?), + interval: (json['interval'] as num?)?.toInt() ?? 1, + variation: (json['variation'] as num?)?.toInt() ?? 0, + count: (json['count'] as num?)?.toInt() ?? 0, + until: + const DateTimeConverter().fromJson((json['until'] as num?)?.toInt()), exceptions: (json['exceptions'] as List?) - ?.map((e) => e as int) + ?.map((e) => (e as num).toInt()) .toList() ?? const [], $type: json['runtimeType'] as String?, @@ -126,13 +129,14 @@ _$AutoCalendarItemImpl _$$AutoCalendarItemImplFromJson( json['eventId'], const MultihashConverter().fromJson), status: $enumDecodeNullable(_$EventStatusEnumMap, json['status']) ?? EventStatus.confirmed, - start: const DateTimeConverter().fromJson(json['start'] as int?), - end: const DateTimeConverter().fromJson(json['end'] as int?), + start: + const DateTimeConverter().fromJson((json['start'] as num?)?.toInt()), + end: const DateTimeConverter().fromJson((json['end'] as num?)?.toInt()), autoGroupId: _$JsonConverterFromJson, Multihash>( json['autoGroupId'], const MultihashConverter().fromJson), - searchStart: - const DateTimeConverter().fromJson(json['searchStart'] as int?), - autoDuration: json['autoDuration'] as int? ?? 60, + searchStart: const DateTimeConverter() + .fromJson((json['searchStart'] as num?)?.toInt()), + autoDuration: (json['autoDuration'] as num?)?.toInt() ?? 60, $type: json['runtimeType'] as String?, ); diff --git a/api/lib/models/label/model.g.dart b/api/lib/models/label/model.g.dart index 2d57bb0f1c0..1797e31225b 100644 --- a/api/lib/models/label/model.g.dart +++ b/api/lib/models/label/model.g.dart @@ -11,7 +11,7 @@ _$LabelImpl _$$LabelImplFromJson(Map json) => _$LabelImpl( json['id'], const MultihashConverter().fromJson), name: json['name'] as String? ?? '', description: json['description'] as String? ?? '', - color: json['color'] as int? ?? kColorBlack, + color: (json['color'] as num?)?.toInt() ?? kColorBlack, ); Map _$$LabelImplToJson(_$LabelImpl instance) => diff --git a/api/lib/models/note/model.g.dart b/api/lib/models/note/model.g.dart index 872ba72d1bc..c92e7baa7b1 100644 --- a/api/lib/models/note/model.g.dart +++ b/api/lib/models/note/model.g.dart @@ -14,7 +14,7 @@ _$NoteImpl _$$NoteImplFromJson(Map json) => _$NoteImpl( name: json['name'] as String? ?? '', description: json['description'] as String? ?? '', status: $enumDecodeNullable(_$NoteStatusEnumMap, json['status']), - priority: json['priority'] as int? ?? 0, + priority: (json['priority'] as num?)?.toInt() ?? 0, ); Map _$$NoteImplToJson(_$NoteImpl instance) => diff --git a/app/lib/pages/events/event.dart b/app/lib/pages/events/event.dart index 93008699736..fab95fca9da 100644 --- a/app/lib/pages/events/event.dart +++ b/app/lib/pages/events/event.dart @@ -54,6 +54,10 @@ class EventDialog extends StatelessWidget { onChanged: (connected) { currentSource = connected?.source ?? ''; currentService = connected?.model; + currentEvent = currentEvent.copyWith( + groupId: null, + placeId: null, + ); }, ), const SizedBox(height: 16), @@ -80,22 +84,20 @@ class EventDialog extends StatelessWidget { onChanged: (value) => currentEvent = currentEvent.copyWith(description: value), ), - if (!create) ...[ - const SizedBox(height: 16), - GroupSelectTile( - source: source!, - onChanged: (value) { - currentEvent = currentEvent.copyWith(groupId: value); - }, - ), - const SizedBox(height: 16), - PlaceSelectTile( - source: source!, - onChanged: (value) { - currentEvent = currentEvent.copyWith(placeId: value); - }, - ), - ], + const SizedBox(height: 16), + GroupSelectTile( + source: currentSource, + onChanged: (value) { + currentEvent = currentEvent.copyWith(groupId: value); + }, + ), + const SizedBox(height: 16), + PlaceSelectTile( + source: currentSource, + onChanged: (value) { + currentEvent = currentEvent.copyWith(placeId: value); + }, + ), const SizedBox(height: 8), StatefulBuilder( builder: (context, setState) => CheckboxListTile( diff --git a/app/lib/pages/groups/select.dart b/app/lib/pages/groups/select.dart index 5c076c9deae..3386219205e 100644 --- a/app/lib/pages/groups/select.dart +++ b/app/lib/pages/groups/select.dart @@ -44,6 +44,16 @@ class _GroupSelectTileState extends State { widget.onChanged(value); } + @override + void didUpdateWidget(covariant GroupSelectTile oldWidget) { + if (oldWidget.value != widget.value || oldWidget.source != widget.source) { + setState(() { + _value = widget.value; + }); + } + super.didUpdateWidget(oldWidget); + } + @override Widget build(BuildContext context) { return FutureBuilder( diff --git a/fastlane/metadata/android/en-US/changelogs/7.txt b/fastlane/metadata/android/en-US/changelogs/7.txt index 51c379a2ce2..8c2023db86f 100644 --- a/fastlane/metadata/android/en-US/changelogs/7.txt +++ b/fastlane/metadata/android/en-US/changelogs/7.txt @@ -2,6 +2,7 @@ * Add density setting * Add high contrast mode * Add classic theme +* Allow changing group and place in event creation dialog * Make dashboard the back page * Improve icon style for different calendar item types * Improve custom title bar window buttons