156 lines
5.0 KiB
Dart
156 lines
5.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
class KtDialog extends StatelessWidget {
|
|
final String title;
|
|
final String subTitle;
|
|
final String leftBtnText;
|
|
final String? leftBtnIcon;
|
|
final String rightBtnText;
|
|
final String? rightBtnIcon;
|
|
final String topIcon;
|
|
final Widget? topIconWidget;
|
|
final bool hasLeftBtn;
|
|
final double titleSize;
|
|
final VoidCallback? leftBtnFunc;
|
|
final VoidCallback? rightBtnFunc;
|
|
|
|
const KtDialog({
|
|
super.key,
|
|
required this.title,
|
|
required this.subTitle,
|
|
this.leftBtnText = 'Cancel',
|
|
this.leftBtnIcon,
|
|
this.rightBtnText = 'Confirm',
|
|
this.rightBtnIcon,
|
|
this.hasLeftBtn = true,
|
|
this.topIcon = 'dialog_star.png',
|
|
this.topIconWidget,
|
|
this.titleSize = 18,
|
|
this.leftBtnFunc,
|
|
this.rightBtnFunc,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Center(
|
|
child: Container(
|
|
width: 315.w,
|
|
height: 367.w,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(image: AssetImage('dialog_bg1.png'.ktIcon)),
|
|
),
|
|
padding: EdgeInsets.fromLTRB(16.w, 94.w, 16.w, 16.w),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: titleSize.sp,
|
|
color: Color(0xFF1E1E20),
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
// SizedBox(height: 20.w),
|
|
Image.asset(topIcon.ktIcon, width: 100.w),
|
|
// SizedBox(height: 10.w),
|
|
SizedBox(
|
|
width: 246.w,
|
|
child: Text(
|
|
subTitle,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontSize: 15.sp,
|
|
color: Color(0xFF1C1C1C),
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 15.w),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
GestureDetector(
|
|
onTap: () {
|
|
Navigator.of(context).pop();
|
|
leftBtnFunc?.call();
|
|
},
|
|
child: Container(
|
|
width: 120.w,
|
|
height: 48.w,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(100),
|
|
border: Border.all(width: 1.w, color: Color(0xFFC5C5C5)),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
if (leftBtnIcon != null)
|
|
Container(
|
|
margin: EdgeInsets.only(right: 4.w),
|
|
child: Image.asset(
|
|
leftBtnIcon!.ktIcon,
|
|
width: 16.w,
|
|
),
|
|
),
|
|
Text(
|
|
leftBtnText,
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Color(0xFFB9B9B9),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: 20.w),
|
|
GestureDetector(
|
|
onTap: () {
|
|
Navigator.of(context).pop();
|
|
rightBtnFunc?.call();
|
|
},
|
|
child: Container(
|
|
width: 120.w,
|
|
height: 48.w,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF1E1E20),
|
|
borderRadius: BorderRadius.circular(100),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
if (rightBtnIcon != null)
|
|
Container(
|
|
margin: EdgeInsets.only(right: 4.w),
|
|
child: Image.asset(
|
|
rightBtnIcon!.ktIcon,
|
|
width: 16.w,
|
|
),
|
|
),
|
|
Text(
|
|
rightBtnText,
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Color(0xFFA7F62F),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|