common_view.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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 '../../data/bean/template_bean.dart';
  10. import '../../resource/assets.gen.dart';
  11. import '../../resource/colors.gen.dart';
  12. import '../../resource/string.gen.dart';
  13. import '../../utils/gradient_rounded_linear_progress_bar.dart';
  14. Widget getAddAgendaView(String addTxt, {VoidCallback? onClick}) {
  15. return GestureDetector(
  16. onTap: onClick,
  17. child: Container(
  18. decoration: BoxDecoration(
  19. color: "#F6F5F8".toColor(),
  20. border: Border.all(color: '#EAE5EF'.toColor(), width: 1),
  21. borderRadius: BorderRadius.circular(8.w)),
  22. margin: EdgeInsets.only(bottom: 8.h, top: 6.h),
  23. padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 11.w),
  24. child: Row(
  25. children: [
  26. SizedBox(
  27. width: 22.w,
  28. height: 22.w,
  29. child: Assets.images.iconTalkAddAdenda.image()),
  30. SizedBox(width: 8.w),
  31. Text(
  32. addTxt,
  33. style: TextStyle(fontSize: 14.sp, color: ColorName.colorPrimary),
  34. )
  35. ],
  36. ),
  37. ),
  38. );
  39. }
  40. //
  41. Widget getTalkAnalyseView(String analyseTxt, double progress) {
  42. return SizedBox(
  43. width: double.infinity,
  44. child: Column(
  45. children: [
  46. SizedBox(height: 138.h),
  47. SizedBox(
  48. width: 100.w,
  49. height: 100.w,
  50. child: Assets.anim.talkAnalyse.image()),
  51. SizedBox(height: 24.h),
  52. GradientRoundedLinearProgressBar(
  53. height: 12.w,
  54. width: 220.w,
  55. borderRadius: 10,
  56. backgroundColor: '#F6F5F8'.toColor(),
  57. progress: progress / 100,
  58. gradientColors: ["#9075FF".toColor(), "#4366FF".toColor()],
  59. ),
  60. SizedBox(height: 10.h),
  61. Text('$analyseTxt $progress%',
  62. style:
  63. TextStyle(fontSize: 12.sp, color: ColorName.secondaryTextColor))
  64. ],
  65. ),
  66. );
  67. }
  68. Widget getTalkUploadingView(RxDouble progress) {
  69. return SizedBox(
  70. width: double.infinity,
  71. child: Column(
  72. children: [
  73. SizedBox(height: 138.h),
  74. SizedBox(
  75. width: 100.w,
  76. height: 100.w,
  77. child: Assets.anim.talkAnalyse.image()),
  78. SizedBox(height: 3.h),
  79. Text('谈话上传中',
  80. style:
  81. TextStyle(fontSize: 15.sp, color: ColorName.primaryTextColor)),
  82. SizedBox(height: 3.h),
  83. Obx(() {
  84. return Text(
  85. '谈话已上传${(progress.value * 100).toFormattedString(1)}%,请稍后查看...',
  86. style: TextStyle(
  87. fontSize: 12.sp, color: ColorName.secondaryTextColor));
  88. })
  89. ],
  90. ),
  91. );
  92. }
  93. Widget getTalkLoadingView() {
  94. return SizedBox(
  95. width: double.infinity,
  96. child: Column(
  97. children: [
  98. SizedBox(height: 138.h),
  99. SizedBox(
  100. width: 100.w,
  101. height: 100.w,
  102. child: Assets.anim.talkAnalyse.image()),
  103. SizedBox(height: 12.h),
  104. Text(StringName.talkAnalyzing.tr,
  105. style:
  106. TextStyle(fontSize: 14.sp, color: ColorName.secondaryTextColor))
  107. ],
  108. ),
  109. );
  110. }
  111. Widget getTalkFailView() {
  112. return SizedBox(
  113. width: double.infinity,
  114. child: Column(
  115. children: [
  116. SizedBox(height: 111.h),
  117. SizedBox(
  118. width: 100.w,
  119. height: 100.w,
  120. child: Assets.images.iconTalkAnalyseFail.image()),
  121. SizedBox(height: 4.h),
  122. Text(
  123. StringName.talkAnalyseFail.tr,
  124. style: TextStyle(
  125. fontSize: 15.sp,
  126. color: ColorName.primaryTextColor,
  127. fontWeight: FontWeight.w500,
  128. ),
  129. ),
  130. SizedBox(height: 2.h),
  131. Row(
  132. mainAxisAlignment: MainAxisAlignment.center,
  133. children: [
  134. Text(StringName.talkAnalyseSummaryFail.tr,
  135. style: TextStyle(
  136. fontSize: 12.sp, color: ColorName.secondaryTextColor)),
  137. GestureDetector(
  138. onTap: () {
  139. Get.toNamed(RoutePath.complaintOpinion, arguments: "意见建议");
  140. },
  141. child: Text(
  142. StringName.talkAnalyseFailFeedback.tr,
  143. style: TextStyle(
  144. color: "#102FDE".toColor(),
  145. fontSize: 12.sp,
  146. decoration: TextDecoration.underline,
  147. decorationColor: "#102FDE".toColor(),
  148. ),
  149. ),
  150. )
  151. ],
  152. ),
  153. ],
  154. ),
  155. );
  156. }
  157. typedef TodoItemBuilder = List<Widget> Function(List<Agenda>? list);
  158. Widget getTodoItemView(AgendaListAllBean agenda, TodoItemBuilder todoBuilder) {
  159. return Container(
  160. decoration: BoxDecoration(
  161. color: ColorName.colorPrimary,
  162. borderRadius: BorderRadius.circular(6),
  163. ),
  164. child: Builder(builder: (context) {
  165. return Theme(
  166. data: Theme.of(context).copyWith(
  167. splashFactory: NoSplash.splashFactory,
  168. ),
  169. child: Container(
  170. margin: EdgeInsets.only(left: 4.w),
  171. decoration: BoxDecoration(
  172. color: "#F6F5F8".toColor(),
  173. borderRadius: const BorderRadius.only(
  174. topRight: Radius.circular(6),
  175. bottomRight: Radius.circular(6),
  176. ),
  177. ),
  178. child: ExpansionTile(
  179. initiallyExpanded: true,
  180. onExpansionChanged: (value) {
  181. agenda.isExpanded.value = value;
  182. },
  183. shape: RoundedRectangleBorder(
  184. borderRadius: BorderRadius.circular(4.0),
  185. side: const BorderSide(color: Colors.transparent),
  186. ),
  187. collapsedShape: RoundedRectangleBorder(
  188. borderRadius: BorderRadius.circular(4.0),
  189. side: const BorderSide(color: Colors.transparent),
  190. ),
  191. minTileHeight: 46.h,
  192. showTrailingIcon: false,
  193. childrenPadding: EdgeInsets.zero,
  194. tilePadding: EdgeInsets.zero,
  195. title: Row(
  196. children: [
  197. SizedBox(width: 12.w),
  198. Text(agenda.name.orEmpty,
  199. style: TextStyle(
  200. fontSize: 15.sp,
  201. color: ColorName.primaryTextColor,
  202. fontWeight: FontWeight.bold)),
  203. const Spacer(),
  204. Obx(() {
  205. return Row(
  206. children: [
  207. Text(
  208. '${agenda.list?.length}${StringName.talkTodoItem.tr}',
  209. style: TextStyle(
  210. fontSize: 15.sp,
  211. color: ColorName.secondaryTextColor),
  212. ),
  213. SizedBox(width: 3.w),
  214. SizedBox(
  215. width: 16.w,
  216. height: 16.w,
  217. child: agenda.isExpanded.value
  218. ? Assets.images.iconTalkExpand.image()
  219. : Assets.images.iconTalkCollapse.image()),
  220. ],
  221. );
  222. }),
  223. SizedBox(width: 12.w),
  224. ],
  225. ),
  226. children: todoBuilder(agenda.list),
  227. ),
  228. ),
  229. );
  230. }),
  231. );
  232. }
  233. typedef TodoItemClick = void Function(Agenda? agenda);
  234. List<Widget> getTalkAgendaSettingList(List<Agenda>? list,
  235. {TodoItemClick? itemClick}) {
  236. return list?.map((agenda) {
  237. return Padding(
  238. padding:
  239. EdgeInsets.only(left: 12.w, right: 12.w, top: 2.h, bottom: 10.h),
  240. child: Row(
  241. crossAxisAlignment: CrossAxisAlignment.center,
  242. children: [
  243. Expanded(
  244. child: Row(
  245. crossAxisAlignment: CrossAxisAlignment.start,
  246. children: [
  247. Container(
  248. width: 8.w,
  249. height: 8.w,
  250. margin: EdgeInsets.only(top: 7.h),
  251. decoration: BoxDecoration(
  252. color: ColorName.colorPrimary.withOpacity(0.5),
  253. shape: BoxShape.circle,
  254. ),
  255. ),
  256. SizedBox(width: 4.w),
  257. Expanded(
  258. child: Text(agenda.content.orEmpty,
  259. style: TextStyle(
  260. fontSize: 14.sp,
  261. color: ColorName.primaryTextColor)),
  262. ),
  263. ]),
  264. ),
  265. SizedBox(width: 20.w),
  266. GestureDetector(
  267. onTap: () {
  268. itemClick?.call(agenda);
  269. },
  270. child: Obx(() {
  271. return Container(
  272. decoration: BoxDecoration(
  273. color: agenda.todo.value
  274. ? "#E7E9F6".toColor()
  275. : ColorName.colorPrimary,
  276. borderRadius: BorderRadius.circular(6),
  277. ),
  278. padding:
  279. EdgeInsets.symmetric(horizontal: 9.w, vertical: 5.w),
  280. child: Text(
  281. agenda.todo.value
  282. ? StringName.talkTodoCancelMine.tr
  283. : StringName.talkTodoSetMine.tr,
  284. style: TextStyle(
  285. fontSize: 13.sp,
  286. color: agenda.todo.value
  287. ? ColorName.colorPrimary
  288. : Colors.white),
  289. ),
  290. );
  291. }),
  292. )
  293. ],
  294. ),
  295. );
  296. }).toList() ??
  297. [];
  298. }
  299. List<Widget> getTalkAgendaEditModelList(List<Agenda>? list,
  300. {void Function(Agenda agenda)? removeCallback}) {
  301. return list?.map((agenda) {
  302. return GestureDetector(
  303. onTap: () {
  304. removeCallback?.call(agenda);
  305. },
  306. child: Padding(
  307. padding: EdgeInsets.only(
  308. left: 12.w, right: 12.w, top: 2.h, bottom: 10.h),
  309. child: Row(
  310. crossAxisAlignment: CrossAxisAlignment.start,
  311. children: [
  312. SizedBox(
  313. width: 18.w,
  314. height: 18.w,
  315. child: Assets.images.iconTalkRemoveAgenda.image()),
  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. );
  326. }).toList() ??
  327. [];
  328. }
  329. List<Widget> getTalkAgendaNormalList(List<Agenda>? list) {
  330. return list?.map((agenda) {
  331. return Padding(
  332. padding:
  333. EdgeInsets.only(left: 12.w, right: 12.w, top: 2.h, bottom: 10.h),
  334. child: Row(
  335. crossAxisAlignment: CrossAxisAlignment.start,
  336. children: [
  337. Container(
  338. width: 8.w,
  339. height: 8.w,
  340. margin: EdgeInsets.only(top: 7.h),
  341. decoration: BoxDecoration(
  342. color: ColorName.colorPrimary.withOpacity(0.5),
  343. shape: BoxShape.circle,
  344. ),
  345. ),
  346. SizedBox(width: 4.w),
  347. Expanded(
  348. child: Text(agenda.content.orEmpty,
  349. style: TextStyle(
  350. fontSize: 14.sp, color: ColorName.primaryTextColor)),
  351. ),
  352. ],
  353. ),
  354. );
  355. }).toList() ??
  356. [];
  357. }
  358. Widget buildTemplateView(List<TemplateBean>? templateList, int? id,
  359. {bool? isShowAdd, VoidCallback? addCallback}) {
  360. return SizedBox(
  361. height: 28.h,
  362. child: ListView(
  363. scrollDirection: Axis.horizontal,
  364. shrinkWrap: true,
  365. children: [
  366. SizedBox(width: 12.w),
  367. for (var item in templateList ?? <TemplateBean>[])
  368. Container(
  369. height: double.infinity,
  370. decoration: item.id == id
  371. ? BoxDecoration(
  372. color: ColorName.colorPrimary,
  373. borderRadius: BorderRadius.circular(6.w),
  374. )
  375. : BoxDecoration(
  376. borderRadius: BorderRadius.circular(6.w),
  377. color: "#FAF9FB".toColor(),
  378. border: Border.all(color: '#F2EFF5'.toColor(), width: 1.w),
  379. ),
  380. margin: EdgeInsets.only(right: 8.w),
  381. padding: EdgeInsets.symmetric(horizontal: 8.w),
  382. child: Center(
  383. child: Text(item.name ?? '',
  384. style: TextStyle(
  385. height: 1,
  386. fontSize: 13.sp,
  387. color: item.id == id
  388. ? ColorName.white
  389. : ColorName.secondaryTextColor)),
  390. ),
  391. ),
  392. _buildAddTemplateView(isShowAdd, addCallback)
  393. ],
  394. ),
  395. );
  396. }
  397. Widget _buildAddTemplateView(bool? isShowAdd, VoidCallback? addCallback) {
  398. return Container(
  399. height: double.infinity,
  400. decoration: BoxDecoration(
  401. color: "#FAF9FB".toColor(),
  402. borderRadius: BorderRadius.circular(6.w),
  403. border: Border.all(color: '#F2EFF5'.toColor(), width: 1.w),
  404. ),
  405. padding: EdgeInsets.symmetric(horizontal: 8.w),
  406. child: Center(
  407. child: IntrinsicWidth(
  408. child: Row(
  409. children: [
  410. Assets.images.iconTalkAddTemplate.image(width: 16.w, height: 16.w),
  411. Text(StringName.talkAddTemplate.tr,
  412. style: TextStyle(
  413. height: 1,
  414. fontSize: 13.sp,
  415. color: ColorName.tertiaryTextColor))
  416. ],
  417. ),
  418. ),
  419. ),
  420. );
  421. }