Skip to content

Commit

Permalink
feat: add checklists in task form
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasn committed Nov 17, 2024
1 parent f87a981 commit 8a84064
Show file tree
Hide file tree
Showing 17 changed files with 566 additions and 21 deletions.
1 change: 1 addition & 0 deletions lib/classes/checklist_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ChecklistData with _$ChecklistData {
const factory ChecklistData({
required String title,
required List<String> linkedChecklistItems,
required List<String> linkedTasks,
}) = _ChecklistData;

factory ChecklistData.fromJson(Map<String, dynamic> json) =>
Expand Down
54 changes: 45 additions & 9 deletions lib/classes/checklist_data.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ChecklistData _$ChecklistDataFromJson(Map<String, dynamic> json) {
mixin _$ChecklistData {
String get title => throw _privateConstructorUsedError;
List<String> get linkedChecklistItems => throw _privateConstructorUsedError;
List<String> get linkedTasks => throw _privateConstructorUsedError;

/// Serializes this ChecklistData to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
Expand All @@ -39,7 +40,10 @@ abstract class $ChecklistDataCopyWith<$Res> {
ChecklistData value, $Res Function(ChecklistData) then) =
_$ChecklistDataCopyWithImpl<$Res, ChecklistData>;
@useResult
$Res call({String title, List<String> linkedChecklistItems});
$Res call(
{String title,
List<String> linkedChecklistItems,
List<String> linkedTasks});
}

/// @nodoc
Expand All @@ -59,6 +63,7 @@ class _$ChecklistDataCopyWithImpl<$Res, $Val extends ChecklistData>
$Res call({
Object? title = null,
Object? linkedChecklistItems = null,
Object? linkedTasks = null,
}) {
return _then(_value.copyWith(
title: null == title
Expand All @@ -69,6 +74,10 @@ class _$ChecklistDataCopyWithImpl<$Res, $Val extends ChecklistData>
? _value.linkedChecklistItems
: linkedChecklistItems // ignore: cast_nullable_to_non_nullable
as List<String>,
linkedTasks: null == linkedTasks
? _value.linkedTasks
: linkedTasks // ignore: cast_nullable_to_non_nullable
as List<String>,
) as $Val);
}
}
Expand All @@ -81,7 +90,10 @@ abstract class _$$ChecklistDataImplCopyWith<$Res>
__$$ChecklistDataImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String title, List<String> linkedChecklistItems});
$Res call(
{String title,
List<String> linkedChecklistItems,
List<String> linkedTasks});
}

/// @nodoc
Expand All @@ -99,6 +111,7 @@ class __$$ChecklistDataImplCopyWithImpl<$Res>
$Res call({
Object? title = null,
Object? linkedChecklistItems = null,
Object? linkedTasks = null,
}) {
return _then(_$ChecklistDataImpl(
title: null == title
Expand All @@ -109,6 +122,10 @@ class __$$ChecklistDataImplCopyWithImpl<$Res>
? _value._linkedChecklistItems
: linkedChecklistItems // ignore: cast_nullable_to_non_nullable
as List<String>,
linkedTasks: null == linkedTasks
? _value._linkedTasks
: linkedTasks // ignore: cast_nullable_to_non_nullable
as List<String>,
));
}
}
Expand All @@ -117,8 +134,11 @@ class __$$ChecklistDataImplCopyWithImpl<$Res>
@JsonSerializable()
class _$ChecklistDataImpl implements _ChecklistData {
const _$ChecklistDataImpl(
{required this.title, required final List<String> linkedChecklistItems})
: _linkedChecklistItems = linkedChecklistItems;
{required this.title,
required final List<String> linkedChecklistItems,
required final List<String> linkedTasks})
: _linkedChecklistItems = linkedChecklistItems,
_linkedTasks = linkedTasks;

factory _$ChecklistDataImpl.fromJson(Map<String, dynamic> json) =>
_$$ChecklistDataImplFromJson(json);
Expand All @@ -134,9 +154,17 @@ class _$ChecklistDataImpl implements _ChecklistData {
return EqualUnmodifiableListView(_linkedChecklistItems);
}

final List<String> _linkedTasks;
@override
List<String> get linkedTasks {
if (_linkedTasks is EqualUnmodifiableListView) return _linkedTasks;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_linkedTasks);
}

@override
String toString() {
return 'ChecklistData(title: $title, linkedChecklistItems: $linkedChecklistItems)';
return 'ChecklistData(title: $title, linkedChecklistItems: $linkedChecklistItems, linkedTasks: $linkedTasks)';
}

@override
Expand All @@ -146,13 +174,18 @@ class _$ChecklistDataImpl implements _ChecklistData {
other is _$ChecklistDataImpl &&
(identical(other.title, title) || other.title == title) &&
const DeepCollectionEquality()
.equals(other._linkedChecklistItems, _linkedChecklistItems));
.equals(other._linkedChecklistItems, _linkedChecklistItems) &&
const DeepCollectionEquality()
.equals(other._linkedTasks, _linkedTasks));
}

@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, title,
const DeepCollectionEquality().hash(_linkedChecklistItems));
int get hashCode => Object.hash(
runtimeType,
title,
const DeepCollectionEquality().hash(_linkedChecklistItems),
const DeepCollectionEquality().hash(_linkedTasks));

/// Create a copy of ChecklistData
/// with the given fields replaced by the non-null parameter values.
Expand All @@ -173,7 +206,8 @@ class _$ChecklistDataImpl implements _ChecklistData {
abstract class _ChecklistData implements ChecklistData {
const factory _ChecklistData(
{required final String title,
required final List<String> linkedChecklistItems}) = _$ChecklistDataImpl;
required final List<String> linkedChecklistItems,
required final List<String> linkedTasks}) = _$ChecklistDataImpl;

factory _ChecklistData.fromJson(Map<String, dynamic> json) =
_$ChecklistDataImpl.fromJson;
Expand All @@ -182,6 +216,8 @@ abstract class _ChecklistData implements ChecklistData {
String get title;
@override
List<String> get linkedChecklistItems;
@override
List<String> get linkedTasks;

/// Create a copy of ChecklistData
/// with the given fields replaced by the non-null parameter values.
Expand Down
4 changes: 4 additions & 0 deletions lib/classes/checklist_data.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/classes/task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class TaskData with _$TaskData {
required String title,
DateTime? due,
Duration? estimate,
List<String>? checklistIds,
}) = _TaskData;

factory TaskData.fromJson(Map<String, dynamic> json) =>
Expand Down
46 changes: 38 additions & 8 deletions lib/classes/task.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2775,6 +2775,7 @@ mixin _$TaskData {
String get title => throw _privateConstructorUsedError;
DateTime? get due => throw _privateConstructorUsedError;
Duration? get estimate => throw _privateConstructorUsedError;
List<String>? get checklistIds => throw _privateConstructorUsedError;

/// Serializes this TaskData to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
Expand All @@ -2798,7 +2799,8 @@ abstract class $TaskDataCopyWith<$Res> {
List<TaskStatus> statusHistory,
String title,
DateTime? due,
Duration? estimate});
Duration? estimate,
List<String>? checklistIds});

$TaskStatusCopyWith<$Res> get status;
}
Expand All @@ -2825,6 +2827,7 @@ class _$TaskDataCopyWithImpl<$Res, $Val extends TaskData>
Object? title = null,
Object? due = freezed,
Object? estimate = freezed,
Object? checklistIds = freezed,
}) {
return _then(_value.copyWith(
status: null == status
Expand Down Expand Up @@ -2855,6 +2858,10 @@ class _$TaskDataCopyWithImpl<$Res, $Val extends TaskData>
? _value.estimate
: estimate // ignore: cast_nullable_to_non_nullable
as Duration?,
checklistIds: freezed == checklistIds
? _value.checklistIds
: checklistIds // ignore: cast_nullable_to_non_nullable
as List<String>?,
) as $Val);
}

Expand Down Expand Up @@ -2884,7 +2891,8 @@ abstract class _$$TaskDataImplCopyWith<$Res>
List<TaskStatus> statusHistory,
String title,
DateTime? due,
Duration? estimate});
Duration? estimate,
List<String>? checklistIds});

@override
$TaskStatusCopyWith<$Res> get status;
Expand All @@ -2910,6 +2918,7 @@ class __$$TaskDataImplCopyWithImpl<$Res>
Object? title = null,
Object? due = freezed,
Object? estimate = freezed,
Object? checklistIds = freezed,
}) {
return _then(_$TaskDataImpl(
status: null == status
Expand Down Expand Up @@ -2940,6 +2949,10 @@ class __$$TaskDataImplCopyWithImpl<$Res>
? _value.estimate
: estimate // ignore: cast_nullable_to_non_nullable
as Duration?,
checklistIds: freezed == checklistIds
? _value._checklistIds
: checklistIds // ignore: cast_nullable_to_non_nullable
as List<String>?,
));
}
}
Expand All @@ -2954,8 +2967,10 @@ class _$TaskDataImpl implements _TaskData {
required final List<TaskStatus> statusHistory,
required this.title,
this.due,
this.estimate})
: _statusHistory = statusHistory;
this.estimate,
final List<String>? checklistIds})
: _statusHistory = statusHistory,
_checklistIds = checklistIds;

factory _$TaskDataImpl.fromJson(Map<String, dynamic> json) =>
_$$TaskDataImplFromJson(json);
Expand All @@ -2980,10 +2995,19 @@ class _$TaskDataImpl implements _TaskData {
final DateTime? due;
@override
final Duration? estimate;
final List<String>? _checklistIds;
@override
List<String>? get checklistIds {
final value = _checklistIds;
if (value == null) return null;
if (_checklistIds is EqualUnmodifiableListView) return _checklistIds;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(value);
}

@override
String toString() {
return 'TaskData(status: $status, dateFrom: $dateFrom, dateTo: $dateTo, statusHistory: $statusHistory, title: $title, due: $due, estimate: $estimate)';
return 'TaskData(status: $status, dateFrom: $dateFrom, dateTo: $dateTo, statusHistory: $statusHistory, title: $title, due: $due, estimate: $estimate, checklistIds: $checklistIds)';
}

@override
Expand All @@ -3000,7 +3024,9 @@ class _$TaskDataImpl implements _TaskData {
(identical(other.title, title) || other.title == title) &&
(identical(other.due, due) || other.due == due) &&
(identical(other.estimate, estimate) ||
other.estimate == estimate));
other.estimate == estimate) &&
const DeepCollectionEquality()
.equals(other._checklistIds, _checklistIds));
}

@JsonKey(includeFromJson: false, includeToJson: false)
Expand All @@ -3013,7 +3039,8 @@ class _$TaskDataImpl implements _TaskData {
const DeepCollectionEquality().hash(_statusHistory),
title,
due,
estimate);
estimate,
const DeepCollectionEquality().hash(_checklistIds));

/// Create a copy of TaskData
/// with the given fields replaced by the non-null parameter values.
Expand All @@ -3039,7 +3066,8 @@ abstract class _TaskData implements TaskData {
required final List<TaskStatus> statusHistory,
required final String title,
final DateTime? due,
final Duration? estimate}) = _$TaskDataImpl;
final Duration? estimate,
final List<String>? checklistIds}) = _$TaskDataImpl;

factory _TaskData.fromJson(Map<String, dynamic> json) =
_$TaskDataImpl.fromJson;
Expand All @@ -3058,6 +3086,8 @@ abstract class _TaskData implements TaskData {
DateTime? get due;
@override
Duration? get estimate;
@override
List<String>? get checklistIds;

/// Create a copy of TaskData
/// with the given fields replaced by the non-null parameter values.
Expand Down
4 changes: 4 additions & 0 deletions lib/classes/task.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion lib/features/journal/ui/widgets/entry_details_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:lotti/features/journal/ui/widgets/entry_image_widget.dart';
import 'package:lotti/features/journal/ui/widgets/journal_card.dart';
import 'package:lotti/features/journal/ui/widgets/tags/tags_list_widget.dart';
import 'package:lotti/features/speech/ui/widgets/audio_player.dart';
import 'package:lotti/features/tasks/ui/checklist_widget.dart';
import 'package:lotti/features/tasks/ui/task_form.dart';
import 'package:lotti/widgets/events/event_form.dart';

Expand Down Expand Up @@ -136,6 +137,7 @@ class EntryDetailsContent extends ConsumerWidget {
event: (_) => const SizedBox.shrink(),
quantitative: (_) => const SizedBox.shrink(),
workout: (_) => const SizedBox.shrink(),
checklist: (_) => const SizedBox.shrink(),
orElse: () {
return EditorWidget(
entryId: itemId,
Expand All @@ -162,7 +164,9 @@ class EntryDetailsContent extends ConsumerWidget {
),
journalEntry: (_) => const SizedBox.shrink(),
journalImage: (_) => const SizedBox.shrink(),
checklist: (_) => const SizedBox.shrink(),
checklist: (checklist) => ChecklistWrapper(
entryId: checklist.meta.id,
),
checklistItem: (_) => const SizedBox.shrink(),
),
EntryDetailFooter(
Expand Down
Loading

0 comments on commit 8a84064

Please sign in to comment.