select_message_reminder_date_dialog.dart 5.1 KB

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