view.dart 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. import 'package:electronic_assistant/base/base_page.dart';
  2. import 'package:electronic_assistant/module/talk/controller.dart';
  3. import 'package:electronic_assistant/module/talk/original/view.dart';
  4. import 'package:electronic_assistant/module/talk/summary/view.dart';
  5. import 'package:electronic_assistant/module/talk/todo/view.dart';
  6. import 'package:electronic_assistant/resource/colors.gen.dart';
  7. import 'package:electronic_assistant/utils/expand.dart';
  8. import 'package:electronic_assistant/utils/fixed_size_tab_indicator.dart';
  9. import 'package:flutter/cupertino.dart';
  10. import 'package:flutter/material.dart';
  11. import 'package:flutter/services.dart';
  12. import 'package:flutter_screenutil/flutter_screenutil.dart';
  13. import 'package:get/get.dart';
  14. import 'package:get/get_core/src/get_main.dart';
  15. import '../../data/bean/talks.dart';
  16. import '../../resource/assets.gen.dart';
  17. import '../../resource/string.gen.dart';
  18. import '../../router/app_pages.dart';
  19. import '../../utils/common_style.dart';
  20. class TalkPage extends BasePage<TalkController> {
  21. TalkPage({super.key});
  22. static void start(TalkBean item) {
  23. Get.toNamed(RoutePath.talkDetail, arguments: item);
  24. }
  25. @override
  26. Widget buildBody(BuildContext context) {
  27. return Stack(
  28. children: [
  29. buildTopGradient(),
  30. Column(
  31. crossAxisAlignment: CrossAxisAlignment.start,
  32. children: [
  33. AppBar(
  34. systemOverlayStyle: SystemUiOverlayStyle.dark,
  35. backgroundColor: Colors.transparent,
  36. leading: IconButton(
  37. icon: SizedBox(
  38. width: 24.w,
  39. height: 24.w,
  40. child: Assets.images.iconBack.image()),
  41. // Custom icon
  42. onPressed: () {
  43. Get.back();
  44. },
  45. ),
  46. ),
  47. Padding(
  48. padding: EdgeInsets.symmetric(horizontal: 12.w),
  49. child: Column(
  50. crossAxisAlignment: CrossAxisAlignment.start,
  51. children: [
  52. SizedBox(height: 8.h),
  53. Text(controller.talkBean.value.title.orEmpty,
  54. style: TextStyle(
  55. fontSize: 22.sp,
  56. fontWeight: FontWeight.bold,
  57. color: ColorName.primaryTextColor)),
  58. SizedBox(height: 4.h),
  59. Text(controller.talkBean.value.createTime.orEmpty,
  60. style: TextStyle(
  61. fontSize: 12.sp,
  62. color: ColorName.secondaryTextColor)),
  63. SizedBox(height: 14.h),
  64. ],
  65. ),
  66. ),
  67. Expanded(
  68. child: DefaultTabController(
  69. length: controller.tabBeans.length,
  70. child: Column(
  71. children: [
  72. Container(
  73. decoration: const BoxDecoration(
  74. color: Colors.white,
  75. borderRadius: BorderRadius.only(
  76. topLeft: Radius.circular(12),
  77. topRight: Radius.circular(12),
  78. )),
  79. child: TabBar(
  80. labelStyle: TextStyle(
  81. fontSize: 16.sp, fontWeight: FontWeight.bold),
  82. unselectedLabelStyle: TextStyle(fontSize: 14.sp),
  83. labelColor: ColorName.primaryTextColor,
  84. unselectedLabelColor:
  85. ColorName.secondaryTextColor,
  86. labelPadding: EdgeInsets.only(top: 4.h),
  87. dividerHeight: 0,
  88. indicator: FixedSizeTabIndicator(
  89. width: 16.w,
  90. height: 3.w,
  91. radius: 3,
  92. color: ColorName.colorPrimary),
  93. tabs: controller.tabBeans
  94. .map((txt) => Tab(text: txt))
  95. .toList()),
  96. ),
  97. Divider(
  98. height: 1,
  99. color: const Color(0xFFf6f6f6),
  100. indent: 12.w,
  101. endIndent: 12.w),
  102. SizedBox(height: 8.h),
  103. buildTalkContentView()
  104. ],
  105. )))
  106. ],
  107. )
  108. ],
  109. );
  110. }
  111. @override
  112. bool immersive() {
  113. return true;
  114. }
  115. Container buildTopGradient() {
  116. return Container(
  117. width: 1.sw,
  118. height: 180.h,
  119. decoration: BoxDecoration(
  120. gradient: LinearGradient(
  121. colors: ['#E1E9FF'.toColor(), '#F9FAFE'.toColor()],
  122. begin: Alignment.topCenter,
  123. end: Alignment.bottomCenter,
  124. stops: const [0.3, 1.0],
  125. ),
  126. ));
  127. }
  128. Widget buildTalkContentView() {
  129. return Obx(() {
  130. if (controller.analyseStatus.value == TalkStatus.notAnalysis) {
  131. if (controller.isShowElectricLow.value) {
  132. return buildElectricLowView();
  133. } else {
  134. return buildNotAnalysisView();
  135. }
  136. } else {
  137. return Expanded(
  138. child: TabBarView(
  139. children: controller.pages,
  140. ),
  141. );
  142. }
  143. });
  144. }
  145. Widget buildNotAnalysisView() {
  146. return SizedBox(
  147. width: double.infinity,
  148. child: Column(
  149. children: [
  150. SizedBox(height: 119.h),
  151. SizedBox(
  152. width: 100.w,
  153. height: 100.w,
  154. child: Assets.images.iconTalkSummaryUnanalyzed.image()),
  155. SizedBox(height: 4.h),
  156. Text(StringName.talkUnAnalyzed.tr,
  157. style: TextStyle(
  158. fontSize: 15.sp, color: ColorName.primaryTextColor)),
  159. SizedBox(height: 2.h),
  160. Text(StringName.talkUnAnalyzedTips.tr,
  161. style: TextStyle(
  162. fontSize: 12.sp, color: ColorName.secondaryTextColor)),
  163. SizedBox(height: 24.h),
  164. GestureDetector(
  165. onTap: () {
  166. controller.checkCanAnalyze();
  167. },
  168. child: Container(
  169. decoration: getPrimaryBtnDecoration(8),
  170. width: 240.w,
  171. height: 48.w,
  172. child: Center(
  173. child: Text(
  174. StringName.talkAnalyzedBtnTxt.tr,
  175. style: TextStyle(fontSize: 16.sp, color: ColorName.white),
  176. ),
  177. ),
  178. ),
  179. )
  180. ],
  181. ),
  182. );
  183. }
  184. Widget buildElectricLowView() {
  185. return Container(
  186. color: const Color(0xFFDFE4FC),
  187. padding: EdgeInsets.only(left: 16.w, right: 12.w, top: 8.h, bottom: 8.h),
  188. child: Row(
  189. children: [
  190. SizedBox(
  191. width: 46.w,
  192. height: 56.w,
  193. child: Assets.images.iconTalkElectricLow.image()),
  194. SizedBox(width: 10.w),
  195. IntrinsicHeight(
  196. child: Column(
  197. crossAxisAlignment: CrossAxisAlignment.start,
  198. children: [
  199. SizedBox(
  200. width: 90.w,
  201. height: 21.w,
  202. child: Assets.images.iconTalkElectricLowTxt.image()),
  203. SizedBox(width: 1.w),
  204. Text(StringName.talkElectricLow.tr,
  205. style: TextStyle(
  206. fontSize: 12.sp, color: ColorName.secondaryTextColor)),
  207. ],
  208. ),
  209. ),
  210. const Spacer(),
  211. GestureDetector(
  212. onTap: () {
  213. controller.goElectricStore();
  214. },
  215. child: Container(
  216. decoration: getPrimaryBtnDecoration(8),
  217. width: 100.w,
  218. height: 36.w,
  219. child: Center(
  220. child: Text(StringName.talkGoStore.tr,
  221. style:
  222. TextStyle(fontSize: 16.sp, color: ColorName.white)),
  223. )),
  224. )
  225. ],
  226. ),
  227. );
  228. }
  229. }