common_view.dart 14 KB

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