location_analyse_page.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/src/widgets/framework.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:get/get.dart';
  6. import 'package:get/get_core/src/get_main.dart';
  7. import 'package:location/base/base_page.dart';
  8. import 'package:location/data/bean/track_daily_bean.dart';
  9. import 'package:location/data/bean/user_info.dart';
  10. import 'package:location/resource/colors.gen.dart';
  11. import 'package:location/resource/string.gen.dart';
  12. import 'package:location/router/app_pages.dart';
  13. import 'package:location/utils/common_expand.dart';
  14. import 'package:lottie/lottie.dart';
  15. import 'package:video_player/video_player.dart';
  16. import '../../resource/assets.gen.dart';
  17. import '../../utils/common_style.dart';
  18. import '../../widget/animated_visibility.dart';
  19. import '../../widget/common_view.dart';
  20. import '../../widget/gradually_print_text.dart';
  21. import '../../widget/typewriter_text.dart';
  22. import 'location_analyse_controller.dart';
  23. class LocationAnalysePage extends BasePage<LocationAnalyseController> {
  24. const LocationAnalysePage({super.key});
  25. static void start(
  26. {required TrackDailyBean errorData, required UserInfo userInfo}) {
  27. Get.toNamed(RoutePath.locationAnalyse, arguments: {
  28. 'errorData': errorData,
  29. 'userInfo': userInfo,
  30. });
  31. }
  32. @override
  33. bool immersive() {
  34. return true;
  35. }
  36. @override
  37. Widget buildBody(BuildContext context) {
  38. return Container(
  39. width: double.infinity,
  40. height: double.infinity,
  41. decoration: BoxDecoration(
  42. gradient: LinearGradient(colors: [
  43. ColorName.white,
  44. '#D8D8FE'.color,
  45. ], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
  46. child: Stack(
  47. children: [buildAnalyseView(), buildBackBtnView()],
  48. ),
  49. );
  50. }
  51. Widget buildAnalyseView() {
  52. return SizedBox(
  53. width: double.infinity,
  54. height: double.infinity,
  55. child: SingleChildScrollView(
  56. child: Column(
  57. children: [
  58. buildAIAnalyseView(),
  59. SizedBox(height: 10.w),
  60. buildTrackAnalyseHeaderView(),
  61. SizedBox(height: 8.w),
  62. buildAnalyseResultView(),
  63. SizedBox(height: 30.w),
  64. ],
  65. )),
  66. );
  67. }
  68. Widget buildAnalyseResultView() {
  69. return Obx(() {
  70. return AnimatedOpacity(
  71. duration: const Duration(milliseconds: 500),
  72. opacity: controller.isShowAnalyseResult ? 1.0 : 0.0,
  73. child: Container(
  74. padding:
  75. EdgeInsets.only(left: 11.w, right: 11.w, top: 20.w, bottom: 20.w),
  76. margin: EdgeInsets.symmetric(horizontal: 10.w),
  77. decoration: BoxDecoration(
  78. color: ColorName.white,
  79. borderRadius: BorderRadius.circular(12.w),
  80. ),
  81. child: Column(
  82. crossAxisAlignment: CrossAxisAlignment.start,
  83. children: [
  84. Row(
  85. children: [
  86. Assets.images.iconTrackDailySummary.image(width: 20.w),
  87. SizedBox(width: 4.w),
  88. Text(StringName.trackAnalyseResultTitle,
  89. style: TextStyle(
  90. fontSize: 13.sp,
  91. color: '#333333'.color,
  92. fontWeight: FontWeight.bold))
  93. ],
  94. ),
  95. SizedBox(height: 10.w),
  96. Obx(() {
  97. if (controller.summaryError?.isNotEmpty == true) {
  98. return Text(controller.summaryError!,
  99. style:
  100. TextStyle(fontSize: 12.sp, color: '#FF0000'.color));
  101. } else {
  102. return GraduallyPrintText(
  103. graduallyController: controller.graduallyController,
  104. textStyle:
  105. TextStyle(fontSize: 12.sp, color: '#333333'.color),
  106. );
  107. }
  108. }),
  109. ],
  110. ),
  111. ),
  112. );
  113. });
  114. }
  115. Widget buildTrackAnalyseHeaderView() {
  116. return SizedBox(
  117. width: double.infinity,
  118. child: Stack(
  119. children: [
  120. buildHeaderContentView(),
  121. Positioned(
  122. top: 8.w,
  123. left: 20.w,
  124. child: Container(
  125. width: 64.w,
  126. height: 64.w,
  127. padding: EdgeInsets.all(2.w),
  128. decoration: BoxDecoration(
  129. shape: BoxShape.circle,
  130. color: ColorName.white,
  131. ),
  132. child: buildCustomAvatarOrDefaultAvatarView(
  133. size: double.infinity,
  134. avatar: controller.userInfo?.avatar,
  135. isMine: controller.userInfo?.isMine == true,
  136. ),
  137. ),
  138. ),
  139. buildAnalyseBtn(),
  140. ],
  141. ),
  142. );
  143. }
  144. Widget buildHeaderContentView() {
  145. return Container(
  146. width: double.infinity,
  147. margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 25.w),
  148. decoration: BoxDecoration(
  149. color: ColorName.white, borderRadius: BorderRadius.circular(12.w)),
  150. child: Column(
  151. crossAxisAlignment: CrossAxisAlignment.start,
  152. children: [
  153. Container(
  154. margin: EdgeInsets.only(left: 85.w, top: 8.w),
  155. child: Column(
  156. crossAxisAlignment: CrossAxisAlignment.start,
  157. children: [
  158. Text(
  159. controller.userInfo?.getUserNickName() ?? '',
  160. style: TextStyle(
  161. fontSize: 14.sp,
  162. color: '#333333'.color,
  163. fontWeight: FontWeight.bold),
  164. ),
  165. SizedBox(height: 3.w),
  166. Text(
  167. controller.errorInfo?.addr == null
  168. ? StringName.trackAnalyseNoNewPosition
  169. : '异常地点:${controller.errorInfo?.addr}',
  170. style: TextStyle(fontSize: 12.sp, color: '#F24D4D'.color),
  171. )
  172. ],
  173. ),
  174. ),
  175. SizedBox(height: 20.w),
  176. Container(
  177. margin: EdgeInsets.only(left: 14.w),
  178. child: Row(
  179. children: [
  180. Assets.images.iconTrackAiInterpretation
  181. .image(width: 16.w, height: 16.w),
  182. SizedBox(width: 6.w),
  183. Text(
  184. StringName.trackAnalyseAiInterpretation,
  185. style: TextStyle(
  186. fontSize: 14.sp,
  187. color: '#333333'.color,
  188. fontWeight: FontWeight.bold),
  189. )
  190. ],
  191. ),
  192. ),
  193. SizedBox(height: 10.w),
  194. Padding(
  195. padding: EdgeInsets.symmetric(horizontal: 12.w),
  196. child: TypewriterText(
  197. text: StringName.trackAnalyseAiInterpretationDetails,
  198. style: TextStyle(fontSize: 11.sp, color: '#666666'.color),
  199. onComplete: controller.onAnalyseTextComplete,
  200. ),
  201. ),
  202. SizedBox(height: 4.w),
  203. buildAnalyseErrorAddressView(),
  204. SizedBox(height: 4.w),
  205. Obx(() {
  206. return Visibility(
  207. visible: controller.showAnalyseRemainContent,
  208. child: Padding(
  209. padding: EdgeInsets.symmetric(horizontal: 12.w),
  210. child: TypewriterText(
  211. text: StringName.trackAnalyseAiInterpretationDetailsFinally,
  212. style: TextStyle(fontSize: 11.sp, color: '#666666'.color),
  213. onComplete: controller.onAnalyseFinishComplete,
  214. ),
  215. ),
  216. );
  217. }),
  218. SizedBox(height: 12.w),
  219. ],
  220. ),
  221. );
  222. }
  223. Widget buildAnalyseErrorAddressView() {
  224. return Obx(() {
  225. return AnimatedVisibility(
  226. duration: const Duration(milliseconds: 600),
  227. visible: controller.isShowAnalyseAddr,
  228. child: Column(
  229. children: [
  230. for (int i = 0; i < controller.errorAddr.length; i++) ...[
  231. Container(
  232. padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.w),
  233. child: Row(
  234. children: [
  235. Expanded(
  236. child: Text(
  237. controller.errorAddr[i].addr ?? '',
  238. style:
  239. TextStyle(fontSize: 11.sp, color: '#666666'.color),
  240. ),
  241. ),
  242. SizedBox(width: 16.w),
  243. Text(controller.getErrorDistance(controller.errorAddr[i]),
  244. style:
  245. TextStyle(fontSize: 11.sp, color: '#666666'.color))
  246. ],
  247. ),
  248. ),
  249. if (i < controller.errorAddr.length - 1)
  250. Container(width: 316.w, height: 1.w, color: '#EEEEEE'.color),
  251. ]
  252. ],
  253. ),
  254. );
  255. });
  256. }
  257. Widget buildAnalyseBtn() {
  258. return Positioned(
  259. top: 0,
  260. right: 10.w,
  261. child: GestureDetector(
  262. onTap: controller.onTrackRefreshClick,
  263. child: Container(
  264. padding: EdgeInsets.symmetric(horizontal: 11.w, vertical: 4.w),
  265. child: IntrinsicWidth(
  266. child: Row(
  267. children: [
  268. Assets.images.iconTrackAnalyseRefresh.image(width: 12.w),
  269. SizedBox(width: 3.w),
  270. Text(
  271. StringName.trackAnalyseRefresh,
  272. style: TextStyle(
  273. fontSize: 12.sp,
  274. color: '#333333'.color,
  275. ),
  276. ),
  277. ],
  278. ),
  279. ),
  280. ),
  281. ),
  282. );
  283. }
  284. Widget buildAIAnalyseView() {
  285. return Stack(
  286. children: [
  287. Container(
  288. margin: EdgeInsets.only(bottom: 40.w),
  289. child:
  290. Assets.images.bgLocationAnalyse.image(width: double.infinity)),
  291. SafeArea(
  292. child: SizedBox(
  293. width: double.infinity,
  294. height: 317.w,
  295. child: Stack(
  296. alignment: Alignment.center,
  297. children: [
  298. buildRobotView(),
  299. Obx(() {
  300. return Visibility(
  301. visible: controller.keywordDelegates != null,
  302. child: Lottie.asset(
  303. controller: controller.keywordLottieController,
  304. Assets.anim.locationLabel,
  305. onLoaded: controller.locationKeywordLottieLoad,
  306. delegates: controller.keywordDelegates),
  307. );
  308. }),
  309. ],
  310. ),
  311. )),
  312. Positioned(
  313. bottom: 10.w,
  314. left: 0,
  315. right: 0,
  316. child: Column(
  317. children: [
  318. Obx(() {
  319. return Text(
  320. controller.isRequestedAnalyse
  321. ? StringName.trackAnalyseDone
  322. : (controller.errorInfo?.addr == null
  323. ? StringName.trackAnalysing
  324. : StringName.trackErrorAddrAnalysing),
  325. style: TextStyle(
  326. fontSize: 16.sp,
  327. color: '#333333'.color,
  328. fontWeight: FontWeight.bold),
  329. );
  330. }),
  331. SizedBox(height: 10.w),
  332. Obx(() {
  333. return Text(
  334. controller.isRequestedAnalyse
  335. ? StringName.trackAnalyseDoneDetail
  336. : StringName.trackAnalysingTips,
  337. style: TextStyle(
  338. fontSize: 13.sp,
  339. color: '#9D96AD'.color,
  340. fontWeight: FontWeight.bold),
  341. );
  342. })
  343. ],
  344. ),
  345. )
  346. ],
  347. );
  348. }
  349. Widget buildRobotView() {
  350. return SizedBox(
  351. width: 248.w,
  352. height: 248.w,
  353. child: Stack(
  354. children: [
  355. Assets.images.bgLocationAnalyseAi
  356. .image(width: double.infinity, height: double.infinity),
  357. Center(
  358. child: ClipOval(
  359. child: SizedBox(
  360. width: 144.w,
  361. height: 144.w,
  362. child: Obx(() {
  363. if (!controller.videoReady) {
  364. return SizedBox.shrink();
  365. }
  366. return Transform.scale(
  367. scale: 1.012, // 放大 3%,可以试试 1.01 ~ 1.05
  368. child: VideoPlayer(controller.locaController),
  369. );
  370. }),
  371. ),
  372. ),
  373. )
  374. ],
  375. ),
  376. );
  377. }
  378. Widget buildBackBtnView() {
  379. return SafeArea(
  380. child: GestureDetector(
  381. onTap: controller.back,
  382. child: Container(
  383. margin: EdgeInsets.only(top: 14.w, left: 12.w),
  384. decoration: BoxDecoration(boxShadow: [
  385. BoxShadow(
  386. color: Colors.black.withOpacity(0.05),
  387. blurRadius: 10.w,
  388. offset: Offset(0, 2.w),
  389. ),
  390. ]),
  391. child: CommonView.getBackBtnView(),
  392. ),
  393. ),
  394. );
  395. }
  396. }