Compare commits
No commits in common. "master" and "prepare_v1.0.5" have entirely different histories.
master
...
prepare_v1
@ -27,8 +27,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
|||||||
var newList = await storage.getEntriesForDate(event.forDate);
|
var newList = await storage.getEntriesForDate(event.forDate);
|
||||||
state.foodEntries.addAll({event.forDate: newList});
|
state.foodEntries.addAll({event.forDate: newList});
|
||||||
|
|
||||||
emit(GlobalEntryState(
|
emit(GlobalEntryState(foodEntries: state.foodEntries));
|
||||||
foodEntries: state.foodEntries, stateChangedForDate: event.forDate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleFoodEntryEvent(
|
void handleFoodEntryEvent(
|
||||||
@ -44,8 +43,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
|||||||
var newFoodEntries = state.foodEntries;
|
var newFoodEntries = state.foodEntries;
|
||||||
newFoodEntries.addAll({event.forDate: entriesForDate});
|
newFoodEntries.addAll({event.forDate: entriesForDate});
|
||||||
|
|
||||||
emit(GlobalEntryState(
|
emit(GlobalEntryState(foodEntries: newFoodEntries));
|
||||||
foodEntries: newFoodEntries, stateChangedForDate: event.forDate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleFoodChangedEvent(
|
void handleFoodChangedEvent(
|
||||||
@ -66,8 +64,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
|||||||
var newFoodEntries = state.foodEntries;
|
var newFoodEntries = state.foodEntries;
|
||||||
newFoodEntries.addAll({event.forDate: entriesForDate});
|
newFoodEntries.addAll({event.forDate: entriesForDate});
|
||||||
|
|
||||||
emit(GlobalEntryState(
|
emit(GlobalEntryState(foodEntries: newFoodEntries));
|
||||||
foodEntries: newFoodEntries, stateChangedForDate: event.forDate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleDeleteFoodEvent(
|
void handleDeleteFoodEvent(
|
||||||
@ -82,8 +79,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
|||||||
var newFoodEntries = state.foodEntries;
|
var newFoodEntries = state.foodEntries;
|
||||||
newFoodEntries.addAll({event.forDate: entriesForDate});
|
newFoodEntries.addAll({event.forDate: entriesForDate});
|
||||||
|
|
||||||
emit(GlobalEntryState(
|
emit(GlobalEntryState(foodEntries: newFoodEntries));
|
||||||
foodEntries: newFoodEntries, stateChangedForDate: event.forDate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleBarcodeScannedEvent(
|
void handleBarcodeScannedEvent(
|
||||||
@ -95,7 +91,6 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
|||||||
if (e.code == BarcodeScanner.cameraAccessDenied) {
|
if (e.code == BarcodeScanner.cameraAccessDenied) {
|
||||||
emit(GlobalEntryState(
|
emit(GlobalEntryState(
|
||||||
foodEntries: state.foodEntries,
|
foodEntries: state.foodEntries,
|
||||||
stateChangedForDate: event.forDate,
|
|
||||||
appError:
|
appError:
|
||||||
GlobalAppError(GlobalAppErrorType.errCameraPermissionDenied)));
|
GlobalAppError(GlobalAppErrorType.errCameraPermissionDenied)));
|
||||||
}
|
}
|
||||||
@ -112,7 +107,6 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
|||||||
if (scanResult.type == ResultType.Error) {
|
if (scanResult.type == ResultType.Error) {
|
||||||
emit(GlobalEntryState(
|
emit(GlobalEntryState(
|
||||||
foodEntries: state.foodEntries,
|
foodEntries: state.foodEntries,
|
||||||
stateChangedForDate: event.forDate,
|
|
||||||
appError: GlobalAppError(GlobalAppErrorType.errGeneralError)));
|
appError: GlobalAppError(GlobalAppErrorType.errGeneralError)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -128,10 +122,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
|||||||
|
|
||||||
entriesForDate.add(newEntryWaiting);
|
entriesForDate.add(newEntryWaiting);
|
||||||
state.foodEntries.addAll({event.forDate: entriesForDate});
|
state.foodEntries.addAll({event.forDate: entriesForDate});
|
||||||
emit(GlobalEntryState(
|
emit(GlobalEntryState(foodEntries: state.foodEntries));
|
||||||
foodEntries: state.foodEntries,
|
|
||||||
stateChangedForDate: event.forDate,
|
|
||||||
));
|
|
||||||
|
|
||||||
await responseFuture.then((response) async {
|
await responseFuture.then((response) async {
|
||||||
var index = entriesForDate
|
var index = entriesForDate
|
||||||
@ -149,7 +140,6 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
|||||||
|
|
||||||
emit(GlobalEntryState(
|
emit(GlobalEntryState(
|
||||||
foodEntries: newFoodEntries,
|
foodEntries: newFoodEntries,
|
||||||
stateChangedForDate: event.forDate,
|
|
||||||
appError: GlobalAppError(GlobalAppErrorType.errbarcodeNotFound)));
|
appError: GlobalAppError(GlobalAppErrorType.errbarcodeNotFound)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -161,7 +151,6 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
|||||||
|
|
||||||
emit(GlobalEntryState(
|
emit(GlobalEntryState(
|
||||||
foodEntries: newFoodEntries,
|
foodEntries: newFoodEntries,
|
||||||
stateChangedForDate: event.forDate,
|
|
||||||
appError:
|
appError:
|
||||||
GlobalAppError(GlobalAppErrorType.errServerNotReachable)));
|
GlobalAppError(GlobalAppErrorType.errServerNotReachable)));
|
||||||
return;
|
return;
|
||||||
@ -184,8 +173,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
|||||||
var newFoodEntries = state.foodEntries;
|
var newFoodEntries = state.foodEntries;
|
||||||
newFoodEntries.addAll({event.forDate: entriesForDate});
|
newFoodEntries.addAll({event.forDate: entriesForDate});
|
||||||
|
|
||||||
emit(GlobalEntryState(
|
emit(GlobalEntryState(foodEntries: newFoodEntries));
|
||||||
foodEntries: newFoodEntries, stateChangedForDate: event.forDate));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,8 +194,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
|||||||
|
|
||||||
selectedEntry.isSelected = !oldStateOfTappedEntry;
|
selectedEntry.isSelected = !oldStateOfTappedEntry;
|
||||||
|
|
||||||
emit(GlobalEntryState(
|
emit(GlobalEntryState(foodEntries: state.foodEntries));
|
||||||
foodEntries: state.foodEntries, stateChangedForDate: event.forDate));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,17 +240,12 @@ class PermissionException extends FoodEvent {
|
|||||||
PermissionException({required super.forDate});
|
PermissionException({required super.forDate});
|
||||||
}
|
}
|
||||||
|
|
||||||
class PageEntryState {}
|
/// This is the state for one date/page
|
||||||
|
|
||||||
class GlobalEntryState {
|
class GlobalEntryState {
|
||||||
final Map<DateTime, List<FoodEntryState>> foodEntries;
|
final Map<DateTime, List<FoodEntryState>> foodEntries;
|
||||||
final GlobalAppError? appError;
|
final GlobalAppError? appError;
|
||||||
|
|
||||||
//we use this to only redraw pages whose entries changed
|
GlobalEntryState({required this.foodEntries, this.appError});
|
||||||
final DateTime? stateChangedForDate;
|
|
||||||
|
|
||||||
GlobalEntryState(
|
|
||||||
{required this.foodEntries, this.stateChangedForDate, this.appError});
|
|
||||||
|
|
||||||
factory GlobalEntryState.init() {
|
factory GlobalEntryState.init() {
|
||||||
return GlobalEntryState(foodEntries: {});
|
return GlobalEntryState(foodEntries: {});
|
||||||
|
@ -92,9 +92,10 @@ class PerDatePageViewController extends StatelessWidget {
|
|||||||
onDateSelected: (dateSelected) {
|
onDateSelected: (dateSelected) {
|
||||||
if (dateSelected == null) return;
|
if (dateSelected == null) return;
|
||||||
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
var dateDiff = dateSelected.difference(initialDate).inDays;
|
||||||
builder: (context) =>
|
|
||||||
PerDatePageViewController(initialDate: dateSelected)));
|
log("dateDiff = $dateDiff");
|
||||||
|
pageController.jumpToPage(initialOffset - dateDiff);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -33,11 +33,6 @@ class _PerDateWidgetState extends State<PerDateWidget>
|
|||||||
showNewSnackbarWith(context, pageState.appError!);
|
showNewSnackbarWith(context, pageState.appError!);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
buildWhen: (previous, current) {
|
|
||||||
if (current.stateChangedForDate == null) return true;
|
|
||||||
if (current.stateChangedForDate == widget.date) return true;
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
builder: (context, pageState) {
|
builder: (context, pageState) {
|
||||||
return FoodEntryList(
|
return FoodEntryList(
|
||||||
entries: pageState.foodEntries[widget.date] ?? [],
|
entries: pageState.foodEntries[widget.date] ?? [],
|
||||||
|
13
pubspec.lock
13
pubspec.lock
@ -290,6 +290,11 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_web_plugins:
|
||||||
|
dependency: transitive
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
frontend_server_client:
|
frontend_server_client:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -311,6 +316,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.2"
|
||||||
|
go_router:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: go_router
|
||||||
|
sha256: "2fd11229f59e23e967b0775df8d5948a519cd7e1e8b6e849729e010587b46539"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "14.6.2"
|
||||||
graphs:
|
graphs:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -19,6 +19,7 @@ dependencies:
|
|||||||
barcode_scan2: ^4.3.3
|
barcode_scan2: ^4.3.3
|
||||||
provider: ^6.1.2
|
provider: ^6.1.2
|
||||||
test: ^1.25.7
|
test: ^1.25.7
|
||||||
|
go_router: ^14.6.2
|
||||||
path_provider_platform_interface: ^2.1.2
|
path_provider_platform_interface: ^2.1.2
|
||||||
plugin_platform_interface: ^2.1.8
|
plugin_platform_interface: ^2.1.8
|
||||||
http: ^1.2.2
|
http: ^1.2.2
|
||||||
|
Loading…
Reference in New Issue
Block a user