common_view.dart 11 KB

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