| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/src/widgets/framework.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import 'package:get/get_core/src/get_main.dart';
- import 'package:location/base/base_page.dart';
- import 'package:location/data/bean/track_daily_bean.dart';
- import 'package:location/data/bean/user_info.dart';
- import 'package:location/resource/colors.gen.dart';
- import 'package:location/resource/string.gen.dart';
- import 'package:location/router/app_pages.dart';
- import 'package:location/utils/common_expand.dart';
- import 'package:lottie/lottie.dart';
- import 'package:video_player/video_player.dart';
- import '../../resource/assets.gen.dart';
- import '../../utils/common_style.dart';
- import '../../widget/animated_visibility.dart';
- import '../../widget/common_view.dart';
- import '../../widget/gradually_print_text.dart';
- import '../../widget/typewriter_text.dart';
- import 'location_analyse_controller.dart';
- class LocationAnalysePage extends BasePage<LocationAnalyseController> {
- const LocationAnalysePage({super.key});
- static void start(
- {required TrackDailyBean errorData, required UserInfo userInfo}) {
- Get.toNamed(RoutePath.locationAnalyse, arguments: {
- 'errorData': errorData,
- 'userInfo': userInfo,
- });
- }
- @override
- bool immersive() {
- return true;
- }
- @override
- Widget buildBody(BuildContext context) {
- return Container(
- width: double.infinity,
- height: double.infinity,
- decoration: BoxDecoration(
- gradient: LinearGradient(colors: [
- ColorName.white,
- '#D8D8FE'.color,
- ], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
- child: Stack(
- children: [buildBackBtnView(), buildAnalyseView()],
- ),
- );
- }
- Widget buildAnalyseView() {
- return SizedBox(
- width: double.infinity,
- height: double.infinity,
- child: SingleChildScrollView(
- child: Column(
- children: [
- buildAIAnalyseView(),
- SizedBox(height: 10.w),
- buildTrackAnalyseHeaderView(),
- SizedBox(height: 8.w),
- buildAnalyseResultView(),
- SizedBox(height: 30.w),
- ],
- )),
- );
- }
- Widget buildAnalyseResultView() {
- return Obx(() {
- return AnimatedOpacity(
- duration: const Duration(milliseconds: 500),
- opacity: controller.isShowAnalyseResult ? 1.0 : 0.0,
- child: Container(
- padding:
- EdgeInsets.only(left: 11.w, right: 11.w, top: 20.w, bottom: 20.w),
- margin: EdgeInsets.symmetric(horizontal: 10.w),
- decoration: BoxDecoration(
- color: ColorName.white,
- borderRadius: BorderRadius.circular(12.w),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Assets.images.iconTrackDailySummary.image(width: 20.w),
- SizedBox(width: 4.w),
- Text(StringName.trackAnalyseResultTitle,
- style: TextStyle(
- fontSize: 13.sp,
- color: '#333333'.color,
- fontWeight: FontWeight.bold))
- ],
- ),
- SizedBox(height: 10.w),
- Obx(() {
- if (controller.summaryError?.isNotEmpty == true) {
- return Text(controller.summaryError!,
- style:
- TextStyle(fontSize: 12.sp, color: '#FF0000'.color));
- } else {
- return GraduallyPrintText(
- graduallyController: controller.graduallyController,
- textStyle:
- TextStyle(fontSize: 12.sp, color: '#333333'.color),
- );
- }
- }),
- ],
- ),
- ),
- );
- });
- }
- Widget buildTrackAnalyseHeaderView() {
- return SizedBox(
- width: double.infinity,
- child: Stack(
- children: [
- buildHeaderContentView(),
- Positioned(
- top: 8.w,
- left: 20.w,
- child: Container(
- width: 64.w,
- height: 64.w,
- padding: EdgeInsets.all(2.w),
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: ColorName.white,
- ),
- child: buildCustomAvatarOrDefaultAvatarView(
- size: double.infinity,
- avatar: controller.userInfo?.avatar,
- isMine: controller.userInfo?.isMine == true,
- ),
- ),
- ),
- buildAnalyseBtn(),
- ],
- ),
- );
- }
- Widget buildHeaderContentView() {
- return Container(
- width: double.infinity,
- margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 25.w),
- decoration: BoxDecoration(
- color: ColorName.white, borderRadius: BorderRadius.circular(12.w)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- margin: EdgeInsets.only(left: 85.w, top: 8.w),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- controller.userInfo?.getUserNickName() ?? '',
- style: TextStyle(
- fontSize: 14.sp,
- color: '#333333'.color,
- fontWeight: FontWeight.bold),
- ),
- SizedBox(height: 3.w),
- Text(
- controller.errorInfo?.addr == null
- ? StringName.trackAnalyseNoNewPosition
- : '异常地点:${controller.errorInfo?.addr}',
- style: TextStyle(fontSize: 12.sp, color: '#F24D4D'.color),
- )
- ],
- ),
- ),
- SizedBox(height: 20.w),
- Container(
- margin: EdgeInsets.only(left: 14.w),
- child: Row(
- children: [
- Assets.images.iconTrackAiInterpretation
- .image(width: 16.w, height: 16.w),
- SizedBox(width: 6.w),
- Text(
- StringName.trackAnalyseAiInterpretation,
- style: TextStyle(
- fontSize: 14.sp,
- color: '#333333'.color,
- fontWeight: FontWeight.bold),
- )
- ],
- ),
- ),
- SizedBox(height: 10.w),
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 12.w),
- child: TypewriterText(
- text: StringName.trackAnalyseAiInterpretationDetails,
- style: TextStyle(fontSize: 11.sp, color: '#666666'.color),
- onComplete: controller.onAnalyseTextComplete,
- ),
- ),
- SizedBox(height: 4.w),
- buildAnalyseErrorAddressView(),
- SizedBox(height: 4.w),
- Obx(() {
- return Visibility(
- visible: controller.showAnalyseRemainContent,
- child: Padding(
- padding: EdgeInsets.symmetric(horizontal: 12.w),
- child: TypewriterText(
- text: StringName.trackAnalyseAiInterpretationDetailsFinally,
- style: TextStyle(fontSize: 11.sp, color: '#666666'.color),
- onComplete: controller.onAnalyseFinishComplete,
- ),
- ),
- );
- }),
- SizedBox(height: 12.w),
- ],
- ),
- );
- }
- Widget buildAnalyseErrorAddressView() {
- return Obx(() {
- return AnimatedVisibility(
- duration: const Duration(milliseconds: 600),
- visible: controller.isShowAnalyseAddr,
- child: Column(
- children: [
- for (int i = 0; i < controller.errorAddr.length; i++) ...[
- Container(
- padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.w),
- child: Row(
- children: [
- Expanded(
- child: Text(
- controller.errorAddr[i].addr ?? '',
- style:
- TextStyle(fontSize: 11.sp, color: '#666666'.color),
- ),
- ),
- SizedBox(width: 16.w),
- Text(controller.getErrorDistance(controller.errorAddr[i]),
- style:
- TextStyle(fontSize: 11.sp, color: '#666666'.color))
- ],
- ),
- ),
- if (i < controller.errorAddr.length - 1)
- Container(width: 316.w, height: 1.w, color: '#EEEEEE'.color),
- ]
- ],
- ),
- );
- });
- }
- Widget buildAnalyseBtn() {
- return Positioned(
- top: 0,
- right: 10.w,
- child: GestureDetector(
- onTap: controller.onTrackRefreshClick,
- child: Container(
- padding: EdgeInsets.symmetric(horizontal: 11.w, vertical: 4.w),
- child: IntrinsicWidth(
- child: Row(
- children: [
- Assets.images.iconTrackAnalyseRefresh.image(width: 12.w),
- SizedBox(width: 3.w),
- Text(
- StringName.trackAnalyseRefresh,
- style: TextStyle(
- fontSize: 12.sp,
- color: '#333333'.color,
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- );
- }
- Widget buildAIAnalyseView() {
- return Stack(
- children: [
- Container(
- margin: EdgeInsets.only(bottom: 40.w),
- child:
- Assets.images.bgLocationAnalyse.image(width: double.infinity)),
- SafeArea(
- child: SizedBox(
- width: double.infinity,
- height: 317.w,
- child: Stack(
- alignment: Alignment.center,
- children: [
- buildRobotView(),
- Obx(() {
- return Visibility(
- visible: controller.keywordDelegates != null,
- child: Lottie.asset(
- controller: controller.keywordLottieController,
- Assets.anim.locationLabel,
- onLoaded: controller.locationKeywordLottieLoad,
- delegates: controller.keywordDelegates),
- );
- }),
- ],
- ),
- )),
- Positioned(
- bottom: 10.w,
- left: 0,
- right: 0,
- child: Column(
- children: [
- Obx(() {
- return Text(
- controller.isRequestedAnalyse
- ? StringName.trackAnalyseDone
- : (controller.errorInfo?.addr == null
- ? StringName.trackAnalysing
- : StringName.trackErrorAddrAnalysing),
- style: TextStyle(
- fontSize: 16.sp,
- color: '#333333'.color,
- fontWeight: FontWeight.bold),
- );
- }),
- SizedBox(height: 10.w),
- Obx(() {
- return Text(
- controller.isRequestedAnalyse
- ? StringName.trackAnalyseDoneDetail
- : StringName.trackAnalysingTips,
- style: TextStyle(
- fontSize: 13.sp,
- color: '#9D96AD'.color,
- fontWeight: FontWeight.bold),
- );
- })
- ],
- ),
- )
- ],
- );
- }
- Widget buildRobotView() {
- return SizedBox(
- width: 248.w,
- height: 248.w,
- child: Stack(
- children: [
- Assets.images.bgLocationAnalyseAi
- .image(width: double.infinity, height: double.infinity),
- Center(
- child: ClipOval(
- child: SizedBox(
- width: 144.w,
- height: 144.w,
- child: Obx(() {
- if (!controller.videoReady) {
- return SizedBox.shrink();
- }
- return Transform.scale(
- scale: 1.012, // 放大 3%,可以试试 1.01 ~ 1.05
- child: VideoPlayer(controller.locaController),
- );
- }),
- ),
- ),
- )
- ],
- ),
- );
- }
- Widget buildBackBtnView() {
- return SafeArea(
- child: GestureDetector(
- onTap: controller.back,
- child: Container(
- margin: EdgeInsets.only(top: 14.w, left: 12.w),
- decoration: BoxDecoration(boxShadow: [
- BoxShadow(
- color: Colors.black.withOpacity(0.05),
- blurRadius: 10.w,
- offset: Offset(0, 2.w),
- ),
- ]),
- child: CommonView.getBackBtnView(),
- ),
- ),
- );
- }
- }
|