118 lines
3.2 KiB
Dart
118 lines
3.2 KiB
Dart
// Author: fengshengxiong
|
|
// Date: 2024/5/11
|
|
// Description: 提示框
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:now_wallpaper/common/components/divider_widget.dart';
|
|
|
|
class RemindDialog extends StatelessWidget {
|
|
const RemindDialog({
|
|
super.key,
|
|
this.title,
|
|
this.content,
|
|
this.showCancelBtn = true,
|
|
this.cancelText,
|
|
this.confirmText,
|
|
this.confirmOnTap,
|
|
});
|
|
|
|
final String? title;
|
|
final String? content;
|
|
final bool? showCancelBtn;
|
|
final String? cancelText;
|
|
final String? confirmText;
|
|
final Function()? confirmOnTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return PopScope(
|
|
canPop: false,
|
|
child: Center(
|
|
child: Container(
|
|
width: 0.8.sw,
|
|
clipBehavior: Clip.hardEdge,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(8).r,
|
|
),
|
|
child: IntrinsicHeight(
|
|
child: Column(
|
|
children: [
|
|
SizedBox(height: 10.h),
|
|
Text(
|
|
title ?? 'Reminder',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 18.sp,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
SizedBox(height: 10.h),
|
|
Text(
|
|
content ?? '',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: const Color(0xFF333333),
|
|
fontSize: 15.sp,
|
|
),
|
|
),
|
|
SizedBox(height: 10.h),
|
|
const DividerWidget(),
|
|
SizedBox(
|
|
height: 48.h,
|
|
child: Row(
|
|
children: [
|
|
if (showCancelBtn!) ...[
|
|
_optionButton(cancelText ?? 'Cancel', false),
|
|
Container(
|
|
width: 1.w,
|
|
height: double.infinity,
|
|
color: const Color(0xFFE5E5E5),
|
|
),
|
|
],
|
|
_optionButton(confirmText ?? 'Confirm', true),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _optionButton(String label, bool isConfirm) {
|
|
return Expanded(
|
|
child: Material(
|
|
color: Colors.transparent,
|
|
child: InkWell(
|
|
onTap: () {
|
|
Get.back();
|
|
if (isConfirm && confirmOnTap != null) {
|
|
confirmOnTap!();
|
|
}
|
|
},
|
|
child: SizedBox(
|
|
height: double.infinity,
|
|
child: Center(
|
|
child: Text(
|
|
label,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: isConfirm ? Colors.black : const Color(0xFF666666),
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|