| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- import 'dart:ui';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_map/flutter_map.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import 'package:location/base/base_page.dart';
- import 'package:location/data/bean/user_info.dart';
- import 'package:location/module/main/main_controller.dart';
- import 'package:location/module/main/view.dart';
- import 'package:location/resource/assets.gen.dart';
- import 'package:location/resource/colors.gen.dart';
- import 'package:location/resource/string.gen.dart';
- import 'package:location/utils/common_expand.dart';
- import 'package:sliding_sheet2/sliding_sheet2.dart';
- import '../../data/consts/constants.dart';
- import '../../router/app_pages.dart';
- import '../../utils/common_style.dart';
- import '../../utils/common_util.dart';
- import '../../widget/marquee_text.dart';
- import '../../widget/relative_time_text.dart';
- import 'main_friend_item.dart';
- class MainPage extends BasePage<MainController> {
- const MainPage({super.key});
- static start({bool? isNotClear, Map<String, dynamic>? arguments}) {
- if (isNotClear == null || !isNotClear) {
- Get.offAllNamed(RoutePath.mainTab, arguments: arguments);
- } else {
- Get.toNamed(RoutePath.mainTab, arguments: arguments);
- }
- }
- @override
- bool immersive() {
- return true;
- }
- @override
- Widget buildBody(BuildContext context) {
- return PopScope(
- canPop: false,
- onPopInvokedWithResult: (bool didPop, dynamic result) {
- controller.onAppBack();
- },
- child: Stack(
- children: [
- buildMapView(),
- buildMapFunView(),
- buildMainBottomView(),
- buildFriendListView(),
- ],
- ),
- );
- }
- Widget buildMapView() {
- return Padding(
- padding: EdgeInsets.only(bottom: 50.h),
- child: SizedBox(
- width: double.infinity,
- child: MapWidget(
- controller: controller.mapController,
- onMarkerTap: controller.onMarkerTap,
- )),
- );
- }
- Widget buildMainBottomView() {
- return SlidingSheet(
- color: '#F9F9F9'.color,
- elevation: 10,
- shadowColor: Colors.black.withOpacity(0.1),
- cornerRadius: 18.w,
- snapSpec: SnapSpec(
- initialSnap: SnapSpec.headerFooterSnap,
- // Enable snapping. This is true by default.
- snap: true,
- // Set custom snapping points.
- snappings: [SnapSpec.headerFooterSnap, SnapSpec.expanded],
- // Define to what the snappings relate to. In this case,
- // the total available space that the sheet can expand to.
- positioning: SnapPositioning.relativeToAvailableSpace,
- ),
- footerBuilder: buildFooterBuilder,
- headerBuilder: buildHeaderBuilder,
- builder: buildTrackEntranceBuilder,
- );
- }
- Widget buildTrackEntranceBuilder(BuildContext context, SheetState state) {
- return Container(
- margin: EdgeInsets.only(left: 12.w, right: 12.w, bottom: 12.w),
- padding: EdgeInsets.only(left: 12.w, right: 12.w, top: 12.w, bottom: 9.w),
- decoration: BoxDecoration(
- color: Colors.white, borderRadius: BorderRadius.circular(20.r)),
- child: AspectRatio(
- aspectRatio: 336 / 134,
- child: Column(
- children: [
- Row(
- children: [
- Text(StringName.todaySimpleTrack,
- style: TextStyle(
- fontSize: 13.sp,
- color: '#333333'.color,
- fontWeight: FontWeight.bold)),
- Spacer(),
- Assets.images.iconMainTrackArrow
- .image(width: 10.w, height: 10.w),
- ],
- ),
- SizedBox(height: 7.w),
- Expanded(
- child: Row(
- children: [
- Container(
- margin: EdgeInsets.only(bottom: 3.w, top: 3.w),
- child: AspectRatio(
- aspectRatio: 1,
- child: Assets.images.imgTrackExample.image(),
- ),
- ),
- SizedBox(width: 10.w),
- Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- SizedBox(height: 6.w),
- getMainTrackDot('#15CBA1'.color),
- Expanded(
- child: Container(
- margin: EdgeInsets.symmetric(vertical: 4.w),
- width: 1.w,
- height: double.infinity,
- decoration: BoxDecoration(
- color: '#F0F0F0'.color,
- borderRadius: BorderRadius.circular(100.r),
- ),
- ),
- ),
- getMainTrackDot('#E94949'.color),
- SizedBox(height: 6.w),
- ],
- ),
- SizedBox(width: 8.w),
- Expanded(
- child: Column(
- children: [
- buildTrackPoint(MainTrackType.startPoint,
- '广东省广州市天河区高唐路235号靠近C栋2楼时代E-PARK'),
- Spacer(),
- buildTrackPoint(
- MainTrackType.errorPoint, '广东省广州市海珠区滨江东路驾驶花园C栋601'),
- ],
- ),
- )
- ],
- ),
- ),
- ],
- ),
- ),
- );
- }
- Widget buildFriendListView() {
- return SafeArea(
- child: Container(
- margin: EdgeInsets.only(top: 26.w),
- child: Row(
- children: [
- Expanded(child: buildMainFriendList()),
- GestureDetector(
- onTap: () {
- controller.onAddFriendClick();
- },
- child: Container(
- margin: EdgeInsets.only(right: 16.w, left: 8.w),
- child: Assets.images.iconMainAddFriend
- .image(width: 60.w, height: 60.w)),
- )
- ],
- ),
- ),
- );
- }
- Widget buildMapFunView() {
- return Positioned(
- right: 0.w,
- bottom: 230.w,
- child: Column(
- children: [
- GestureDetector(
- onTap: controller.onRefreshFriendLocationClick,
- child: Container(
- margin: EdgeInsets.only(right: 12.w),
- child: Assets.images.iconMainRefreshFriendLocation
- .image(width: 42.w, height: 42.w)),
- ),
- SizedBox(height: 14.w),
- GestureDetector(
- onTap: controller.onCurrentLocationClick,
- child: Container(
- margin: EdgeInsets.only(right: 12.w),
- child: Assets.images.iconMainRefreshMineLocation
- .image(width: 42.w, height: 42.w)),
- ),
- SizedBox(height: 20.w)
- ],
- ),
- );
- }
- Container buildTabContainer() {
- return Container(
- decoration: BoxDecoration(
- color: ColorName.white,
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(20.w),
- topRight: Radius.circular(20.w),
- ),
- boxShadow: [
- BoxShadow(
- color: ColorName.black.withOpacity(0.01),
- blurRadius: 10,
- offset: const Offset(0, -2), // changes position of shadow
- ),
- ],
- ),
- padding: EdgeInsets.only(top: 13.w, bottom: 23.w),
- child: buildMainFunList());
- }
- Widget buildMainFunList() {
- return Row(
- children: [
- Expanded(
- child: buildFunItem(
- Assets.images.iconMainFriendGuard.provider(),
- StringName.mainFriendListTab,
- () => controller.onFriendClick())),
- Expanded(child: Obx(() {
- return buildFunItem(Assets.images.iconMainNews.provider(),
- StringName.mainNewsTab, () => controller.onNewsClick(),
- isShowDot: controller.hasUnreadMessage);
- })),
- Expanded(
- child: buildFunItem(
- Assets.images.iconMainHelp.provider(),
- StringName.mainHelpTab,
- () => controller.onUrgentContactClick())),
- Expanded(
- child: buildFunItem(Assets.images.iconMainMine.provider(),
- StringName.mainMineTab, () => controller.onMineClick()))
- ],
- );
- }
- Widget buildFunItem(ImageProvider imgProvider, String title, Function() onTap,
- {bool? isShowDot}) {
- return GestureDetector(
- onTap: onTap,
- child: IntrinsicHeight(
- child: Column(
- children: [
- Stack(children: [
- SizedBox(
- width: 44.w, height: 44.w, child: Image(image: imgProvider)),
- Visibility(
- visible: isShowDot ?? false,
- child: Positioned(
- top: 6.w,
- right: 6.w,
- child: Container(
- width: 10.w,
- height: 10.w,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: '#FF333D'.color, // 背景颜色
- ),
- ),
- ),
- )
- ]),
- Text(title,
- style: TextStyle(
- fontSize: 12.sp,
- color: ColorName.black70,
- fontWeight: FontWeight.bold))
- ],
- ),
- ),
- );
- }
- Widget buildMainFriendList() {
- return SizedBox(
- height: 58.w,
- child: Obx(() {
- return ListView(
- physics: const BouncingScrollPhysics(
- parent: AlwaysScrollableScrollPhysics()),
- padding: EdgeInsets.only(left: 12.w),
- scrollDirection: Axis.horizontal,
- children: [
- for (UserInfo userInfo in controller.integrateList)
- Obx(() {
- return mainFriendItem(
- userInfo, controller.selectedFriend?.id == userInfo.id,
- onTap: () {
- controller.onSelectUserClick(userInfo);
- });
- })
- ],
- );
- }),
- );
- }
- Widget buildFooterBuilder(BuildContext context, SheetState state) {
- return buildTabContainer();
- }
- Widget buildHeaderBuilder(BuildContext context, SheetState state) {
- return IntrinsicHeight(
- child: Column(
- children: [
- SizedBox(height: 5.w),
- Container(
- width: 32.w,
- height: 3.w,
- decoration: BoxDecoration(
- color: '#D9D9D9'.color,
- borderRadius: BorderRadius.all(Radius.circular(49.w))),
- ),
- SizedBox(height: 12.w),
- buildSelectFriendInfoView(),
- SizedBox(height: 13.w)
- ],
- ),
- );
- }
- Widget buildSelectFriendInfoView() {
- return Container(
- width: 336.w,
- height: 86.w,
- decoration: BoxDecoration(
- color: ColorName.white,
- borderRadius: BorderRadius.all(Radius.circular(20.w))),
- child: Row(
- children: [
- SizedBox(width: 7.w),
- Obx(() {
- return buildCustomAvatarOrDefaultAvatarView(
- size: 50.w,
- avatar: controller.selectedFriend?.avatar,
- isMine: controller.selectedFriend?.isMine == true);
- }),
- SizedBox(width: 5.w),
- Expanded(
- child: Container(
- margin: EdgeInsets.symmetric(vertical: 15.w),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Obx(() {
- return Text(
- controller.selectedFriend?.getUserNickName() ?? '',
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 16.sp,
- color: '#202020'.color),
- );
- }),
- SizedBox(width: 7.w),
- Obx(() {
- return RelativeTimeText(
- timestamp: controller.selectedFriend?.lastLocation
- .value?.lastUpdateTime,
- updateInterval: Duration(minutes: 1),
- style: TextStyle(
- fontSize: 12.sp, color: '#A7A7A7'.color));
- }),
- Spacer(),
- Obx(() {
- return controller.selectedFriend != null
- ? GestureDetector(
- onTap: () => controller.onViewTraceClick(
- controller.selectedFriend!),
- child: Container(
- margin: EdgeInsets.only(right: 16.w),
- decoration: getPrimaryBtnDecoration(32.w),
- padding: EdgeInsets.symmetric(
- horizontal: 21.w, vertical: 5.w),
- child: Text(StringName.locationTrace,
- style: TextStyle(
- fontSize: 15.sp,
- color: Colors.white))),
- )
- : SizedBox.shrink();
- }),
- ],
- ),
- Expanded(
- child: Container(
- margin: EdgeInsets.only(right: 17.w),
- child: Obx(() {
- return ImageFiltered(
- enabled: controller.selectedFriend?.blockedMe ==
- true ||
- ((controller.memberStatusInfo.value == null ||
- controller.memberStatusInfo.value
- ?.expired ==
- true) &&
- !(controller.selectedFriend?.isMine ==
- true)),
- imageFilter: ImageFilter.blur(
- sigmaX: Constants.blurredX,
- sigmaY: Constants.blurredY,
- ),
- child: controller.selectedFriend?.blockedMe == true ||
- ((controller.memberStatusInfo.value == null ||
- controller.memberStatusInfo.value?.expired ==
- true) &&
- !(controller.selectedFriend?.isMine ==
- true))
- ? Text(addressCheck(controller.selectedFriend?.lastLocation.value?.address),
- style: TextStyle(
- fontSize: 13.sp,
- color: ColorName.black50))
- : MarqueeText.marquee(
- text: addressCheck(controller.selectedFriend
- ?.lastLocation.value?.address),
- textStyle: TextStyle(
- fontSize: 13.sp,
- color: ColorName.black50),
- containerWidth: 244.w),
- );
- }),
- ),
- )
- // Text('广东省广州市天河区XX街街XX街区XX村XX')
- ],
- ),
- ),
- )
- ],
- ));
- }
- }
|