common_view.dart 12 KB

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