track_page.dart 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/src/widgets/framework.dart';
  4. import 'package:flutter_map/flutter_map.dart';
  5. import 'package:flutter_screenutil/flutter_screenutil.dart';
  6. import 'package:get/get.dart';
  7. import 'package:get/get_core/src/get_main.dart';
  8. import 'package:location/base/base_page.dart';
  9. import 'package:location/data/bean/user_info.dart';
  10. import 'package:location/module/track/track_controller.dart';
  11. import 'package:location/module/track/track_day_detail/track_day_detail_view.dart';
  12. import 'package:location/resource/colors.gen.dart';
  13. import 'package:location/utils/common_expand.dart';
  14. import 'package:location/utils/common_style.dart';
  15. import 'package:sliding_sheet2/sliding_sheet2.dart';
  16. import '../../router/app_pages.dart';
  17. import '../../utils/fixed_size_tab_indicator.dart';
  18. import '../../widget/common_view.dart';
  19. class TrackPage extends BasePage<TrackController> {
  20. const TrackPage({super.key});
  21. static void start(UserInfo userInfo) {
  22. Get.toNamed(RoutePath.track, arguments: userInfo);
  23. }
  24. @override
  25. bool immersive() {
  26. return true;
  27. }
  28. @override
  29. Widget buildBody(BuildContext context) {
  30. return Stack(
  31. children: [
  32. SizedBox(
  33. width: double.infinity,
  34. height: double.infinity,
  35. child: MapWidget(
  36. controller: controller.mapController,
  37. ),
  38. ),
  39. buildBackBtnView(),
  40. SlidingSheet(
  41. color: ColorName.white,
  42. controller: controller.sheetController,
  43. elevation: 10,
  44. shadowColor: Colors.black.withOpacity(0.1),
  45. cornerRadius: 18.w,
  46. snapSpec: SnapSpec(
  47. initialSnap: 0.45,
  48. // Enable snapping. This is true by default.
  49. snap: true,
  50. // Set custom snapping points.
  51. snappings: [SnapSpec.headerSnap, 0.45, 1.0],
  52. // Define to what the snappings relate to. In this case,
  53. // the total available space that the sheet can expand to.
  54. positioning: SnapPositioning.relativeToAvailableSpace,
  55. ),
  56. headerBuilder: (context, state) {
  57. return buildSheetHeadView();
  58. },
  59. builder: (context, state) {
  60. return buildSheetContentView();
  61. },
  62. )
  63. ],
  64. );
  65. }
  66. Widget buildBackBtnView() {
  67. return SafeArea(
  68. child: GestureDetector(
  69. onTap: controller.back,
  70. child: Container(
  71. margin: EdgeInsets.only(top: 14.w, left: 12.w),
  72. decoration: BoxDecoration(boxShadow: [
  73. BoxShadow(
  74. color: Colors.black.withOpacity(0.05),
  75. blurRadius: 10.w,
  76. offset: Offset(0, 2.w),
  77. ),
  78. ]),
  79. child: CommonView.getBackBtnView(),
  80. ),
  81. ),
  82. );
  83. }
  84. Widget buildSheetContentView() {
  85. return SizedBox(
  86. height: 0.77.sh,
  87. width: double.infinity,
  88. child: Obx(() {
  89. return Visibility(
  90. visible: controller.tabController != null,
  91. child: Column(
  92. children: [
  93. SizedBox(
  94. width: double.infinity,
  95. child: TabBar(
  96. controller: controller.tabController,
  97. tabAlignment: TabAlignment.start,
  98. isScrollable: true,
  99. dividerHeight: 0,
  100. indicator: FixedSizeTabIndicator(
  101. width: 26.w,
  102. height: 3.w,
  103. radius: 0,
  104. color: ColorName.colorPrimary),
  105. unselectedLabelStyle:
  106. TextStyle(fontSize: 13.sp, color: '#666666'.color),
  107. labelStyle: TextStyle(
  108. fontSize: 13.sp,
  109. color: '#333333'.color,
  110. fontWeight: FontWeight.bold),
  111. tabs: controller.daysList.map((e) {
  112. return Tab(
  113. text: e.day,
  114. );
  115. }).toList(),
  116. ),
  117. ),
  118. Container(
  119. color: '#EEEEEE'.color,
  120. height: 1.w,
  121. width: double.infinity,
  122. ),
  123. Expanded(
  124. child: TabBarView(
  125. controller: controller.tabController,
  126. children: List.generate(
  127. controller.daysList.length,
  128. (index) => TrackDayDetailView(controller.daysList[index],
  129. isExpand: index == 0)),
  130. )),
  131. ],
  132. ),
  133. );
  134. }),
  135. );
  136. }
  137. Widget buildSheetHeadView() {
  138. return IntrinsicHeight(
  139. child: Column(
  140. children: [
  141. SizedBox(height: 5.w),
  142. Align(
  143. alignment: Alignment.center,
  144. child: Container(
  145. width: 32.w,
  146. height: 3.w,
  147. decoration: BoxDecoration(
  148. color: '#D9D9D9'.color,
  149. borderRadius: BorderRadius.circular(49.w),
  150. ),
  151. ),
  152. ),
  153. SizedBox(height: 25.w),
  154. buildTrackHeaderView(),
  155. SizedBox(height: 20.w),
  156. ],
  157. ));
  158. }
  159. Widget buildTrackHeaderView() {
  160. return Row(
  161. children: [
  162. SizedBox(width: 14.w),
  163. Obx(() {
  164. return buildCustomAvatarOrDefaultAvatarView(
  165. size: 32.w,
  166. avatar: controller.userInfo?.avatar,
  167. isMine: controller.userInfo?.isMine == true);
  168. }),
  169. SizedBox(width: 10.w),
  170. Expanded(
  171. child: Text(
  172. '${controller.userInfo?.getUserNickName() ?? ''}的轨迹',
  173. style: TextStyle(
  174. overflow: TextOverflow.ellipsis,
  175. fontSize: 16.sp,
  176. color: ColorName.black80,
  177. fontWeight: FontWeight.bold),
  178. ),
  179. ),
  180. SizedBox(width: 12.w),
  181. ],
  182. );
  183. }
  184. }