Skip to content

Commit

Permalink
fix: minor ui issues
Browse files Browse the repository at this point in the history
  • Loading branch information
TomBursch committed Sep 20, 2022
1 parent b11f475 commit 988eff1
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
}
},
"addRecipeToPlanner": "Zum Essensplan hinzufügen",
"addRecipeToPlannerShort": "Hinzufügen",
"address": "Adresse",
"addTag": "Add Tag",
"admin": "Admin",
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
}
},
"addRecipeToPlanner": "Add to meal plan",
"addRecipeToPlannerShort": "Add to meal plan",
"address": "Address",
"addTag": "Add Tag",
"admin": "Admin",
Expand Down
1 change: 1 addition & 0 deletions lib/pages/home_page/shoppinglist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class _ShoppinglistPageState extends State<ShoppinglistPage> {
cubit.add(item.name, item.description),
categories: state.categories,
onRefresh: cubit.refresh,
isDescriptionEditable: false,
isLoading: state is LoadingShoppinglistCubitState,
isList: state.style == ShoppinglistStyle.list,
),
Expand Down
21 changes: 16 additions & 5 deletions lib/pages/item_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ import 'package:kitchenowl/widgets/recipe_item.dart';
class ItemPage<T extends Item> extends StatefulWidget {
final T item;
final List<Category> categories;
final bool isDescriptionEditable;

const ItemPage({Key? key, required this.item, this.categories = const []})
: super(key: key);
const ItemPage({
super.key,
required this.item,
this.categories = const [],
this.isDescriptionEditable = true,
});

@override
_ItemPageState createState() => _ItemPageState<T>();
Expand Down Expand Up @@ -89,7 +94,8 @@ class _ItemPageState<T extends Item> extends State<ItemPage<T>> {
onRefresh: cubit.refresh,
child: CustomScrollView(
slivers: [
if (widget.item is ItemWithDescription)
if (widget.isDescriptionEditable &&
widget.item is ItemWithDescription)
SliverPadding(
padding: const EdgeInsets.all(16),
sliver: SliverToBoxAdapter(
Expand Down Expand Up @@ -122,7 +128,10 @@ class _ItemPageState<T extends Item> extends State<ItemPage<T>> {
if (widget.item is! RecipeItem)
SliverPadding(
padding: EdgeInsets.only(
top: (widget.item is ItemWithDescription) ? 0 : 16,
top: (widget.isDescriptionEditable &&
widget.item is ItemWithDescription)
? 0
: 16,
bottom: 16,
left: 16,
right: 16,
Expand Down Expand Up @@ -208,7 +217,9 @@ class _ItemPageState<T extends Item> extends State<ItemPage<T>> {
: null,
);
},
childCount: state.recipes.length + 1,
childCount: state.recipes.isEmpty
? 0
: state.recipes.length + 1,
),
),
);
Expand Down
1 change: 0 additions & 1 deletion lib/services/storage/storage.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:shared_preferences/shared_preferences.dart';

Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/recipe_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ class RecipeCard extends StatelessWidget {
),
onPressed: onLongPressed,
child: Text(
AppLocalizations.of(context)!.addRecipeToPlanner,
AppLocalizations.of(context)!
.addRecipeToPlannerShort,
),
),
],
Expand Down
3 changes: 3 additions & 0 deletions lib/widgets/sliver_item_grid_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SliverItemGridList<T extends Item> extends StatelessWidget {
final bool isList;
final bool Function(T)? selected;
final bool isLoading;
final bool isDescriptionEditable;

const SliverItemGridList({
super.key,
Expand All @@ -28,6 +29,7 @@ class SliverItemGridList<T extends Item> extends StatelessWidget {
this.isList = false,
this.selected,
this.isLoading = false,
this.isDescriptionEditable = true,
});

@override
Expand Down Expand Up @@ -67,6 +69,7 @@ class SliverItemGridList<T extends Item> extends StatelessWidget {
builder: (BuildContext context) => ItemPage(
item: item,
categories: categories ?? const [],
isDescriptionEditable: isDescriptionEditable,
),
),
);
Expand Down

0 comments on commit 988eff1

Please sign in to comment.