diff --git a/lib/features/feed/presentation/widgets/tags_modal_widget.dart b/lib/features/feed/presentation/widgets/tags_modal_widget.dart index 724f91a8..5d66b330 100644 --- a/lib/features/feed/presentation/widgets/tags_modal_widget.dart +++ b/lib/features/feed/presentation/widgets/tags_modal_widget.dart @@ -51,7 +51,6 @@ class _TagsModalWidgetState extends State { borderRadius: BorderRadius.circular(16), ), padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), - label: Text(tag.name), labelStyle: TextStyle( color: isSelected ? Colors.white : appTheme.gray600, fontWeight: FontWeight.w500, @@ -60,6 +59,9 @@ class _TagsModalWidgetState extends State { selected: isSelected, backgroundColor: appTheme.gray100, onSelected: (bool selected) => context.read().updateTags(tag), + label: Text( + '${tag.name} ${tag.recipesCount}', + ), ); } } diff --git a/lib/features/recipes/models/recipe_tag_model.dart b/lib/features/recipes/models/recipe_tag_model.dart index 8cd13054..004f4f29 100644 --- a/lib/features/recipes/models/recipe_tag_model.dart +++ b/lib/features/recipes/models/recipe_tag_model.dart @@ -20,6 +20,7 @@ class RecipeTag with _$RecipeTag { const factory RecipeTag({ @JsonKey(name: "id") required int id, @JsonKey(name: "name") required String name, + @JsonKey(name: "recipes_count") required int recipesCount, @JsonKey(name: "created_at") required DateTime createdAt, @JsonKey(name: "updated_at") required DateTime updatedAt, }) = _RecipeTag; diff --git a/lib/features/recipes/models/recipe_tag_model.freezed.dart b/lib/features/recipes/models/recipe_tag_model.freezed.dart index db917d4a..25970a55 100644 --- a/lib/features/recipes/models/recipe_tag_model.freezed.dart +++ b/lib/features/recipes/models/recipe_tag_model.freezed.dart @@ -246,6 +246,8 @@ mixin _$RecipeTag { int get id => throw _privateConstructorUsedError; @JsonKey(name: "name") String get name => throw _privateConstructorUsedError; + @JsonKey(name: "recipes_count") + int get recipesCount => throw _privateConstructorUsedError; @JsonKey(name: "created_at") DateTime get createdAt => throw _privateConstructorUsedError; @JsonKey(name: "updated_at") @@ -265,6 +267,7 @@ abstract class $RecipeTagCopyWith<$Res> { $Res call( {@JsonKey(name: "id") int id, @JsonKey(name: "name") String name, + @JsonKey(name: "recipes_count") int recipesCount, @JsonKey(name: "created_at") DateTime createdAt, @JsonKey(name: "updated_at") DateTime updatedAt}); } @@ -284,6 +287,7 @@ class _$RecipeTagCopyWithImpl<$Res, $Val extends RecipeTag> $Res call({ Object? id = null, Object? name = null, + Object? recipesCount = null, Object? createdAt = null, Object? updatedAt = null, }) { @@ -296,6 +300,10 @@ class _$RecipeTagCopyWithImpl<$Res, $Val extends RecipeTag> ? _value.name : name // ignore: cast_nullable_to_non_nullable as String, + recipesCount: null == recipesCount + ? _value.recipesCount + : recipesCount // ignore: cast_nullable_to_non_nullable + as int, createdAt: null == createdAt ? _value.createdAt : createdAt // ignore: cast_nullable_to_non_nullable @@ -319,6 +327,7 @@ abstract class _$$RecipeTagImplCopyWith<$Res> $Res call( {@JsonKey(name: "id") int id, @JsonKey(name: "name") String name, + @JsonKey(name: "recipes_count") int recipesCount, @JsonKey(name: "created_at") DateTime createdAt, @JsonKey(name: "updated_at") DateTime updatedAt}); } @@ -336,6 +345,7 @@ class __$$RecipeTagImplCopyWithImpl<$Res> $Res call({ Object? id = null, Object? name = null, + Object? recipesCount = null, Object? createdAt = null, Object? updatedAt = null, }) { @@ -348,6 +358,10 @@ class __$$RecipeTagImplCopyWithImpl<$Res> ? _value.name : name // ignore: cast_nullable_to_non_nullable as String, + recipesCount: null == recipesCount + ? _value.recipesCount + : recipesCount // ignore: cast_nullable_to_non_nullable + as int, createdAt: null == createdAt ? _value.createdAt : createdAt // ignore: cast_nullable_to_non_nullable @@ -366,6 +380,7 @@ class _$RecipeTagImpl implements _RecipeTag { const _$RecipeTagImpl( {@JsonKey(name: "id") required this.id, @JsonKey(name: "name") required this.name, + @JsonKey(name: "recipes_count") required this.recipesCount, @JsonKey(name: "created_at") required this.createdAt, @JsonKey(name: "updated_at") required this.updatedAt}); @@ -379,6 +394,9 @@ class _$RecipeTagImpl implements _RecipeTag { @JsonKey(name: "name") final String name; @override + @JsonKey(name: "recipes_count") + final int recipesCount; + @override @JsonKey(name: "created_at") final DateTime createdAt; @override @@ -387,7 +405,7 @@ class _$RecipeTagImpl implements _RecipeTag { @override String toString() { - return 'RecipeTag(id: $id, name: $name, createdAt: $createdAt, updatedAt: $updatedAt)'; + return 'RecipeTag(id: $id, name: $name, recipesCount: $recipesCount, createdAt: $createdAt, updatedAt: $updatedAt)'; } @override @@ -397,6 +415,8 @@ class _$RecipeTagImpl implements _RecipeTag { other is _$RecipeTagImpl && (identical(other.id, id) || other.id == id) && (identical(other.name, name) || other.name == name) && + (identical(other.recipesCount, recipesCount) || + other.recipesCount == recipesCount) && (identical(other.createdAt, createdAt) || other.createdAt == createdAt) && (identical(other.updatedAt, updatedAt) || @@ -405,7 +425,8 @@ class _$RecipeTagImpl implements _RecipeTag { @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, name, createdAt, updatedAt); + int get hashCode => + Object.hash(runtimeType, id, name, recipesCount, createdAt, updatedAt); @JsonKey(ignore: true) @override @@ -425,6 +446,7 @@ abstract class _RecipeTag implements RecipeTag { const factory _RecipeTag( {@JsonKey(name: "id") required final int id, @JsonKey(name: "name") required final String name, + @JsonKey(name: "recipes_count") required final int recipesCount, @JsonKey(name: "created_at") required final DateTime createdAt, @JsonKey(name: "updated_at") required final DateTime updatedAt}) = _$RecipeTagImpl; @@ -439,6 +461,9 @@ abstract class _RecipeTag implements RecipeTag { @JsonKey(name: "name") String get name; @override + @JsonKey(name: "recipes_count") + int get recipesCount; + @override @JsonKey(name: "created_at") DateTime get createdAt; @override diff --git a/lib/features/recipes/models/recipe_tag_model.g.dart b/lib/features/recipes/models/recipe_tag_model.g.dart index 6ab2a853..cd387547 100644 --- a/lib/features/recipes/models/recipe_tag_model.g.dart +++ b/lib/features/recipes/models/recipe_tag_model.g.dart @@ -27,6 +27,7 @@ _$RecipeTagImpl _$$RecipeTagImplFromJson(Map json) => _$RecipeTagImpl( id: (json['id'] as num).toInt(), name: json['name'] as String, + recipesCount: (json['recipes_count'] as num).toInt(), createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), ); @@ -35,6 +36,7 @@ Map _$$RecipeTagImplToJson(_$RecipeTagImpl instance) => { 'id': instance.id, 'name': instance.name, + 'recipes_count': instance.recipesCount, 'created_at': instance.createdAt.toIso8601String(), 'updated_at': instance.updatedAt.toIso8601String(), };