71 lines
1.5 KiB
Dart
71 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class LoadingWidget extends StatelessWidget {
|
|
const LoadingWidget({
|
|
super.key,
|
|
this.message,
|
|
this.size = 24.0,
|
|
});
|
|
|
|
final String? message;
|
|
final double size;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final colorScheme = theme.colorScheme;
|
|
|
|
return Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SizedBox(
|
|
width: size,
|
|
height: size,
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: 2.0,
|
|
color: colorScheme.primary,
|
|
),
|
|
),
|
|
if (message != null) ...[
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
message!,
|
|
style: theme.textTheme.bodyMedium?.copyWith(
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class LoadingOverlay extends StatelessWidget {
|
|
const LoadingOverlay({
|
|
super.key,
|
|
required this.isLoading,
|
|
required this.child,
|
|
this.message,
|
|
});
|
|
|
|
final bool isLoading;
|
|
final Widget child;
|
|
final String? message;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Stack(
|
|
children: [
|
|
child,
|
|
if (isLoading)
|
|
Container(
|
|
color: Colors.black.withOpacity(0.3),
|
|
child: LoadingWidget(message: message),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
} |