Files
chat/client/flutter/lib/widgets/loading_widget.dart
2026-04-25 16:36:34 +08:00

88 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:sales_chat/theme/app_theme.dart';
class LoadingWidget extends StatelessWidget {
final String? message;
final double size;
const LoadingWidget({
super.key,
this.message,
this.size = 40,
});
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: size,
height: size,
child: CircularProgressIndicator(
strokeWidth: 3,
valueColor: AlwaysStoppedAnimation<Color>(AppTheme.primaryColor),
),
),
if (message != null) ...[
const SizedBox(height: 16),
Text(
message!,
style: TextStyle(
color: AppTheme.textSecondary,
fontSize: 14,
),
),
],
],
),
);
}
}
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: Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const CircularProgressIndicator(),
if (message != null) ...[
const SizedBox(height: 16),
Text(message!),
],
],
),
),
),
),
],
);
}
}