location_view.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. import 'package:abroad_location/base/base_view.dart';
  2. import 'package:abroad_location/resource/assets.gen.dart';
  3. import 'package:abroad_location/resource/colors.gen.dart';
  4. import 'package:abroad_location/resource/string.gen.dart';
  5. import 'package:abroad_location/utils/atmob_log.dart';
  6. import 'package:abroad_location/utils/base_expand.dart';
  7. import 'package:abroad_location/widget/MapWidget.dart';
  8. import 'package:flutter/cupertino.dart';
  9. import 'package:flutter/material.dart';
  10. import 'package:flutter/src/widgets/framework.dart';
  11. import 'package:flutter_screenutil/flutter_screenutil.dart';
  12. import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
  13. import 'package:sliding_sheet2/sliding_sheet2.dart';
  14. import 'friend_item.dart';
  15. import 'location_controller.dart';
  16. class LocationView extends BaseView<LocationController> {
  17. const LocationView({super.key});
  18. @override
  19. Widget buildBody(BuildContext context) {
  20. return SlidingSheet(
  21. listener: (SheetState state) {
  22. controller.setSheetProgress(state.progress);
  23. AtmobLog.d('zk', 'progress: ${state.progress}');
  24. },
  25. color: '#F7F7F7'.color,
  26. controller: controller.sheetController,
  27. elevation: 10,
  28. shadowColor: Colors.black.withOpacity(0.1),
  29. cornerRadius: 28.w,
  30. snapSpec: SnapSpec(
  31. initialSnap: 158.w, // 67.w + 91.w
  32. // Enable snapping. This is true by default.
  33. snap: true,
  34. // Set custom snapping points.
  35. snappings: [158.w, 500.w],
  36. // Define to what the snappings relate to. In this case,
  37. // the total available space that the sheet can expand to.
  38. positioning: SnapPositioning.pixelOffset,
  39. ),
  40. body: buildSheetBody(),
  41. headerBuilder: buildLocationSheetHeader,
  42. customBuilder: buildFriendList,
  43. );
  44. }
  45. Widget buildSheetBody() {
  46. return Stack(
  47. children: [
  48. MapWidget(),
  49. buildLocationMember(),
  50. buildAddFriendView(),
  51. buildLocationMenu()
  52. ],
  53. );
  54. }
  55. Widget buildLocationSheetHeader(BuildContext context, SheetState state) {
  56. return SizedBox(
  57. width: double.infinity,
  58. child: IntrinsicHeight(
  59. child: Column(
  60. children: [
  61. SizedBox(height: 8.w),
  62. Container(
  63. width: 36.w,
  64. height: 4.w,
  65. decoration: BoxDecoration(
  66. color: '#D4DCEA'.color,
  67. borderRadius: BorderRadius.circular(2.w),
  68. ),
  69. ),
  70. SizedBox(height: 19.w),
  71. Container(
  72. margin: EdgeInsets.only(left: 16.w, right: 16.w),
  73. child: Row(
  74. children: [
  75. Text(StringName.friendList,
  76. style: TextStyle(
  77. fontSize: 20.sp,
  78. color: ColorName.black80,
  79. fontWeight: FontWeight.bold)),
  80. Spacer(),
  81. Container(
  82. height: 28.w,
  83. decoration: BoxDecoration(
  84. color: '#264476FF'.color,
  85. borderRadius: BorderRadius.circular(100.w),
  86. ),
  87. padding: EdgeInsets.all(2.w),
  88. child: Row(
  89. children: [
  90. Assets.images.iconLocationFriendAdd.image(),
  91. SizedBox(width: 5.w),
  92. Text(
  93. StringName.locationAddFriend,
  94. style: TextStyle(
  95. fontSize: 12.sp,
  96. color: '#274494'.color,
  97. fontWeight: FontWeight.w500),
  98. ),
  99. SizedBox(width: 8.w),
  100. ],
  101. ),
  102. )
  103. ],
  104. ),
  105. ),
  106. SizedBox(height: 8.w),
  107. ],
  108. ),
  109. ),
  110. );
  111. }
  112. //选中的好友卡片
  113. Widget buildSelectedFriendCard() {
  114. return Obx(() {
  115. return Visibility(
  116. visible: controller.sheetProgress < 1,
  117. child: Opacity(
  118. opacity: 1 - controller.sheetProgress,
  119. child: SingleChildScrollView(
  120. child: Container(
  121. color: '#F7F7F7'.color,
  122. child: Column(
  123. children: [
  124. SizedBox(height: 8.w),
  125. controller.selectUserInfo != null
  126. ? locationFriendItem(controller.selectUserInfo!)
  127. : SizedBox.shrink(),
  128. SizedBox(height: 13.w),
  129. ],
  130. ),
  131. ),
  132. ),
  133. ),
  134. );
  135. });
  136. }
  137. Widget buildFriendList(
  138. BuildContext context,
  139. ScrollController ctl,
  140. SheetState state,
  141. ) {
  142. return Stack(children: [
  143. Obx(() {
  144. return Opacity(
  145. opacity: controller.sheetProgress,
  146. child: ListView.builder(
  147. padding: EdgeInsets.zero,
  148. controller: ctl,
  149. itemBuilder: buildFriendListItem,
  150. itemCount: controller.locationFriendList.length),
  151. );
  152. }),
  153. buildSelectedFriendCard(),
  154. ]);
  155. }
  156. Widget buildFriendListItem(BuildContext context, int index) {
  157. return Container(
  158. margin: EdgeInsets.only(bottom: 10.w),
  159. child: locationFriendItem(controller.locationFriendList[index],
  160. onItemClick: (userInfo) {
  161. controller.onSelectItemClick(userInfo);
  162. }, onTrackClick: (userInfo) {}));
  163. }
  164. Widget buildLocationMenu() {
  165. return Positioned(
  166. right: 4.w,
  167. bottom: 220.w,
  168. child: IntrinsicHeight(
  169. child: Column(
  170. children: [
  171. Assets.images.iconLocationLayer.image(width: 56.w, height: 56.w),
  172. Assets.images.iconLocationPosition.image(width: 56.w, height: 56.w),
  173. Assets.images.iconLocationRefresh.image(width: 56.w, height: 56.w),
  174. ],
  175. ),
  176. ),
  177. );
  178. }
  179. Widget buildLocationMember() {
  180. return Positioned(
  181. top: 125.w,
  182. right: 4.w,
  183. child:
  184. Assets.images.iconLoationMember.image(width: 56.w, height: 56.w));
  185. }
  186. Widget buildAddFriendView() {
  187. return Stack(
  188. children: [
  189. buildHeadBg(),
  190. buildAddFriendBackboard(),
  191. buildAddFriendInput()
  192. ],
  193. );
  194. }
  195. Widget buildAddFriendBackboard() {
  196. return Container(
  197. width: double.infinity,
  198. height: 205.w,
  199. decoration: BoxDecoration(
  200. borderRadius: BorderRadius.only(
  201. bottomLeft: Radius.circular(36.w),
  202. bottomRight: Radius.circular(36.w)),
  203. gradient: LinearGradient(
  204. colors: [
  205. ColorName.white10,
  206. ColorName.white90,
  207. ],
  208. begin: Alignment.topCenter,
  209. end: Alignment.bottomCenter,
  210. ),
  211. boxShadow: [
  212. BoxShadow(
  213. color: ColorName.black40.withOpacity(0.1),
  214. blurRadius: 10.w,
  215. offset: Offset(0, 2.w))
  216. ],
  217. ),
  218. );
  219. // return Stack(children: [
  220. //
  221. // Container(
  222. // width: double.infinity,
  223. // height: 210.w,
  224. // decoration: BoxDecoration(
  225. // color: ColorName.black,
  226. // borderRadius: BorderRadius.only(
  227. // bottomLeft: Radius.circular(32.w),
  228. // bottomRight: Radius.circular(34.w)),
  229. // ),
  230. // ),
  231. //
  232. // ClipRRect(
  233. // child: Container(
  234. // width: double.infinity,
  235. // height: 205.w,
  236. // decoration: BoxDecoration(
  237. // borderRadius: BorderRadius.only(
  238. // bottomLeft: Radius.circular(36.w),
  239. // bottomRight: Radius.circular(36.w)),
  240. // gradient: LinearGradient(
  241. // colors: [
  242. // Colors.transparent,
  243. // Colors.blue,
  244. // // ColorName.white10,
  245. // // ColorName.white90,
  246. // ],
  247. // begin: Alignment.topCenter,
  248. // end: Alignment.bottomCenter,
  249. // ),
  250. // ),
  251. // ),
  252. // )
  253. // ],);
  254. }
  255. Container buildHeadBg() {
  256. return Container(
  257. decoration: BoxDecoration(
  258. gradient: LinearGradient(
  259. colors: [
  260. '#DEE5FF'.color,
  261. ColorName.transparent,
  262. ],
  263. begin: Alignment.topCenter,
  264. end: Alignment.bottomCenter,
  265. ),
  266. ),
  267. width: double.infinity,
  268. height: 73.w,
  269. );
  270. }
  271. Container buildAddFriendInput() {
  272. return Container(
  273. padding: EdgeInsets.only(top: 62.w),
  274. child: Row(
  275. children: [
  276. SizedBox(width: 16.w),
  277. Obx(() {
  278. return AnimatedContainer(
  279. duration: controller.findContactAnimatedDuration,
  280. width: controller.isFindContact ? 0.w : 50.w,
  281. height: controller.isFindContact ? 0.w : 50.w,
  282. margin: EdgeInsets.only(right: 10.w),
  283. decoration: BoxDecoration(
  284. borderRadius: BorderRadius.all(Radius.circular(18.w)),
  285. boxShadow: [
  286. BoxShadow(
  287. color: ColorName.black20.withOpacity(0.1),
  288. blurRadius: 10.w)
  289. ],
  290. ),
  291. child: Assets.images.iconLocationMenu
  292. .image(width: double.infinity, height: double.infinity),
  293. );
  294. }),
  295. Expanded(
  296. child: Container(
  297. height: 50.w,
  298. decoration: BoxDecoration(
  299. color: ColorName.white,
  300. borderRadius: BorderRadius.all(Radius.circular(100.w)),
  301. boxShadow: [
  302. BoxShadow(
  303. color: ColorName.black20.withOpacity(0.1),
  304. blurRadius: 10.w)
  305. ],
  306. ),
  307. child: Row(
  308. children: [
  309. SizedBox(width: 8.w),
  310. Assets.images.iconLocationSearch
  311. .image(width: 18.w, height: 18.w),
  312. SizedBox(width: 10.w),
  313. Expanded(
  314. child: GestureDetector(
  315. behavior: HitTestBehavior.opaque,
  316. onTap: () {
  317. controller.onFindContactClick();
  318. },
  319. child: SizedBox(
  320. height: double.infinity,
  321. child: Align(
  322. alignment: Alignment.centerLeft,
  323. child: Text(
  324. textAlign: TextAlign.start,
  325. StringName.locationAddFriendHint,
  326. style: TextStyle(
  327. fontSize: 14.sp, color: ColorName.black40),
  328. ),
  329. ),
  330. ),
  331. ),
  332. ),
  333. SizedBox(width: 10.w),
  334. Obx(() {
  335. return AnimatedScale(
  336. scale: controller.isFindContact ? 0 : 1,
  337. duration: controller.findContactAnimatedDuration,
  338. child: Container(
  339. padding: EdgeInsets.symmetric(
  340. vertical: 5.5.w, horizontal: 11.w),
  341. decoration: BoxDecoration(
  342. color: '#4476FF'.color,
  343. borderRadius: BorderRadius.circular(100.w),
  344. boxShadow: [
  345. BoxShadow(
  346. offset: Offset(0, 2.w),
  347. color: '#4476FF'.color.withOpacity(0.4),
  348. blurRadius: 5.w)
  349. ],
  350. ),
  351. child: Text(StringName.locationAddFriendBtn,
  352. style: TextStyle(
  353. fontSize: 14.sp,
  354. color: ColorName.white,
  355. fontWeight: FontWeight.bold)),
  356. ),
  357. );
  358. }),
  359. SizedBox(width: 10.w),
  360. ],
  361. ),
  362. ),
  363. ),
  364. SizedBox(width: 16.w),
  365. ],
  366. ),
  367. );
  368. }
  369. }