init
This commit is contained in:
35
lib/shared/widgets/app_status_view.dart
Normal file
35
lib/shared/widgets/app_status_view.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_template/shared/widgets/app_empty_view.dart';
|
||||
import 'package:flutter_template/shared/widgets/app_error_view.dart';
|
||||
import 'package:flutter_template/shared/widgets/app_loading_view.dart';
|
||||
|
||||
enum AppViewStatus { loading, empty, error, content }
|
||||
|
||||
class AppStatusView extends StatelessWidget {
|
||||
const AppStatusView({
|
||||
super.key,
|
||||
required this.status,
|
||||
required this.child,
|
||||
this.empty,
|
||||
this.error,
|
||||
this.loading,
|
||||
this.onRetry,
|
||||
});
|
||||
|
||||
final AppViewStatus status;
|
||||
final Widget child;
|
||||
final Widget? empty;
|
||||
final Widget? error;
|
||||
final Widget? loading;
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return switch (status) {
|
||||
AppViewStatus.loading => loading ?? const AppLoadingView(),
|
||||
AppViewStatus.empty => empty ?? const AppEmptyView(),
|
||||
AppViewStatus.error => error ?? AppErrorView(onRetry: onRetry),
|
||||
AppViewStatus.content => child,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user