Compare commits
6 Commits
home-butto
...
master
Author | SHA1 | Date | |
---|---|---|---|
a3eb907a8e | |||
7728ec3b66 | |||
7126b1b593 | |||
e1fdefe979 | |||
435ad4e618 | |||
0aca111cb5 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -42,3 +42,5 @@ app.*.map.json
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
assets/icon_base.xcf
|
||||
|
||||
/metadata/**/*.xcf
|
||||
|
@ -34,8 +34,8 @@ android {
|
||||
applicationId = "de.swgross.calorimeter"
|
||||
minSdk = flutter.minSdkVersion
|
||||
targetSdk = flutter.targetSdkVersion
|
||||
versionCode = 4
|
||||
versionName = "1.0.4"
|
||||
versionCode = 5
|
||||
versionName = "1.0.5"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
|
@ -27,7 +27,8 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
||||
var newList = await storage.getEntriesForDate(event.forDate);
|
||||
state.foodEntries.addAll({event.forDate: newList});
|
||||
|
||||
emit(GlobalEntryState(foodEntries: state.foodEntries));
|
||||
emit(GlobalEntryState(
|
||||
foodEntries: state.foodEntries, stateChangedForDate: event.forDate));
|
||||
}
|
||||
|
||||
void handleFoodEntryEvent(
|
||||
@ -43,7 +44,8 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
||||
var newFoodEntries = state.foodEntries;
|
||||
newFoodEntries.addAll({event.forDate: entriesForDate});
|
||||
|
||||
emit(GlobalEntryState(foodEntries: newFoodEntries));
|
||||
emit(GlobalEntryState(
|
||||
foodEntries: newFoodEntries, stateChangedForDate: event.forDate));
|
||||
}
|
||||
|
||||
void handleFoodChangedEvent(
|
||||
@ -64,7 +66,8 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
||||
var newFoodEntries = state.foodEntries;
|
||||
newFoodEntries.addAll({event.forDate: entriesForDate});
|
||||
|
||||
emit(GlobalEntryState(foodEntries: newFoodEntries));
|
||||
emit(GlobalEntryState(
|
||||
foodEntries: newFoodEntries, stateChangedForDate: event.forDate));
|
||||
}
|
||||
|
||||
void handleDeleteFoodEvent(
|
||||
@ -79,7 +82,8 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
||||
var newFoodEntries = state.foodEntries;
|
||||
newFoodEntries.addAll({event.forDate: entriesForDate});
|
||||
|
||||
emit(GlobalEntryState(foodEntries: newFoodEntries));
|
||||
emit(GlobalEntryState(
|
||||
foodEntries: newFoodEntries, stateChangedForDate: event.forDate));
|
||||
}
|
||||
|
||||
void handleBarcodeScannedEvent(
|
||||
@ -91,6 +95,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
||||
if (e.code == BarcodeScanner.cameraAccessDenied) {
|
||||
emit(GlobalEntryState(
|
||||
foodEntries: state.foodEntries,
|
||||
stateChangedForDate: event.forDate,
|
||||
appError:
|
||||
GlobalAppError(GlobalAppErrorType.errCameraPermissionDenied)));
|
||||
}
|
||||
@ -107,6 +112,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
||||
if (scanResult.type == ResultType.Error) {
|
||||
emit(GlobalEntryState(
|
||||
foodEntries: state.foodEntries,
|
||||
stateChangedForDate: event.forDate,
|
||||
appError: GlobalAppError(GlobalAppErrorType.errGeneralError)));
|
||||
return;
|
||||
}
|
||||
@ -122,7 +128,10 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
||||
|
||||
entriesForDate.add(newEntryWaiting);
|
||||
state.foodEntries.addAll({event.forDate: entriesForDate});
|
||||
emit(GlobalEntryState(foodEntries: state.foodEntries));
|
||||
emit(GlobalEntryState(
|
||||
foodEntries: state.foodEntries,
|
||||
stateChangedForDate: event.forDate,
|
||||
));
|
||||
|
||||
await responseFuture.then((response) async {
|
||||
var index = entriesForDate
|
||||
@ -140,6 +149,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
||||
|
||||
emit(GlobalEntryState(
|
||||
foodEntries: newFoodEntries,
|
||||
stateChangedForDate: event.forDate,
|
||||
appError: GlobalAppError(GlobalAppErrorType.errbarcodeNotFound)));
|
||||
return;
|
||||
}
|
||||
@ -151,6 +161,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
||||
|
||||
emit(GlobalEntryState(
|
||||
foodEntries: newFoodEntries,
|
||||
stateChangedForDate: event.forDate,
|
||||
appError:
|
||||
GlobalAppError(GlobalAppErrorType.errServerNotReachable)));
|
||||
return;
|
||||
@ -173,7 +184,8 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
||||
var newFoodEntries = state.foodEntries;
|
||||
newFoodEntries.addAll({event.forDate: entriesForDate});
|
||||
|
||||
emit(GlobalEntryState(foodEntries: newFoodEntries));
|
||||
emit(GlobalEntryState(
|
||||
foodEntries: newFoodEntries, stateChangedForDate: event.forDate));
|
||||
});
|
||||
}
|
||||
|
||||
@ -194,7 +206,8 @@ class FoodEntryBloc extends Bloc<FoodEvent, GlobalEntryState> {
|
||||
|
||||
selectedEntry.isSelected = !oldStateOfTappedEntry;
|
||||
|
||||
emit(GlobalEntryState(foodEntries: state.foodEntries));
|
||||
emit(GlobalEntryState(
|
||||
foodEntries: state.foodEntries, stateChangedForDate: event.forDate));
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,12 +253,17 @@ class PermissionException extends FoodEvent {
|
||||
PermissionException({required super.forDate});
|
||||
}
|
||||
|
||||
/// This is the state for one date/page
|
||||
class PageEntryState {}
|
||||
|
||||
class GlobalEntryState {
|
||||
final Map<DateTime, List<FoodEntryState>> foodEntries;
|
||||
final GlobalAppError? appError;
|
||||
|
||||
GlobalEntryState({required this.foodEntries, this.appError});
|
||||
//we use this to only redraw pages whose entries changed
|
||||
final DateTime? stateChangedForDate;
|
||||
|
||||
GlobalEntryState(
|
||||
{required this.foodEntries, this.stateChangedForDate, this.appError});
|
||||
|
||||
factory GlobalEntryState.init() {
|
||||
return GlobalEntryState(foodEntries: {});
|
||||
|
@ -92,10 +92,9 @@ class PerDatePageViewController extends StatelessWidget {
|
||||
onDateSelected: (dateSelected) {
|
||||
if (dateSelected == null) return;
|
||||
|
||||
var dateDiff = dateSelected.difference(initialDate).inDays;
|
||||
|
||||
log("dateDiff = $dateDiff");
|
||||
pageController.jumpToPage(initialOffset - dateDiff);
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
PerDatePageViewController(initialDate: dateSelected)));
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -33,6 +33,11 @@ class _PerDateWidgetState extends State<PerDateWidget>
|
||||
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) {
|
||||
return FoodEntryList(
|
||||
entries: pageState.foodEntries[widget.date] ?? [],
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 93 KiB |
Binary file not shown.
After Width: | Height: | Size: 94 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.5 MiB |
Binary file not shown.
Before Width: | Height: | Size: 98 KiB |
Binary file not shown.
Before Width: | Height: | Size: 97 KiB |
13
pubspec.lock
13
pubspec.lock
@ -290,11 +290,6 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
frontend_server_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -316,14 +311,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -19,7 +19,6 @@ dependencies:
|
||||
barcode_scan2: ^4.3.3
|
||||
provider: ^6.1.2
|
||||
test: ^1.25.7
|
||||
go_router: ^14.6.2
|
||||
path_provider_platform_interface: ^2.1.2
|
||||
plugin_platform_interface: ^2.1.8
|
||||
http: ^1.2.2
|
||||
|
Loading…
Reference in New Issue
Block a user