common_view.dart 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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 getTalkUploadingView() {
  12. return SizedBox(
  13. width: double.infinity,
  14. child: Column(
  15. children: [
  16. SizedBox(height: 138.h),
  17. SizedBox(
  18. width: 100.w,
  19. height: 100.w,
  20. child: Assets.anim.talkAnalyse.image()),
  21. SizedBox(height: 12.h),
  22. Text(StringName.talkUploadingTips.tr,
  23. style:
  24. TextStyle(fontSize: 14.sp, color: ColorName.secondaryTextColor))
  25. ],
  26. ),
  27. );
  28. }
  29. Widget getTalkLoadingView() {
  30. return SizedBox(
  31. width: double.infinity,
  32. child: Column(
  33. children: [
  34. SizedBox(height: 138.h),
  35. SizedBox(
  36. width: 100.w,
  37. height: 100.w,
  38. child: Assets.anim.talkAnalyse.image()),
  39. SizedBox(height: 12.h),
  40. Text(StringName.talkAnalyzing.tr,
  41. style:
  42. TextStyle(fontSize: 14.sp, color: ColorName.secondaryTextColor))
  43. ],
  44. ),
  45. );
  46. }
  47. Widget getTalkFailView() {
  48. return SizedBox(
  49. width: double.infinity,
  50. child: Column(
  51. children: [
  52. SizedBox(height: 111.h),
  53. SizedBox(
  54. width: 100.w,
  55. height: 100.w,
  56. child: Assets.images.iconTalkAnalyseFail.image()),
  57. SizedBox(height: 4.h),
  58. Text(StringName.talkAnalyseFail.tr,
  59. style:
  60. TextStyle(fontSize: 15.sp, color: ColorName.primaryTextColor)),
  61. SizedBox(height: 2.h),
  62. ],
  63. ),
  64. );
  65. }
  66. typedef TodoItemBuilder = List<Widget> Function(List<Agenda>? list);
  67. Widget getTodoItemView(AgendaListAllBean agenda, TodoItemBuilder todoBuilder) {
  68. return Container(
  69. decoration: BoxDecoration(
  70. color: ColorName.colorPrimary,
  71. borderRadius: BorderRadius.circular(6),
  72. ),
  73. child: Builder(builder: (context) {
  74. return Theme(
  75. data: Theme.of(context).copyWith(
  76. splashFactory: NoSplash.splashFactory,
  77. ),
  78. child: Container(
  79. margin: EdgeInsets.only(left: 4.w),
  80. decoration: BoxDecoration(
  81. color: "#F6F5F8".toColor(),
  82. borderRadius: const BorderRadius.only(
  83. topRight: Radius.circular(6),
  84. bottomRight: Radius.circular(6),
  85. ),
  86. ),
  87. child: ExpansionTile(
  88. initiallyExpanded: true,
  89. onExpansionChanged: (value) {
  90. agenda.isExpanded.value = value;
  91. },
  92. shape: RoundedRectangleBorder(
  93. borderRadius: BorderRadius.circular(4.0),
  94. side: const BorderSide(color: Colors.transparent),
  95. ),
  96. collapsedShape: RoundedRectangleBorder(
  97. borderRadius: BorderRadius.circular(4.0),
  98. side: const BorderSide(color: Colors.transparent),
  99. ),
  100. minTileHeight: 46.h,
  101. showTrailingIcon: false,
  102. childrenPadding: EdgeInsets.zero,
  103. tilePadding: EdgeInsets.zero,
  104. title: Row(
  105. children: [
  106. SizedBox(width: 12.w),
  107. Text(agenda.name.orEmpty,
  108. style: TextStyle(
  109. fontSize: 15.sp,
  110. color: ColorName.primaryTextColor,
  111. fontWeight: FontWeight.bold)),
  112. const Spacer(),
  113. Obx(() {
  114. return Row(
  115. children: [
  116. Text(
  117. '${agenda.list?.length}${StringName.talkTodoItem.tr}',
  118. style: TextStyle(
  119. fontSize: 15.sp,
  120. color: ColorName.secondaryTextColor),
  121. ),
  122. SizedBox(width: 3.w),
  123. SizedBox(
  124. width: 16.w,
  125. height: 16.w,
  126. child: agenda.isExpanded.value
  127. ? Assets.images.iconTalkExpand.image()
  128. : Assets.images.iconTalkCollapse.image()),
  129. ],
  130. );
  131. }),
  132. SizedBox(width: 12.w),
  133. ],
  134. ),
  135. children: todoBuilder(agenda.list),
  136. ),
  137. ),
  138. );
  139. }),
  140. );
  141. }
  142. typedef TodoItemClick = void Function(Agenda? agenda);
  143. List<Widget> getTalkAgendaSettingList(List<Agenda>? list,
  144. {TodoItemClick? itemClick}) {
  145. return list?.map((agenda) {
  146. return Padding(
  147. padding:
  148. EdgeInsets.only(left: 12.w, right: 12.w, top: 2.h, bottom: 10.h),
  149. child: Row(
  150. crossAxisAlignment: CrossAxisAlignment.center,
  151. children: [
  152. Expanded(
  153. child: Row(
  154. crossAxisAlignment: CrossAxisAlignment.start,
  155. children: [
  156. Container(
  157. width: 8.w,
  158. height: 8.w,
  159. margin: EdgeInsets.only(top: 7.h),
  160. decoration: BoxDecoration(
  161. color: ColorName.colorPrimary.withOpacity(0.5),
  162. shape: BoxShape.circle,
  163. ),
  164. ),
  165. SizedBox(width: 4.w),
  166. Expanded(
  167. child: Text(agenda.content.orEmpty,
  168. style: TextStyle(
  169. fontSize: 14.sp,
  170. color: ColorName.primaryTextColor)),
  171. ),
  172. ]),
  173. ),
  174. SizedBox(width: 20.w),
  175. GestureDetector(
  176. onTap: () {
  177. itemClick?.call(agenda);
  178. },
  179. child: Obx(() {
  180. return Container(
  181. decoration: BoxDecoration(
  182. color: agenda.todo.value
  183. ? "#E7E9F6".toColor()
  184. : ColorName.colorPrimary,
  185. borderRadius: BorderRadius.circular(6),
  186. ),
  187. padding:
  188. EdgeInsets.symmetric(horizontal: 9.w, vertical: 5.w),
  189. child: Text(
  190. agenda.todo.value
  191. ? StringName.talkTodoCancelMine.tr
  192. : StringName.talkTodoSetMine.tr,
  193. style: TextStyle(
  194. fontSize: 13.sp,
  195. color: agenda.todo.value
  196. ? ColorName.colorPrimary
  197. : Colors.white),
  198. ),
  199. );
  200. }),
  201. )
  202. ],
  203. ),
  204. );
  205. }).toList() ??
  206. [];
  207. }
  208. List<Widget> getTalkAgendaEditModelList(List<Agenda>? list,
  209. {void Function(Agenda agenda)? removeCallback}) {
  210. return list?.map((agenda) {
  211. return GestureDetector(
  212. onTap: () {
  213. removeCallback?.call(agenda);
  214. },
  215. child: Padding(
  216. padding: EdgeInsets.only(
  217. left: 12.w, right: 12.w, top: 2.h, bottom: 10.h),
  218. child: Row(
  219. crossAxisAlignment: CrossAxisAlignment.start,
  220. children: [
  221. SizedBox(
  222. width: 18.w,
  223. height: 18.w,
  224. child: Assets.images.iconTalkRemoveAgenda.image()),
  225. SizedBox(width: 4.w),
  226. Expanded(
  227. child: Text(agenda.content.orEmpty,
  228. style: TextStyle(
  229. fontSize: 14.sp, color: ColorName.primaryTextColor)),
  230. ),
  231. ],
  232. ),
  233. ),
  234. );
  235. }).toList() ??
  236. [];
  237. }
  238. List<Widget> getTalkAgendaNormalList(List<Agenda>? list) {
  239. return list?.map((agenda) {
  240. return Padding(
  241. padding:
  242. EdgeInsets.only(left: 12.w, right: 12.w, top: 2.h, bottom: 10.h),
  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, color: ColorName.primaryTextColor)),
  260. ),
  261. ],
  262. ),
  263. );
  264. }).toList() ??
  265. [];
  266. }