Skip to content

Commit

Permalink
feat: adapt checklists and checklist items classes
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasn committed Nov 18, 2024
1 parent 9d8001d commit ade09b0
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 38 deletions.
2 changes: 1 addition & 1 deletion lib/classes/checklist_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ part 'checklist_data.g.dart';
class ChecklistData with _$ChecklistData {
const factory ChecklistData({
required String title,
required bool isChecked,
required List<String> linkedChecklistItems,
}) = _ChecklistData;

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

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

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

/// @nodoc
Expand All @@ -98,37 +98,45 @@ class __$$ChecklistDataImplCopyWithImpl<$Res>
@override
$Res call({
Object? title = null,
Object? isChecked = null,
Object? linkedChecklistItems = null,
}) {
return _then(_$ChecklistDataImpl(
title: null == title
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
isChecked: null == isChecked
? _value.isChecked
: isChecked // ignore: cast_nullable_to_non_nullable
as bool,
linkedChecklistItems: null == linkedChecklistItems
? _value._linkedChecklistItems
: linkedChecklistItems // ignore: cast_nullable_to_non_nullable
as List<String>,
));
}
}

/// @nodoc
@JsonSerializable()
class _$ChecklistDataImpl implements _ChecklistData {
const _$ChecklistDataImpl({required this.title, required this.isChecked});
const _$ChecklistDataImpl(
{required this.title, required final List<String> linkedChecklistItems})
: _linkedChecklistItems = linkedChecklistItems;

factory _$ChecklistDataImpl.fromJson(Map<String, dynamic> json) =>
_$$ChecklistDataImplFromJson(json);

@override
final String title;
final List<String> _linkedChecklistItems;
@override
final bool isChecked;
List<String> get linkedChecklistItems {
if (_linkedChecklistItems is EqualUnmodifiableListView)
return _linkedChecklistItems;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_linkedChecklistItems);
}

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

@override
Expand All @@ -137,13 +145,14 @@ class _$ChecklistDataImpl implements _ChecklistData {
(other.runtimeType == runtimeType &&
other is _$ChecklistDataImpl &&
(identical(other.title, title) || other.title == title) &&
(identical(other.isChecked, isChecked) ||
other.isChecked == isChecked));
const DeepCollectionEquality()
.equals(other._linkedChecklistItems, _linkedChecklistItems));
}

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

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

factory _ChecklistData.fromJson(Map<String, dynamic> json) =
_$ChecklistDataImpl.fromJson;

@override
String get title;
@override
bool get isChecked;
List<String> get linkedChecklistItems;

/// Create a copy of ChecklistData
/// with the given fields replaced by the non-null parameter values.
Expand Down
6 changes: 4 additions & 2 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/checklist_item_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ChecklistItemData with _$ChecklistItemData {
const factory ChecklistItemData({
required String title,
required bool isChecked,
required List<String> linkedChecklists,
}) = _ChecklistItemData;

factory ChecklistItemData.fromJson(Map<String, dynamic> json) =>
Expand Down
43 changes: 36 additions & 7 deletions lib/classes/checklist_item_data.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ChecklistItemData _$ChecklistItemDataFromJson(Map<String, dynamic> json) {
mixin _$ChecklistItemData {
String get title => throw _privateConstructorUsedError;
bool get isChecked => throw _privateConstructorUsedError;
List<String> get linkedChecklists => throw _privateConstructorUsedError;

/// Serializes this ChecklistItemData to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
Expand All @@ -39,7 +40,7 @@ abstract class $ChecklistItemDataCopyWith<$Res> {
ChecklistItemData value, $Res Function(ChecklistItemData) then) =
_$ChecklistItemDataCopyWithImpl<$Res, ChecklistItemData>;
@useResult
$Res call({String title, bool isChecked});
$Res call({String title, bool isChecked, List<String> linkedChecklists});
}

/// @nodoc
Expand All @@ -59,6 +60,7 @@ class _$ChecklistItemDataCopyWithImpl<$Res, $Val extends ChecklistItemData>
$Res call({
Object? title = null,
Object? isChecked = null,
Object? linkedChecklists = null,
}) {
return _then(_value.copyWith(
title: null == title
Expand All @@ -69,6 +71,10 @@ class _$ChecklistItemDataCopyWithImpl<$Res, $Val extends ChecklistItemData>
? _value.isChecked
: isChecked // ignore: cast_nullable_to_non_nullable
as bool,
linkedChecklists: null == linkedChecklists
? _value.linkedChecklists
: linkedChecklists // ignore: cast_nullable_to_non_nullable
as List<String>,
) as $Val);
}
}
Expand All @@ -81,7 +87,7 @@ abstract class _$$ChecklistItemDataImplCopyWith<$Res>
__$$ChecklistItemDataImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String title, bool isChecked});
$Res call({String title, bool isChecked, List<String> linkedChecklists});
}

/// @nodoc
Expand All @@ -99,6 +105,7 @@ class __$$ChecklistItemDataImplCopyWithImpl<$Res>
$Res call({
Object? title = null,
Object? isChecked = null,
Object? linkedChecklists = null,
}) {
return _then(_$ChecklistItemDataImpl(
title: null == title
Expand All @@ -109,14 +116,22 @@ class __$$ChecklistItemDataImplCopyWithImpl<$Res>
? _value.isChecked
: isChecked // ignore: cast_nullable_to_non_nullable
as bool,
linkedChecklists: null == linkedChecklists
? _value._linkedChecklists
: linkedChecklists // ignore: cast_nullable_to_non_nullable
as List<String>,
));
}
}

/// @nodoc
@JsonSerializable()
class _$ChecklistItemDataImpl implements _ChecklistItemData {
const _$ChecklistItemDataImpl({required this.title, required this.isChecked});
const _$ChecklistItemDataImpl(
{required this.title,
required this.isChecked,
required final List<String> linkedChecklists})
: _linkedChecklists = linkedChecklists;

factory _$ChecklistItemDataImpl.fromJson(Map<String, dynamic> json) =>
_$$ChecklistItemDataImplFromJson(json);
Expand All @@ -125,10 +140,18 @@ class _$ChecklistItemDataImpl implements _ChecklistItemData {
final String title;
@override
final bool isChecked;
final List<String> _linkedChecklists;
@override
List<String> get linkedChecklists {
if (_linkedChecklists is EqualUnmodifiableListView)
return _linkedChecklists;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_linkedChecklists);
}

@override
String toString() {
return 'ChecklistItemData(title: $title, isChecked: $isChecked)';
return 'ChecklistItemData(title: $title, isChecked: $isChecked, linkedChecklists: $linkedChecklists)';
}

@override
Expand All @@ -138,12 +161,15 @@ class _$ChecklistItemDataImpl implements _ChecklistItemData {
other is _$ChecklistItemDataImpl &&
(identical(other.title, title) || other.title == title) &&
(identical(other.isChecked, isChecked) ||
other.isChecked == isChecked));
other.isChecked == isChecked) &&
const DeepCollectionEquality()
.equals(other._linkedChecklists, _linkedChecklists));
}

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

/// Create a copy of ChecklistItemData
/// with the given fields replaced by the non-null parameter values.
Expand All @@ -165,7 +191,8 @@ class _$ChecklistItemDataImpl implements _ChecklistItemData {
abstract class _ChecklistItemData implements ChecklistItemData {
const factory _ChecklistItemData(
{required final String title,
required final bool isChecked}) = _$ChecklistItemDataImpl;
required final bool isChecked,
required final List<String> linkedChecklists}) = _$ChecklistItemDataImpl;

factory _ChecklistItemData.fromJson(Map<String, dynamic> json) =
_$ChecklistItemDataImpl.fromJson;
Expand All @@ -174,6 +201,8 @@ abstract class _ChecklistItemData implements ChecklistItemData {
String get title;
@override
bool get isChecked;
@override
List<String> get linkedChecklists;

/// Create a copy of ChecklistItemData
/// with the given fields replaced by the non-null parameter values.
Expand Down
4 changes: 4 additions & 0 deletions lib/classes/checklist_item_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/features/ai/state/ollama_prompt_checklist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class AiChecklistResponse extends Notifier<List<ChecklistItemData>> {
// ignore: avoid_dynamic_calls
title: e['title'] as String,
isChecked: false,
linkedChecklists: [],
),
)
.toList();
Expand Down

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

2 changes: 1 addition & 1 deletion lib/features/journal/state/entry_controller.g.dart

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

6 changes: 3 additions & 3 deletions lib/features/sync/state/matrix_login_provider.g.dart

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

2 changes: 1 addition & 1 deletion lib/features/sync/state/matrix_stats_provider.g.dart

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

Loading

0 comments on commit ade09b0

Please sign in to comment.