track_page.dart 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 DefaultTabController(
  90. length: controller.daysList.length,
  91. child: Column(
  92. children: [
  93. SizedBox(
  94. width: double.infinity,
  95. child: TabBar(
  96. tabAlignment: TabAlignment.start,
  97. isScrollable: true,
  98. dividerHeight: 0,
  99. indicator: FixedSizeTabIndicator(
  100. width: 26.w,
  101. height: 3.w,
  102. radius: 0,
  103. color: ColorName.colorPrimary),
  104. unselectedLabelStyle:
  105. TextStyle(fontSize: 13.sp, color: '#666666'.color),
  106. labelStyle: TextStyle(
  107. fontSize: 13.sp,
  108. color: '#333333'.color,
  109. fontWeight: FontWeight.bold),
  110. tabs: controller.daysList.map((e) {
  111. return Tab(
  112. text: e.day,
  113. );
  114. }).toList(),
  115. ),
  116. ),
  117. Container(
  118. color: '#EEEEEE'.color,
  119. height: 1.w,
  120. width: double.infinity,
  121. ),
  122. Expanded(
  123. child: TabBarView(
  124. children: List.generate(
  125. controller.daysList.length,
  126. (index) => TrackDayDetailView(controller.daysList[index],
  127. isExpand: index == 0)),
  128. )),
  129. ],
  130. ),
  131. );
  132. }),
  133. );
  134. }
  135. Widget buildSheetHeadView() {
  136. return IntrinsicHeight(
  137. child: Column(
  138. children: [
  139. SizedBox(height: 5.w),
  140. Align(
  141. alignment: Alignment.center,
  142. child: Container(
  143. width: 32.w,
  144. height: 3.w,
  145. decoration: BoxDecoration(
  146. color: '#D9D9D9'.color,
  147. borderRadius: BorderRadius.circular(49.w),
  148. ),
  149. ),
  150. ),
  151. SizedBox(height: 25.w),
  152. buildTrackHeaderView(),
  153. SizedBox(height: 20.w),
  154. ],
  155. ));
  156. }
  157. Widget buildTrackHeaderView() {
  158. return Row(
  159. children: [
  160. SizedBox(width: 14.w),
  161. Obx(() {
  162. return buildCustomAvatarOrDefaultAvatarView(
  163. size: 32.w,
  164. avatar: controller.userInfo?.avatar,
  165. isMine: controller.userInfo?.isMine == true);
  166. }),
  167. SizedBox(width: 10.w),
  168. Expanded(
  169. child: Text(
  170. '${controller.userInfo?.getUserNickName() ?? ''}的轨迹',
  171. style: TextStyle(
  172. overflow: TextOverflow.ellipsis,
  173. fontSize: 16.sp,
  174. color: ColorName.black80,
  175. fontWeight: FontWeight.bold),
  176. ),
  177. ),
  178. SizedBox(width: 12.w),
  179. ],
  180. );
  181. }
  182. }