common_view.dart 10 KB

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