common_view.dart 7.5 KB

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