feat(apps): 新增 ErrorRetrySurface 和 FullScreenLoading 通用组件
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/theme/design_tokens.dart';
|
||||
import 'app_button.dart';
|
||||
|
||||
class ErrorRetrySurface extends StatelessWidget {
|
||||
const ErrorRetrySurface({
|
||||
super.key,
|
||||
required this.message,
|
||||
required this.onRetry,
|
||||
this.horizontalPadding = AppSpacing.xl,
|
||||
});
|
||||
|
||||
final String message;
|
||||
final VoidCallback onRetry;
|
||||
final double horizontalPadding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: horizontalPadding),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
message,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(color: AppColors.red500),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
AppButton(text: '重试', onPressed: onRetry),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_loading_indicator.dart';
|
||||
|
||||
class FullScreenLoading extends StatelessWidget {
|
||||
const FullScreenLoading({super.key, this.safeArea = false});
|
||||
|
||||
final bool safeArea;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final content = const Center(child: AppLoadingIndicator(size: 22));
|
||||
if (!safeArea) {
|
||||
return content;
|
||||
}
|
||||
return const SafeArea(child: Center(child: AppLoadingIndicator(size: 22)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user