46 lines
1.1 KiB
Dart
46 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|||
|
|
|
||
|
|
/// 加载遮罩组件
|
||
|
|
class LoadingOverlay extends StatelessWidget {
|
||
|
|
final bool isLoading;
|
||
|
|
final Widget child;
|
||
|
|
final String? message;
|
||
|
|
|
||
|
|
const LoadingOverlay({
|
||
|
|
super.key,
|
||
|
|
required this.isLoading,
|
||
|
|
required this.child,
|
||
|
|
this.message,
|
||
|
|
});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Stack(
|
||
|
|
children: [
|
||
|
|
child,
|
||
|
|
if (isLoading)
|
||
|
|
Container(
|
||
|
|
color: Colors.black.withOpacity(0.3),
|
||
|
|
child: Center(
|
||
|
|
child: Card(
|
||
|
|
child: Padding(
|
||
|
|
padding: const EdgeInsets.all(24),
|
||
|
|
child: Column(
|
||
|
|
mainAxisSize: MainAxisSize.min,
|
||
|
|
children: [
|
||
|
|
const CircularProgressIndicator(),
|
||
|
|
if (message != null) ...[
|
||
|
|
const SizedBox(height: 16),
|
||
|
|
Text(message!),
|
||
|
|
],
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|