| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- 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<WeekdaySelector> {
- final List<String> days = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
- List<bool> 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)
- ],
- );
- }),
- );
- }
- }
|