初始化提交
This commit is contained in:
Executable
+197
@@ -0,0 +1,197 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:kaer_with_panels/app/localization/app_translations.dart';
|
||||
|
||||
class KRDialog extends StatelessWidget {
|
||||
final String? title;
|
||||
final String? message;
|
||||
final String? confirmText;
|
||||
final String? cancelText;
|
||||
final VoidCallback? onConfirm;
|
||||
final VoidCallback? onCancel;
|
||||
final Widget? icon;
|
||||
final Widget? customMessageWidget;
|
||||
|
||||
const KRDialog({
|
||||
Key? key,
|
||||
this.title,
|
||||
this.message,
|
||||
this.confirmText,
|
||||
this.cancelText,
|
||||
this.onConfirm,
|
||||
this.onCancel,
|
||||
this.icon,
|
||||
this.customMessageWidget,
|
||||
}) : super(key: key);
|
||||
|
||||
static Future<void> show({
|
||||
String? title,
|
||||
String? message,
|
||||
String? confirmText,
|
||||
String? cancelText,
|
||||
VoidCallback? onConfirm,
|
||||
VoidCallback? onCancel,
|
||||
Widget? icon,
|
||||
Widget? customMessageWidget,
|
||||
}) {
|
||||
return Get.dialog(
|
||||
KRDialog(
|
||||
title: title,
|
||||
message: message,
|
||||
confirmText: confirmText,
|
||||
cancelText: cancelText,
|
||||
onConfirm: onConfirm,
|
||||
onCancel: onCancel,
|
||||
icon: icon,
|
||||
customMessageWidget: customMessageWidget,
|
||||
),
|
||||
barrierDismissible: false,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildConfirmButton() {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(23.r),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF1797FF).withOpacity(0.25),
|
||||
blurRadius: 8.r,
|
||||
offset: Offset(0, 2.w),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
onConfirm?.call();
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF1797FF),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(23.r),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: Size.fromHeight(46.w),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
child: Text(
|
||||
confirmText ?? AppTranslations.kr_dialog.kr_confirm,
|
||||
style: TextStyle(
|
||||
fontSize: 15.sp,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final isDark = theme.brightness == Brightness.dark;
|
||||
|
||||
return Dialog(
|
||||
backgroundColor: theme.cardColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12.r),
|
||||
),
|
||||
child: Container(
|
||||
width: 280.w,
|
||||
padding: EdgeInsets.all(24.w),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
icon!,
|
||||
SizedBox(height: 20.w),
|
||||
],
|
||||
if (title != null) ...[
|
||||
Text(
|
||||
title!,
|
||||
style: TextStyle(
|
||||
fontSize: 17.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isDark ? Colors.white : const Color(0xFF333333),
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
height: 1.3,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(height: 12.w),
|
||||
],
|
||||
if (message != null || customMessageWidget != null) ...[
|
||||
Container(
|
||||
constraints: BoxConstraints(maxHeight: 200.h),
|
||||
child: SingleChildScrollView(
|
||||
child: customMessageWidget ?? Text(
|
||||
message!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
color: isDark ? const Color(0xFFCCCCCC) : const Color(0xFF666666),
|
||||
fontFamily: 'AlibabaPuHuiTi-Regular',
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 28.w),
|
||||
],
|
||||
if (cancelText != null) ...[
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(23.r),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.03),
|
||||
blurRadius: 4.r,
|
||||
offset: Offset(0, 2.w),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
onCancel?.call();
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: isDark ? const Color(0xFF222222) : const Color(0xFFEEEEEE),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(23.r),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: Size.fromHeight(46.w),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
child: Text(
|
||||
cancelText ?? AppTranslations.kr_dialog.kr_cancel,
|
||||
style: TextStyle(
|
||||
fontSize: 15.sp,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isDark ? const Color(0xFFBBBBBB) : const Color(0xFF666666),
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12.w),
|
||||
Expanded(child: _buildConfirmButton()),
|
||||
],
|
||||
),
|
||||
] else ...[
|
||||
_buildConfirmButton(),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:kaer_with_panels/app/widgets/kr_local_image.dart';
|
||||
|
||||
import '../../localization/app_translations.dart';
|
||||
|
||||
class KRUpdateDialog extends StatelessWidget {
|
||||
final String version;
|
||||
final String updateContent;
|
||||
final VoidCallback? onConfirm;
|
||||
final VoidCallback? onCancel;
|
||||
final bool showCancelButton;
|
||||
final bool isForceUpdate;
|
||||
|
||||
KRUpdateDialog({
|
||||
Key? key,
|
||||
required this.version,
|
||||
String? updateContent,
|
||||
this.onConfirm,
|
||||
this.onCancel,
|
||||
this.showCancelButton = true,
|
||||
this.isForceUpdate = false,
|
||||
}) : updateContent = updateContent ?? AppTranslations.kr_update.defaultContent,
|
||||
super(key: key);
|
||||
|
||||
static Future<void> show({
|
||||
required String version,
|
||||
String? updateContent,
|
||||
VoidCallback? onConfirm,
|
||||
VoidCallback? onCancel,
|
||||
bool showCancelButton = true,
|
||||
bool isForceUpdate = false,
|
||||
}) {
|
||||
return Get.dialog(
|
||||
|
||||
KRUpdateDialog(
|
||||
version: version,
|
||||
updateContent: updateContent,
|
||||
onConfirm: onConfirm,
|
||||
onCancel: onCancel,
|
||||
showCancelButton: showCancelButton,
|
||||
isForceUpdate: isForceUpdate,
|
||||
|
||||
),
|
||||
barrierDismissible: false,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildConfirmButton(ThemeData theme) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: 44.h,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(22.r),
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF2196F3), Color(0xFF1E88E5)],
|
||||
),
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
if (!isForceUpdate) {
|
||||
Get.back();
|
||||
}
|
||||
onConfirm?.call();
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(22.r),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
child: Text(
|
||||
AppTranslations.kr_update.updateNow,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16.sp,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCancelButton(ThemeData theme) {
|
||||
return TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
onCancel?.call();
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
child: Text(
|
||||
AppTranslations.kr_update.updateLater,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.hintColor,
|
||||
fontSize: 14.sp,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return Dialog(
|
||||
backgroundColor: theme.cardColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12.r),
|
||||
),
|
||||
child: Container(
|
||||
width: 280.w,
|
||||
padding: EdgeInsets.all(24.w),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
KrLocalImage(
|
||||
imageName: 'vs_update',
|
||||
width: 190.w,
|
||||
height: 98.w,
|
||||
imageType: ImageType.svg,
|
||||
),
|
||||
SizedBox(height: 16.h),
|
||||
Text(
|
||||
AppTranslations.kr_update.title,
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 18.sp,
|
||||
color: theme.brightness == Brightness.light
|
||||
? const Color(0xFF333333)
|
||||
: theme.textTheme.titleLarge?.color,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4.h),
|
||||
Text(
|
||||
'V$version',
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.hintColor,
|
||||
fontSize: 14.sp,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 1.h),
|
||||
Container(
|
||||
constraints: BoxConstraints(maxHeight: 120.h),
|
||||
child: SingleChildScrollView(
|
||||
child: Text(
|
||||
updateContent,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.hintColor,
|
||||
fontSize: 14.sp,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20.h),
|
||||
_buildConfirmButton(theme),
|
||||
if (showCancelButton) ...[
|
||||
SizedBox(height: 12.h),
|
||||
_buildCancelButton(theme),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user