| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- 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/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 '../../router/app_pages.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,
- ),
- // headerBuilder: (context, state) {
- // return Container(
- // height: 56,
- // width: double.infinity,
- // color: Colors.green,
- // alignment: Alignment.center,
- // child: Text(
- // 'This is the header',
- // ),
- // );
- // },
- footerBuilder: buildFooterBuilder,
- headerBuilder: buildHeaderBuilder,
- builder: buildTrackEntranceBuilder,
- );
- }
- Widget buildTrackEntranceBuilder(BuildContext context, SheetState state) {
- return Container(
- height: 200.w,
- width: 1.sw,
- );
- }
- 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 buildSelectFriendInfoView() {
- return Obx(() {
- UserInfo? userInfo = controller.selectedFriend;
- if (userInfo == null) {
- return SizedBox(
- height: 86.w,
- );
- }
- return mainSelectedFriendItem(
- userInfo,
- (controller.memberStatusInfo.value == null ||
- controller.memberStatusInfo.value?.expired == true),
- viewTraceClick: () => controller.onViewTraceClick(userInfo));
- });
- }
- 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)
- ],
- ),
- );
- }
- }
|