feat: enhance admin and profile repositories with token handling; update dropdown initial values in various screens
This commit is contained in:
@@ -16,6 +16,18 @@ class _IntNotifier extends Notifier<int> {
|
||||
final int _initial;
|
||||
@override
|
||||
int build() => _initial;
|
||||
|
||||
void increment() {
|
||||
state = state + 1;
|
||||
}
|
||||
|
||||
void decrement() {
|
||||
state = state - 1;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
final mealPlanWeekOffsetProvider =
|
||||
|
||||
@@ -19,7 +19,7 @@ class MealPlanRepository {
|
||||
message: 'Ogiltigt svar från servern.',
|
||||
);
|
||||
}
|
||||
return (data as List)
|
||||
return data
|
||||
.map((item) => MealPlanEntry.fromJson(item as Map<String, dynamic>))
|
||||
.toList();
|
||||
} on ApiException {
|
||||
@@ -41,7 +41,7 @@ class MealPlanRepository {
|
||||
message: 'Ogiltigt svar från servern.',
|
||||
);
|
||||
}
|
||||
return (data as List)
|
||||
return data
|
||||
.map((item) => ShoppingItem.fromJson(item as Map<String, dynamic>))
|
||||
.toList();
|
||||
} on ApiException {
|
||||
@@ -63,7 +63,7 @@ class MealPlanRepository {
|
||||
message: 'Ogiltigt svar från servern.',
|
||||
);
|
||||
}
|
||||
return (data as List)
|
||||
return data
|
||||
.map((item) => InventoryCompareItem.fromJson(item as Map<String, dynamic>))
|
||||
.toList();
|
||||
} on ApiException {
|
||||
|
||||
@@ -114,19 +114,19 @@ class _MealPlanScreenState extends ConsumerState<MealPlanScreen> {
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
OutlinedButton.icon(
|
||||
onPressed: () => ref.read(mealPlanWeekOffsetProvider.notifier).state--,
|
||||
onPressed: () => ref.read(mealPlanWeekOffsetProvider.notifier).decrement(),
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
label: Text(l10n.mealPlanWeekPrevious),
|
||||
),
|
||||
Chip(label: Text(weekLabel)),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () => ref.read(mealPlanWeekOffsetProvider.notifier).state++,
|
||||
onPressed: () => ref.read(mealPlanWeekOffsetProvider.notifier).increment(),
|
||||
icon: const Icon(Icons.chevron_right),
|
||||
label: Text(l10n.mealPlanWeekNext),
|
||||
),
|
||||
if (ref.watch(mealPlanWeekOffsetProvider) != 0)
|
||||
TextButton(
|
||||
onPressed: () => ref.read(mealPlanWeekOffsetProvider.notifier).state = 0,
|
||||
onPressed: () => ref.read(mealPlanWeekOffsetProvider.notifier).reset(),
|
||||
child: Text(l10n.mealPlanWeekCurrent),
|
||||
),
|
||||
],
|
||||
@@ -203,7 +203,7 @@ class _DayCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
DropdownButtonFormField<String>(
|
||||
value: selectedValue,
|
||||
initialValue: selectedValue,
|
||||
isExpanded: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.mealPlanSelectRecipe,
|
||||
@@ -248,7 +248,7 @@ class _DayCard extends StatelessWidget {
|
||||
SizedBox(
|
||||
width: 220,
|
||||
child: DropdownButtonFormField<int>(
|
||||
value: currentServings,
|
||||
initialValue: currentServings,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.mealPlanServingsLabel,
|
||||
border: const OutlineInputBorder(),
|
||||
|
||||
Reference in New Issue
Block a user