mirror of
https://github.com/immich-app/immich.git
synced 2024-12-17 12:22:31 +02:00
983473261b
* build(mobile): add riverpod_lint * refactor(mobile): riverpod_generator for providers * test(mobile): fix integration test helper * refactor: ApiService to riverpod codegen * refactor(mobile): return curatedcontent instead of people dto * refactor: person provider to asyncnotifier * mobile: update service providers to use lambda * mobile: update scaffoldbody default error icon * remove logger mixin --------- Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
28 lines
800 B
Dart
28 lines
800 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/shared/ui/immich_loading_indicator.dart';
|
|
import 'package:immich_mobile/shared/ui/scaffold_error_body.dart';
|
|
import 'package:logging/logging.dart';
|
|
|
|
extension ScaffoldBody<T> on AsyncValue<T> {
|
|
static final Logger _scaffoldBodyLog = Logger("ScaffoldBody");
|
|
|
|
Widget scaffoldBodyWhen({
|
|
required Widget Function(T data) onData,
|
|
Widget? onError,
|
|
}) {
|
|
if (isLoading) {
|
|
return const Center(
|
|
child: ImmichLoadingIndicator(),
|
|
);
|
|
}
|
|
|
|
if (hasError && !hasValue) {
|
|
_scaffoldBodyLog.severe("Error occured in AsyncValue", error, stackTrace);
|
|
return onError ?? const ScaffoldErrorBody();
|
|
}
|
|
|
|
return onData(requireValue);
|
|
}
|
|
}
|