import 'package:flutter/material.dart';
import 'package:recording_tool/shared/widgets/app_empty_view.dart';
import 'package:recording_tool/shared/widgets/app_error_view.dart';
import 'package:recording_tool/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,
    };
  }
}
