2023-11-19 16:04:44 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|
|
|
|
|
|
|
|
|
// Error widget to be used in Scaffold when an AsyncError is received
|
|
|
|
|
class ScaffoldErrorBody extends StatelessWidget {
|
2023-11-29 04:17:29 +00:00
|
|
|
final bool withIcon;
|
2024-01-05 05:20:55 +00:00
|
|
|
final String? errorMsg;
|
2023-11-19 16:04:44 +00:00
|
|
|
|
2024-01-05 05:20:55 +00:00
|
|
|
const ScaffoldErrorBody({super.key, this.withIcon = true, this.errorMsg});
|
2023-11-19 16:04:44 +00:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
2025-07-29 00:34:03 +05:30
|
|
|
Text("scaffold_body_error_occurred", style: context.textTheme.displayMedium, textAlign: TextAlign.center).tr(),
|
2023-11-29 04:17:29 +00:00
|
|
|
if (withIcon)
|
|
|
|
|
Center(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 15),
|
|
|
|
|
child: Icon(
|
|
|
|
|
Icons.error_outline,
|
|
|
|
|
size: 100,
|
2025-07-25 08:07:22 +05:30
|
|
|
color: context.themeData.iconTheme.color?.withValues(alpha: 0.5),
|
2023-11-29 04:17:29 +00:00
|
|
|
),
|
|
|
|
|
),
|
2023-11-19 16:04:44 +00:00
|
|
|
),
|
2024-01-05 05:20:55 +00:00
|
|
|
if (withIcon && errorMsg != null)
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(20),
|
2025-07-29 00:34:03 +05:30
|
|
|
child: Text(errorMsg!, style: context.textTheme.displaySmall, textAlign: TextAlign.center),
|
2024-01-05 05:20:55 +00:00
|
|
|
),
|
2023-11-19 16:04:44 +00:00
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|