location_analyse_page.dart 13 KB

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