feat: add utility functions for date and quantity formatting; refactor inventory and recipe screens to use new formatters
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../core/api/api_error_mapper.dart';
|
||||
import '../../../core/api/api_exception.dart';
|
||||
import '../../../core/utils/formatters.dart';
|
||||
import '../../../core/l10n/l10n.dart';
|
||||
import '../../auth/data/auth_providers.dart';
|
||||
import '../data/recipe_providers.dart';
|
||||
@@ -305,11 +306,7 @@ class _CreateRecipeScreenState extends ConsumerState<CreateRecipeScreen> {
|
||||
}
|
||||
|
||||
Widget _buildIngredientRow(int index, ParsedIngredient ing) {
|
||||
final qtyStr = ing.quantity > 0
|
||||
? (ing.quantity == ing.quantity.truncateToDouble()
|
||||
? '${ing.quantity.toInt()} '
|
||||
: '${ing.quantity} ')
|
||||
: '';
|
||||
final qtyStr = ing.quantity > 0 ? '${formatQuantity(ing.quantity)} ' : '';
|
||||
final unitStr = ing.unit.isNotEmpty ? '${ing.unit} ' : '';
|
||||
final noteStr = ing.note != null ? ' (${ing.note})' : '';
|
||||
final label = '$qtyStr$unitStr${ing.rawName}$noteStr';
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../core/api/api_error_mapper.dart';
|
||||
import '../../../core/api/api_exception.dart';
|
||||
import '../../../core/utils/formatters.dart';
|
||||
import '../../../core/auth/jwt_decoder.dart';
|
||||
import '../../../core/l10n/l10n.dart';
|
||||
import '../../../core/ui/async_state_views.dart';
|
||||
@@ -12,8 +13,7 @@ import '../data/recipe_providers.dart';
|
||||
import '../domain/recipe.dart';
|
||||
import '../domain/inventory_preview.dart';
|
||||
|
||||
String _fmtQty(double v) =>
|
||||
v == v.truncateToDouble() ? v.toInt().toString() : v.toString();
|
||||
String _fmtQty(double v) => formatQuantity(v);
|
||||
|
||||
enum _ShareAction { share, unshare }
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../core/api/api_error_mapper.dart';
|
||||
import '../../../core/api/api_exception.dart';
|
||||
import '../../../core/utils/formatters.dart';
|
||||
import '../../../core/api/api_paths.dart';
|
||||
import '../../../core/api/api_providers.dart';
|
||||
import '../../../core/forms/form_options.dart';
|
||||
@@ -31,13 +32,10 @@ class _EditableIngredient {
|
||||
noteCtrl = TextEditingController(text: note);
|
||||
|
||||
factory _EditableIngredient.fromRecipe(RecipeIngredient ingredient) {
|
||||
final quantity = ingredient.quantity == ingredient.quantity.truncateToDouble()
|
||||
? ingredient.quantity.toInt().toString()
|
||||
: ingredient.quantity.toString();
|
||||
return _EditableIngredient(
|
||||
productId: ingredient.productId,
|
||||
productName: ingredient.productName,
|
||||
quantity: quantity,
|
||||
quantity: formatQuantity(ingredient.quantity),
|
||||
unit: ingredient.unit,
|
||||
note: ingredient.note ?? '',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user