add_agenda_dialog.dart 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. import 'package:electronic_assistant/resource/assets.gen.dart';
  2. import 'package:electronic_assistant/utils/expand.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:get/get.dart';
  6. import 'package:get/get_core/src/get_main.dart';
  7. import '../resource/colors.gen.dart';
  8. import '../resource/string.gen.dart';
  9. void showAddAgendaDialog(
  10. BuildContext context,
  11. TextEditingController agendaContentController,
  12. TextEditingController agendaNameController,
  13. {List<String>? list,
  14. void Function()? callback}) {
  15. final etContentTxt = agendaContentController.text.obs;
  16. final etNameTxt = agendaNameController.text.obs;
  17. agendaContentController.addListener(() {
  18. etContentTxt.value = agendaContentController.text;
  19. });
  20. agendaNameController.addListener(() {
  21. etNameTxt.value = agendaNameController.text;
  22. });
  23. showModalBottomSheet(
  24. context: context,
  25. enableDrag: false,
  26. isScrollControlled: true,
  27. backgroundColor: ColorName.transparent,
  28. builder: (BuildContext context) {
  29. return Padding(
  30. padding: EdgeInsets.only(
  31. bottom: MediaQuery.of(context).viewInsets.bottom,
  32. ),
  33. child: Container(
  34. decoration: BoxDecoration(
  35. borderRadius: BorderRadius.only(
  36. topLeft: Radius.circular(12.w),
  37. topRight: Radius.circular(12.w)),
  38. color: "#FFFFFF".toColor(),
  39. ),
  40. child: IntrinsicHeight(
  41. child: Column(
  42. crossAxisAlignment: CrossAxisAlignment.start,
  43. children: [
  44. SizedBox(height: 18.h),
  45. Row(
  46. children: [
  47. GestureDetector(
  48. onTap: () {
  49. Get.back();
  50. },
  51. child: Container(
  52. color: Colors.transparent,
  53. margin: EdgeInsets.only(left: 16.w),
  54. padding: EdgeInsets.symmetric(horizontal: 8.w),
  55. child: Text(StringName.cancel.tr,
  56. style: TextStyle(
  57. color: ColorName.secondaryTextColor,
  58. fontSize: 14.sp)),
  59. ),
  60. ),
  61. const Spacer(),
  62. Text(StringName.talkAddAgendaProject.tr,
  63. style: TextStyle(
  64. color: ColorName.primaryTextColor,
  65. fontSize: 15.sp)),
  66. const Spacer(),
  67. GestureDetector(
  68. onTap: () {
  69. callback?.call();
  70. },
  71. child: Container(
  72. color: Colors.transparent,
  73. margin: EdgeInsets.only(right: 16.w),
  74. padding: EdgeInsets.symmetric(horizontal: 8.w),
  75. child: Obx(() {
  76. return Text(StringName.done.tr,
  77. style: TextStyle(
  78. color: etContentTxt.isNotEmpty &&
  79. etNameTxt.isNotEmpty
  80. ? ColorName.colorPrimary
  81. : ColorName.tertiaryTextColor,
  82. fontSize: 15.sp));
  83. }),
  84. ),
  85. ),
  86. ],
  87. ),
  88. SizedBox(height: 24.h),
  89. Container(
  90. margin: EdgeInsets.symmetric(horizontal: 16.w),
  91. decoration: BoxDecoration(
  92. color: "#F6F5F8".toColor(),
  93. borderRadius: BorderRadius.circular(8),
  94. ),
  95. height: 120.h,
  96. child: TextField(
  97. maxLines: null,
  98. maxLength: 200,
  99. cursorColor: ColorName.colorPrimary,
  100. style: TextStyle(
  101. fontSize: 15.sp, color: ColorName.primaryTextColor),
  102. decoration: InputDecoration(
  103. counterText: '',
  104. border: InputBorder.none,
  105. fillColor: Colors.transparent,
  106. hintText: StringName.talkAddAgendaContentHint.tr,
  107. hintStyle: TextStyle(
  108. fontSize: 15.sp, color: ColorName.tertiaryTextColor),
  109. contentPadding: const EdgeInsets.all(12).w,
  110. ),
  111. controller: agendaContentController,
  112. ),
  113. ),
  114. SizedBox(height: 16.h),
  115. Padding(
  116. padding: EdgeInsets.only(left: 16.w),
  117. child: Text(StringName.talkAddAgendaNameTitle.tr,
  118. style: TextStyle(
  119. fontSize: 14.sp,
  120. color: ColorName.secondaryTextColor)),
  121. ),
  122. SizedBox(height: 8.h),
  123. Container(
  124. margin: EdgeInsets.symmetric(horizontal: 16.w),
  125. decoration: BoxDecoration(
  126. color: "#F6F5F8".toColor(),
  127. borderRadius: BorderRadius.circular(8),
  128. ),
  129. height: 44.h,
  130. child: Row(
  131. children: [
  132. Expanded(
  133. child: TextField(
  134. maxLines: 1,
  135. maxLength: 15,
  136. cursorColor: ColorName.colorPrimary,
  137. style: TextStyle(
  138. fontSize: 15.sp,
  139. color: ColorName.primaryTextColor),
  140. decoration: InputDecoration(
  141. counterText: '',
  142. border: InputBorder.none,
  143. fillColor: Colors.transparent,
  144. hintText: StringName.talkAddAgendaNameHint.tr,
  145. hintStyle: TextStyle(
  146. fontSize: 15.sp,
  147. color: ColorName.tertiaryTextColor),
  148. contentPadding: const EdgeInsets.all(12).w,
  149. ),
  150. controller: agendaNameController,
  151. ),
  152. ),
  153. Obx(() {
  154. return Visibility(
  155. visible: etNameTxt.isNotEmpty,
  156. child: GestureDetector(
  157. onTap: () {
  158. agendaNameController.clear();
  159. },
  160. child: Container(
  161. margin: EdgeInsets.only(right: 12.w),
  162. width: 20.w,
  163. height: 20.w,
  164. child:
  165. Assets.images.iconRenameClearTxt.image()),
  166. ),
  167. );
  168. })
  169. ],
  170. ),
  171. ),
  172. SizedBox(height: 12.h),
  173. _buildAgendaList(list, itemClick: (item) {
  174. agendaNameController.text = item;
  175. }),
  176. SizedBox(height: 16.h),
  177. ],
  178. ),
  179. ),
  180. ),
  181. );
  182. },
  183. );
  184. }
  185. Widget _buildAgendaList(List<String>? list,
  186. {void Function(String item)? itemClick}) {
  187. if (list == null || list.isEmpty) {
  188. return Container();
  189. }
  190. return SizedBox(
  191. height: 32.h,
  192. child: ListView(
  193. padding: EdgeInsets.only(left: 16.w),
  194. scrollDirection: Axis.horizontal,
  195. children: [
  196. for (var item in list)
  197. GestureDetector(
  198. onTap: () {
  199. itemClick?.call(item);
  200. },
  201. child: Container(
  202. margin: EdgeInsets.only(right: 12.w),
  203. decoration: BoxDecoration(
  204. color: "#F6F5F8".toColor(),
  205. borderRadius: BorderRadius.circular(16),
  206. ),
  207. padding: EdgeInsets.symmetric(horizontal: 12.w),
  208. height: double.infinity,
  209. child: Row(
  210. children: [
  211. SizedBox(
  212. width: 16.w,
  213. height: 16.w,
  214. child: Assets.images.iconTalkUser.image()),
  215. SizedBox(width: 2.w),
  216. Text(
  217. item,
  218. style: TextStyle(
  219. fontSize: 14.sp, color: ColorName.primaryTextColor),
  220. )
  221. ],
  222. ),
  223. ),
  224. ),
  225. ]),
  226. );
  227. }