53 lines
1.3 KiB
Dart
53 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class LoadingDialog {
|
|
static void show(BuildContext context, {String? message}) {
|
|
showDialog(
|
|
context: context,
|
|
barrierDismissible: false,
|
|
builder: (BuildContext context) {
|
|
return PopScope(
|
|
canPop: false,
|
|
child: AlertDialog(
|
|
backgroundColor: Colors.transparent,
|
|
elevation: 0,
|
|
content: _buildLoadingContent(context, message),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
static void hide(BuildContext context) {
|
|
Navigator.of(context, rootNavigator: true).pop();
|
|
}
|
|
|
|
static Widget _buildLoadingContent(BuildContext context, String? message) {
|
|
final colors = Theme.of(context).colorScheme;
|
|
|
|
return Container(
|
|
padding: EdgeInsets.all(20),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
CircularProgressIndicator(
|
|
valueColor: AlwaysStoppedAnimation<Color>(colors.primary),
|
|
strokeWidth: 3,
|
|
),
|
|
if (message != null) ...[
|
|
SizedBox(height: 16),
|
|
Text(
|
|
message,
|
|
style: TextStyle(fontSize: 14, color: Colors.grey[600]),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|