import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:location/resource/assets.gen.dart'; import 'package:location/resource/string.gen.dart'; import 'package:location/utils/common_expand.dart'; import '../resource/colors.gen.dart'; class SelectMessageReminderDateDialog { static const String _tag = 'SelectMessageReminderDateDialog'; static void show() { SmartDialog.show( tag: _tag, animationType: SmartAnimationType.centerFade_otherSlide, alignment: Alignment.bottomCenter, keepSingle: true, builder: (_) { return SelectMessageReminderDateView(); }); } static void hide() { SmartDialog.dismiss(tag: _tag); } } class SelectMessageReminderDateView extends StatelessWidget { const SelectMessageReminderDateView({super.key}); @override Widget build(BuildContext context) { return IntrinsicHeight( child: Container( padding: EdgeInsets.all(16.w), margin: EdgeInsets.all(12.w), width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(16.r), gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: ['#E4E4FF'.color, ColorName.white], stops: [0.0, 0.3])), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(StringName.selectMessageReminderDateTitle, style: TextStyle( fontSize: 16.sp, color: ColorName.black90, fontWeight: FontWeight.bold)), SizedBox(height: 12.w), buildDateView(), SizedBox(height: 12.w), buildSelectBtnView(), ], ), ), ); } Widget buildDateView() { return WeekdaySelector(); } Widget buildSelectBtnView() { return Row( children: [ Expanded( child: GestureDetector( onTap: () { SelectMessageReminderDateDialog.hide(); }, child: Container( height: 46.w, decoration: BoxDecoration( color: ColorName.colorPrimary.withOpacity(0.08), borderRadius: BorderRadius.circular(100.w)), child: Center( child: Text( StringName.dialogCancel, style: TextStyle( fontSize: 14.sp, color: ColorName.colorPrimary, fontWeight: FontWeight.bold), ), ), ), )), SizedBox(width: 12.w), Expanded( child: GestureDetector( onTap: onSureClick, child: Container( height: 46.w, decoration: BoxDecoration( color: ColorName.colorPrimary, borderRadius: BorderRadius.circular(100.w)), child: Center( child: Text( StringName.dialogSave, style: TextStyle( fontSize: 14.sp, color: ColorName.white, fontWeight: FontWeight.bold), ), ), ), )), ], ); } void onSureClick() {} } class WeekdaySelector extends StatefulWidget { @override _WeekdaySelectorState createState() => _WeekdaySelectorState(); } class _WeekdaySelectorState extends State { final List days = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]; List selected = List.filled(7, false); // 保存勾选状态 @override Widget build(BuildContext context) { return Column( children: List.generate(days.length, (index) { return Column( children: [ GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { setState(() { selected[index] = !selected[index]; }); }, child: Container( padding: EdgeInsets.symmetric(vertical: 12.w), child: Row( children: [ Text(days[index], style: TextStyle( fontSize: 14.sp, color: ColorName.black60)), Spacer(), if (selected[index]) Assets.images.iconDateSelected .image(width: 18.w, height: 18.w) else Assets.images.iconDateUnSelect .image(width: 18.w, height: 18.w) ], ), ), ), if (index != days.length - 1) Container( height: 0.5.w, width: double.infinity, color: '#14000000'.color) ], ); }), ); } }