2023-11-19 18:04:44 +02: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 06:17:29 +02:00
|
|
|
final bool withIcon;
|
2024-01-05 07:20:55 +02:00
|
|
|
final String? errorMsg;
|
2023-11-19 18:04:44 +02:00
|
|
|
|
2024-01-05 07:20:55 +02:00
|
|
|
const ScaffoldErrorBody({super.key, this.withIcon = true, this.errorMsg});
|
2023-11-19 18:04:44 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
2023-11-29 06:17:29 +02:00
|
|
|
Text(
|
2023-12-05 21:34:37 +02:00
|
|
|
"scaffold_body_error_occurred",
|
2023-11-29 06:17:29 +02:00
|
|
|
style: context.textTheme.displayMedium,
|
2023-11-19 18:04:44 +02:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
).tr(),
|
2023-11-29 06:17:29 +02:00
|
|
|
if (withIcon)
|
|
|
|
Center(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 15),
|
|
|
|
child: Icon(
|
|
|
|
Icons.error_outline,
|
|
|
|
size: 100,
|
|
|
|
color: context.themeData.iconTheme.color?.withOpacity(0.5),
|
|
|
|
),
|
|
|
|
),
|
2023-11-19 18:04:44 +02:00
|
|
|
),
|
2024-01-05 07:20:55 +02:00
|
|
|
if (withIcon && errorMsg != null)
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(20),
|
|
|
|
child: Text(
|
|
|
|
errorMsg!,
|
|
|
|
style: context.textTheme.displaySmall,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
),
|
2023-11-19 18:04:44 +02:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|