select_message_reminder_date_dialog.dart 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  5. import 'package:location/resource/assets.gen.dart';
  6. import 'package:location/resource/string.gen.dart';
  7. import 'package:location/utils/common_expand.dart';
  8. import '../resource/colors.gen.dart';
  9. class SelectMessageReminderDateDialog {
  10. static const String _tag = 'SelectMessageReminderDateDialog';
  11. static void show({List<int>? selectWeekDays}) {
  12. SmartDialog.show(
  13. tag: _tag,
  14. animationType: SmartAnimationType.centerFade_otherSlide,
  15. alignment: Alignment.bottomCenter,
  16. keepSingle: true,
  17. builder: (_) {
  18. return SelectMessageReminderDateView(selectWeekDays);
  19. });
  20. }
  21. static void hide() {
  22. SmartDialog.dismiss(tag: _tag);
  23. }
  24. }
  25. class SelectMessageReminderDateView extends StatelessWidget {
  26. final List<int>? selectWeekDays;
  27. const SelectMessageReminderDateView(this.selectWeekDays, {super.key});
  28. @override
  29. Widget build(BuildContext context) {
  30. return IntrinsicHeight(
  31. child: Container(
  32. padding: EdgeInsets.all(16.w),
  33. margin: EdgeInsets.all(12.w),
  34. width: double.infinity,
  35. decoration: BoxDecoration(
  36. borderRadius: BorderRadius.circular(16.r),
  37. gradient: LinearGradient(
  38. begin: Alignment.topCenter,
  39. end: Alignment.bottomCenter,
  40. colors: ['#E4E4FF'.color, ColorName.white],
  41. stops: [0.0, 0.3])),
  42. child: Column(
  43. crossAxisAlignment: CrossAxisAlignment.start,
  44. children: [
  45. Text(StringName.selectMessageReminderDateTitle,
  46. style: TextStyle(
  47. fontSize: 16.sp,
  48. color: ColorName.black90,
  49. fontWeight: FontWeight.bold)),
  50. SizedBox(height: 12.w),
  51. buildDateView(),
  52. SizedBox(height: 12.w),
  53. buildSelectBtnView(),
  54. ],
  55. ),
  56. ),
  57. );
  58. }
  59. Widget buildDateView() {
  60. return WeekdaySelector();
  61. }
  62. Widget buildSelectBtnView() {
  63. return Row(
  64. children: [
  65. Expanded(
  66. child: GestureDetector(
  67. onTap: () {
  68. SelectMessageReminderDateDialog.hide();
  69. },
  70. child: Container(
  71. height: 46.w,
  72. decoration: BoxDecoration(
  73. color: ColorName.colorPrimary.withOpacity(0.08),
  74. borderRadius: BorderRadius.circular(100.w)),
  75. child: Center(
  76. child: Text(
  77. StringName.dialogCancel,
  78. style: TextStyle(
  79. fontSize: 14.sp,
  80. color: ColorName.colorPrimary,
  81. fontWeight: FontWeight.bold),
  82. ),
  83. ),
  84. ),
  85. )),
  86. SizedBox(width: 12.w),
  87. Expanded(
  88. child: GestureDetector(
  89. onTap: onSureClick,
  90. child: Container(
  91. height: 46.w,
  92. decoration: BoxDecoration(
  93. color: ColorName.colorPrimary,
  94. borderRadius: BorderRadius.circular(100.w)),
  95. child: Center(
  96. child: Text(
  97. StringName.dialogSave,
  98. style: TextStyle(
  99. fontSize: 14.sp,
  100. color: ColorName.white,
  101. fontWeight: FontWeight.bold),
  102. ),
  103. ),
  104. ),
  105. )),
  106. ],
  107. );
  108. }
  109. void onSureClick() {}
  110. }
  111. class WeekdaySelector extends StatefulWidget {
  112. @override
  113. _WeekdaySelectorState createState() => _WeekdaySelectorState();
  114. }
  115. class _WeekdaySelectorState extends State<WeekdaySelector> {
  116. final List<String> days = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
  117. List<bool> selected = List.filled(7, false); // 保存勾选状态
  118. @override
  119. Widget build(BuildContext context) {
  120. return Column(
  121. children: List.generate(days.length, (index) {
  122. return Column(
  123. children: [
  124. GestureDetector(
  125. behavior: HitTestBehavior.translucent,
  126. onTap: () {
  127. setState(() {
  128. selected[index] = !selected[index];
  129. });
  130. },
  131. child: Container(
  132. padding: EdgeInsets.symmetric(vertical: 12.w),
  133. child: Row(
  134. children: [
  135. Text(days[index],
  136. style: TextStyle(
  137. fontSize: 14.sp, color: ColorName.black60)),
  138. Spacer(),
  139. if (selected[index])
  140. Assets.images.iconDateSelected
  141. .image(width: 18.w, height: 18.w)
  142. else
  143. Assets.images.iconDateUnSelect
  144. .image(width: 18.w, height: 18.w)
  145. ],
  146. ),
  147. ),
  148. ),
  149. if (index != days.length - 1)
  150. Container(
  151. height: 0.5.w,
  152. width: double.infinity,
  153. color: '#14000000'.color)
  154. ],
  155. );
  156. }),
  157. );
  158. }
  159. }