common_view.dart 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. import 'package:electronic_assistant/data/bean/agenda_list_all_bean.dart';
  2. import 'package:electronic_assistant/utils/expand.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_screenutil/flutter_screenutil.dart';
  6. import 'package:get/get.dart';
  7. import '../../data/bean/agenda.dart';
  8. import '../../resource/assets.gen.dart';
  9. import '../../resource/colors.gen.dart';
  10. import '../../resource/string.gen.dart';
  11. Widget getAddAgendaView(String addTxt, {VoidCallback? onClick}) {
  12. return GestureDetector(
  13. onTap: onClick,
  14. child: Container(
  15. decoration: BoxDecoration(
  16. color: "#F6F5F8".toColor(),
  17. border: Border.all(color: '#EAE5EF'.toColor(), width: 1),
  18. borderRadius: BorderRadius.circular(8.w)),
  19. margin: EdgeInsets.only(bottom: 8.h, top: 6.h),
  20. padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 11.w),
  21. child: Row(
  22. children: [
  23. SizedBox(
  24. width: 22.w,
  25. height: 22.w,
  26. child: Assets.images.iconTalkAddAdenda.image()),
  27. SizedBox(width: 8.w),
  28. Text(
  29. addTxt,
  30. style: TextStyle(fontSize: 14.sp, color: ColorName.colorPrimary),
  31. )
  32. ],
  33. ),
  34. ),
  35. );
  36. }
  37. Widget getTalkUploadingView() {
  38. return SizedBox(
  39. width: double.infinity,
  40. child: Column(
  41. children: [
  42. SizedBox(height: 138.h),
  43. SizedBox(
  44. width: 100.w,
  45. height: 100.w,
  46. child: Assets.anim.talkAnalyse.image()),
  47. SizedBox(height: 12.h),
  48. Text(StringName.talkUploadingTips.tr,
  49. style:
  50. TextStyle(fontSize: 14.sp, color: ColorName.secondaryTextColor))
  51. ],
  52. ),
  53. );
  54. }
  55. Widget getTalkLoadingView() {
  56. return SizedBox(
  57. width: double.infinity,
  58. child: Column(
  59. children: [
  60. SizedBox(height: 138.h),
  61. SizedBox(
  62. width: 100.w,
  63. height: 100.w,
  64. child: Assets.anim.talkAnalyse.image()),
  65. SizedBox(height: 12.h),
  66. Text(StringName.talkAnalyzing.tr,
  67. style:
  68. TextStyle(fontSize: 14.sp, color: ColorName.secondaryTextColor))
  69. ],
  70. ),
  71. );
  72. }
  73. Widget getTalkFailView() {
  74. return SizedBox(
  75. width: double.infinity,
  76. child: Column(
  77. children: [
  78. SizedBox(height: 111.h),
  79. SizedBox(
  80. width: 100.w,
  81. height: 100.w,
  82. child: Assets.images.iconTalkAnalyseFail.image()),
  83. SizedBox(height: 4.h),
  84. Text(StringName.talkAnalyseFail.tr,
  85. style:
  86. TextStyle(fontSize: 15.sp, color: ColorName.primaryTextColor)),
  87. SizedBox(height: 2.h),
  88. ],
  89. ),
  90. );
  91. }
  92. typedef TodoItemBuilder = List<Widget> Function(List<Agenda>? list);
  93. Widget getTodoItemView(AgendaListAllBean agenda, TodoItemBuilder todoBuilder) {
  94. return Container(
  95. decoration: BoxDecoration(
  96. color: ColorName.colorPrimary,
  97. borderRadius: BorderRadius.circular(6),
  98. ),
  99. child: Builder(builder: (context) {
  100. return Theme(
  101. data: Theme.of(context).copyWith(
  102. splashFactory: NoSplash.splashFactory,
  103. ),
  104. child: Container(
  105. margin: EdgeInsets.only(left: 4.w),
  106. decoration: BoxDecoration(
  107. color: "#F6F5F8".toColor(),
  108. borderRadius: const BorderRadius.only(
  109. topRight: Radius.circular(6),
  110. bottomRight: Radius.circular(6),
  111. ),
  112. ),
  113. child: ExpansionTile(
  114. initiallyExpanded: true,
  115. onExpansionChanged: (value) {
  116. agenda.isExpanded.value = value;
  117. },
  118. shape: RoundedRectangleBorder(
  119. borderRadius: BorderRadius.circular(4.0),
  120. side: const BorderSide(color: Colors.transparent),
  121. ),
  122. collapsedShape: RoundedRectangleBorder(
  123. borderRadius: BorderRadius.circular(4.0),
  124. side: const BorderSide(color: Colors.transparent),
  125. ),
  126. minTileHeight: 46.h,
  127. showTrailingIcon: false,
  128. childrenPadding: EdgeInsets.zero,
  129. tilePadding: EdgeInsets.zero,
  130. title: Row(
  131. children: [
  132. SizedBox(width: 12.w),
  133. Text(agenda.name.orEmpty,
  134. style: TextStyle(
  135. fontSize: 15.sp,
  136. color: ColorName.primaryTextColor,
  137. fontWeight: FontWeight.bold)),
  138. const Spacer(),
  139. Obx(() {
  140. return Row(
  141. children: [
  142. Text(
  143. '${agenda.list?.length}${StringName.talkTodoItem.tr}',
  144. style: TextStyle(
  145. fontSize: 15.sp,
  146. color: ColorName.secondaryTextColor),
  147. ),
  148. SizedBox(width: 3.w),
  149. SizedBox(
  150. width: 16.w,
  151. height: 16.w,
  152. child: agenda.isExpanded.value
  153. ? Assets.images.iconTalkExpand.image()
  154. : Assets.images.iconTalkCollapse.image()),
  155. ],
  156. );
  157. }),
  158. SizedBox(width: 12.w),
  159. ],
  160. ),
  161. children: todoBuilder(agenda.list),
  162. ),
  163. ),
  164. );
  165. }),
  166. );
  167. }
  168. typedef TodoItemClick = void Function(Agenda? agenda);
  169. List<Widget> getTalkAgendaSettingList(List<Agenda>? list,
  170. {TodoItemClick? itemClick}) {
  171. return list?.map((agenda) {
  172. return Padding(
  173. padding:
  174. EdgeInsets.only(left: 12.w, right: 12.w, top: 2.h, bottom: 10.h),
  175. child: Row(
  176. crossAxisAlignment: CrossAxisAlignment.center,
  177. children: [
  178. Expanded(
  179. child: Row(
  180. crossAxisAlignment: CrossAxisAlignment.start,
  181. children: [
  182. Container(
  183. width: 8.w,
  184. height: 8.w,
  185. margin: EdgeInsets.only(top: 7.h),
  186. decoration: BoxDecoration(
  187. color: ColorName.colorPrimary.withOpacity(0.5),
  188. shape: BoxShape.circle,
  189. ),
  190. ),
  191. SizedBox(width: 4.w),
  192. Expanded(
  193. child: Text(agenda.content.orEmpty,
  194. style: TextStyle(
  195. fontSize: 14.sp,
  196. color: ColorName.primaryTextColor)),
  197. ),
  198. ]),
  199. ),
  200. SizedBox(width: 20.w),
  201. GestureDetector(
  202. onTap: () {
  203. itemClick?.call(agenda);
  204. },
  205. child: Obx(() {
  206. return Container(
  207. decoration: BoxDecoration(
  208. color: agenda.todo.value
  209. ? "#E7E9F6".toColor()
  210. : ColorName.colorPrimary,
  211. borderRadius: BorderRadius.circular(6),
  212. ),
  213. padding:
  214. EdgeInsets.symmetric(horizontal: 9.w, vertical: 5.w),
  215. child: Text(
  216. agenda.todo.value
  217. ? StringName.talkTodoCancelMine.tr
  218. : StringName.talkTodoSetMine.tr,
  219. style: TextStyle(
  220. fontSize: 13.sp,
  221. color: agenda.todo.value
  222. ? ColorName.colorPrimary
  223. : Colors.white),
  224. ),
  225. );
  226. }),
  227. )
  228. ],
  229. ),
  230. );
  231. }).toList() ??
  232. [];
  233. }
  234. List<Widget> getTalkAgendaEditModelList(List<Agenda>? list,
  235. {void Function(Agenda agenda)? removeCallback}) {
  236. return list?.map((agenda) {
  237. return GestureDetector(
  238. onTap: () {
  239. removeCallback?.call(agenda);
  240. },
  241. child: Padding(
  242. padding: EdgeInsets.only(
  243. left: 12.w, right: 12.w, top: 2.h, bottom: 10.h),
  244. child: Row(
  245. crossAxisAlignment: CrossAxisAlignment.start,
  246. children: [
  247. SizedBox(
  248. width: 18.w,
  249. height: 18.w,
  250. child: Assets.images.iconTalkRemoveAgenda.image()),
  251. SizedBox(width: 4.w),
  252. Expanded(
  253. child: Text(agenda.content.orEmpty,
  254. style: TextStyle(
  255. fontSize: 14.sp, color: ColorName.primaryTextColor)),
  256. ),
  257. ],
  258. ),
  259. ),
  260. );
  261. }).toList() ??
  262. [];
  263. }
  264. List<Widget> getTalkAgendaNormalList(List<Agenda>? list) {
  265. return list?.map((agenda) {
  266. return Padding(
  267. padding:
  268. EdgeInsets.only(left: 12.w, right: 12.w, top: 2.h, bottom: 10.h),
  269. child: Row(
  270. crossAxisAlignment: CrossAxisAlignment.start,
  271. children: [
  272. Container(
  273. width: 8.w,
  274. height: 8.w,
  275. margin: EdgeInsets.only(top: 7.h),
  276. decoration: BoxDecoration(
  277. color: ColorName.colorPrimary.withOpacity(0.5),
  278. shape: BoxShape.circle,
  279. ),
  280. ),
  281. SizedBox(width: 4.w),
  282. Expanded(
  283. child: Text(agenda.content.orEmpty,
  284. style: TextStyle(
  285. fontSize: 14.sp, color: ColorName.primaryTextColor)),
  286. ),
  287. ],
  288. ),
  289. );
  290. }).toList() ??
  291. [];
  292. }