common_view.dart 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 builder) {
  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. onExpansionChanged: (value) {
  89. agenda.isExpanded.value = value;
  90. },
  91. shape: RoundedRectangleBorder(
  92. borderRadius: BorderRadius.circular(4.0),
  93. side: const BorderSide(color: Colors.transparent),
  94. ),
  95. collapsedShape: RoundedRectangleBorder(
  96. borderRadius: BorderRadius.circular(4.0),
  97. side: const BorderSide(color: Colors.transparent),
  98. ),
  99. minTileHeight: 46.h,
  100. showTrailingIcon: false,
  101. childrenPadding: EdgeInsets.zero,
  102. tilePadding: EdgeInsets.zero,
  103. title: Row(
  104. children: [
  105. SizedBox(width: 12.w),
  106. Text(agenda.name.orEmpty,
  107. style: TextStyle(
  108. fontSize: 15.sp,
  109. color: ColorName.primaryTextColor,
  110. fontWeight: FontWeight.bold)),
  111. const Spacer(),
  112. Obx(() {
  113. return Row(
  114. children: [
  115. Text(
  116. '${agenda.list?.length}${StringName.talkTodoItem.tr}',
  117. style: TextStyle(
  118. fontSize: 15.sp,
  119. color: ColorName.secondaryTextColor),
  120. ),
  121. SizedBox(width: 3.w),
  122. SizedBox(
  123. width: 16.w,
  124. height: 16.w,
  125. child: agenda.isExpanded.value
  126. ? Assets.images.iconTalkExpand.image()
  127. : Assets.images.iconTalkCollapse.image()),
  128. ],
  129. );
  130. }),
  131. SizedBox(width: 12.w),
  132. ],
  133. ),
  134. children: builder(agenda.list),
  135. ),
  136. ),
  137. );
  138. }),
  139. );
  140. }
  141. typedef TodoItemClick = void Function(Agenda? agenda);
  142. List<Widget> getTalkAgendaSettingList(List<Agenda>? list,
  143. {TodoItemClick? itemClick}) {
  144. return list?.map((agenda) {
  145. return Padding(
  146. padding:
  147. EdgeInsets.only(left: 12.w, right: 12.w, top: 2.h, bottom: 10.h),
  148. child: Row(
  149. crossAxisAlignment: CrossAxisAlignment.center,
  150. children: [
  151. Expanded(
  152. child: Row(
  153. crossAxisAlignment: CrossAxisAlignment.start,
  154. children: [
  155. Container(
  156. width: 8.w,
  157. height: 8.w,
  158. margin: EdgeInsets.only(top: 7.h),
  159. decoration: BoxDecoration(
  160. color: ColorName.colorPrimary.withOpacity(0.5),
  161. shape: BoxShape.circle,
  162. ),
  163. ),
  164. SizedBox(width: 4.w),
  165. Expanded(
  166. child: Text(agenda.content.orEmpty,
  167. style: TextStyle(
  168. fontSize: 14.sp,
  169. color: ColorName.primaryTextColor)),
  170. ),
  171. ]),
  172. ),
  173. SizedBox(width: 20.w),
  174. GestureDetector(
  175. onTap: () {
  176. itemClick?.call(agenda);
  177. },
  178. child: Obx(() {
  179. return Container(
  180. decoration: BoxDecoration(
  181. color: agenda.todo.value
  182. ? "#E7E9F6".toColor()
  183. : ColorName.colorPrimary,
  184. borderRadius: BorderRadius.circular(6),
  185. ),
  186. padding:
  187. EdgeInsets.symmetric(horizontal: 9.w, vertical: 5.w),
  188. child: Text(
  189. agenda.todo.value
  190. ? StringName.talkTodoCancelMine.tr
  191. : StringName.talkTodoSetMine.tr,
  192. style: TextStyle(
  193. fontSize: 13.sp,
  194. color: agenda.todo.value
  195. ? ColorName.colorPrimary
  196. : Colors.white),
  197. ),
  198. );
  199. }),
  200. )
  201. ],
  202. ),
  203. );
  204. }).toList() ??
  205. [];
  206. }
  207. List<Widget> getTalkAgendaNormalList(List<Agenda>? list) {
  208. return list?.map((agenda) {
  209. return Padding(
  210. padding:
  211. EdgeInsets.only(left: 12.w, right: 12.w, top: 2.h, bottom: 10.h),
  212. child: Row(
  213. crossAxisAlignment: CrossAxisAlignment.start,
  214. children: [
  215. Container(
  216. width: 8.w,
  217. height: 8.w,
  218. margin: EdgeInsets.only(top: 7.h),
  219. decoration: BoxDecoration(
  220. color: ColorName.colorPrimary.withOpacity(0.5),
  221. shape: BoxShape.circle,
  222. ),
  223. ),
  224. SizedBox(width: 4.w),
  225. Expanded(
  226. child: Text(agenda.content.orEmpty,
  227. style: TextStyle(
  228. fontSize: 14.sp, color: ColorName.primaryTextColor)),
  229. ),
  230. ],
  231. ),
  232. );
  233. }).toList() ??
  234. [];
  235. }