| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
- import 'package:keyboard/utils/common_expand.dart';
- import '../resource/colors.gen.dart';
- import '../utils/styles.dart';
- class CommonAlertDialog {
- static const String _tag = "CommonAlertDialog";
- static void show(
- {required Widget titleWidget,
- required Widget descWidget,
- required String cancelText,
- required String confirmText,
- required VoidCallback cancelOnTap,
- required VoidCallback confirmOnTap,
- String tag = _tag}) {
- SmartDialog.show(
- tag: _tag,
- builder: (_) {
- return _CommonAlertDialog(
- titleWidget: titleWidget,
- descWidget: descWidget,
- cancelText: cancelText,
- confirmText: confirmText,
- cancelOnTap: cancelOnTap,
- confirmOnTap: confirmOnTap);
- });
- }
- static void dismiss({String tag = _tag}) {
- SmartDialog.dismiss(tag: _tag);
- }
- }
- class _CommonAlertDialog extends Dialog {
- final Widget titleWidget;
- final Widget descWidget;
- final String cancelText;
- final String confirmText;
- final VoidCallback cancelOnTap;
- final VoidCallback confirmOnTap;
- const _CommonAlertDialog({
- required this.titleWidget,
- required this.descWidget,
- required this.cancelText,
- required this.confirmText,
- required this.cancelOnTap,
- required this.confirmOnTap,
- });
- @override
- Widget build(BuildContext context) {
- return Container(
- margin: EdgeInsets.symmetric(horizontal: 33.w),
- decoration: ShapeDecoration(
- color: Colors.white,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(20.r),
- ),
- ),
- padding: EdgeInsets.symmetric(
- horizontal: 16.w,
- vertical: 24.w,
- ),
- child: IntrinsicHeight(
- child: Column(
- children: [
- titleWidget,
- SizedBox(height: 20.h),
- descWidget,
- SizedBox(height: 20.h),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- GestureDetector(
- onTap: () => cancelOnTap(),
- child: Container(
- height: 40.h,
- width: 128.w,
- alignment: Alignment.center,
- decoration: ShapeDecoration(
- color: const Color(0xFFF5F4F9),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(50.r),
- ),
- ),
- child: Center(
- child: Text(cancelText,
- style: Styles.getTextStyleBlack102W500(16.sp),
- ),
- ),
- ),
- ),
- GestureDetector(
- onTap: () => confirmOnTap(),
- child: Container(
- height: 40.h,
- width: 128.r,
- alignment: Alignment.center,
- decoration: Styles.getActivateButtonDecoration(
- 50.r,
- ),
- child: Center(
- child: Text(confirmText,
- style: Styles.getTextStyleWhiteW500(16.sp),),
- ),
- ),
- ),
- ],
- ),
- ],
- ),
- ),
- );
- }
- }
|