146 lines
4.8 KiB
Dart
146 lines
4.8 KiB
Dart
import 'package:another_flushbar/flushbar.dart';
|
|
import 'package:didvan/config/design_config.dart';
|
|
import 'package:didvan/config/theme_data.dart';
|
|
import 'package:didvan/constants/assets.dart';
|
|
import 'package:didvan/models/enums.dart';
|
|
import 'package:didvan/models/view/action_sheet_data.dart';
|
|
import 'package:didvan/models/view/alert_data.dart';
|
|
import 'package:didvan/widgets/didvan/button.dart';
|
|
import 'package:didvan/widgets/didvan/text.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:rive/rive.dart';
|
|
|
|
class ActionSheetUtils {
|
|
static late BuildContext context;
|
|
|
|
static Future<void> showLogoLoadingIndicator() async {
|
|
await showDialog(
|
|
context: context,
|
|
builder: (context) =>
|
|
// _customSystemOverlayStyle(
|
|
// child:
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: MediaQuery.of(context).size.width / 3,
|
|
),
|
|
child: RiveAnimation.asset(Assets.logoLoadingAnimation),
|
|
// ),
|
|
),
|
|
);
|
|
}
|
|
|
|
static AnnotatedRegion _customSystemOverlayStyle({required Widget child}) {
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
value: DesignConfig.systemUiOverlayStyle.copyWith(
|
|
systemNavigationBarColor: DesignConfig
|
|
.systemUiOverlayStyle.systemNavigationBarColor!
|
|
.withBlue(20),
|
|
),
|
|
child: child,
|
|
);
|
|
}
|
|
|
|
static Future<void> showAlert(AlertData alertData) async {
|
|
await Flushbar(
|
|
margin: const EdgeInsets.symmetric(horizontal: 16),
|
|
message: alertData.message,
|
|
backgroundColor: Theme.of(context).colorScheme.focused,
|
|
borderRadius: DesignConfig.mediumBorderRadius,
|
|
messageColor: Theme.of(context).colorScheme.text,
|
|
flushbarPosition: FlushbarPosition.TOP,
|
|
duration: const Duration(seconds: 2),
|
|
boxShadows: [
|
|
BoxShadow(color: Theme.of(context).colorScheme.cardBorder),
|
|
],
|
|
).show(context);
|
|
}
|
|
|
|
static Future<void> showBottomSheet({required ActionSheetData data}) async {
|
|
await showModalBottomSheet(
|
|
backgroundColor: Colors.transparent,
|
|
isScrollControlled: true,
|
|
context: context,
|
|
builder: (context) => Container(
|
|
padding: const EdgeInsets.all(20),
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.surface,
|
|
borderRadius: const BorderRadius.vertical(
|
|
top: Radius.circular(
|
|
10,
|
|
),
|
|
),
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Center(
|
|
child: Container(
|
|
height: 3,
|
|
width: 50,
|
|
color: Theme.of(context).colorScheme.hint,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Row(
|
|
children: [
|
|
if (data.titleIcon != null)
|
|
Icon(
|
|
data.titleIcon,
|
|
color: data.titleColor ??
|
|
Theme.of(context).colorScheme.title,
|
|
),
|
|
if (data.titleIcon != null) const SizedBox(width: 8),
|
|
DidvanText(
|
|
data.title,
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
color:
|
|
data.titleColor ?? Theme.of(context).colorScheme.title,
|
|
)
|
|
],
|
|
),
|
|
const SizedBox(height: 28),
|
|
data.content,
|
|
const SizedBox(height: 28),
|
|
Row(
|
|
children: [
|
|
if (data.hasDismissButton)
|
|
Expanded(
|
|
child: DidvanButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
data.onDismissed?.call();
|
|
},
|
|
title: data.dismissTitle ?? 'بازگشت',
|
|
style: ButtonStyleMode.flat,
|
|
),
|
|
),
|
|
if (data.hasDismissButton) const SizedBox(width: 20),
|
|
Expanded(
|
|
flex: data.smallDismissButton ? 2 : 1,
|
|
child: DidvanButton(
|
|
style: ButtonStyleMode.primary,
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
data.onConfirmed?.call();
|
|
},
|
|
title: data.confrimTitle ?? 'تایید',
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
static void pop() {
|
|
DesignConfig.updateSystemUiOverlayStyle();
|
|
Navigator.of(context).pop();
|
|
}
|
|
}
|