add_friend_page.dart 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. import 'dart:io';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:get/get.dart';
  6. import 'package:get/get_core/src/get_main.dart';
  7. import 'package:location/utils/common_expand.dart';
  8. import 'package:location/utils/common_style.dart';
  9. import '../../../base/base_view.dart';
  10. import '../../../resource/assets.gen.dart';
  11. import '../../../resource/colors.gen.dart';
  12. import '../../../resource/string.gen.dart';
  13. import 'add_friend_dialog_controller.dart';
  14. class AddFriendPage extends BaseView<AddFriendDialogController> {
  15. const AddFriendPage({super.key});
  16. static Future<T?> show<T>() {
  17. return Get.bottomSheet(AddFriendPage(),
  18. isScrollControlled: true,
  19. barrierColor: ColorName.black55,
  20. backgroundColor: ColorName.transparent);
  21. }
  22. static void dismiss() {
  23. Get.back();
  24. }
  25. @override
  26. Widget buildBody(BuildContext context) {
  27. return _addFriendView();
  28. }
  29. @override
  30. backgroundColor() {
  31. return ColorName.transparent;
  32. }
  33. Widget _addFriendView() {
  34. return GestureDetector(
  35. onTap: () => FocusScope.of(Get.context!).unfocus(),
  36. child: IntrinsicHeight(
  37. child: Container(
  38. decoration: BoxDecoration(
  39. color: '#FDFCFE'.color,
  40. borderRadius: BorderRadius.only(
  41. topLeft: Radius.circular(16.w),
  42. topRight: Radius.circular(16.w),
  43. ),
  44. ),
  45. child: Stack(
  46. children: [
  47. Positioned(
  48. top: 0,
  49. child: Assets.images.bgAddFriendDialog.image(width: 1.sw),
  50. ),
  51. _buildClose(),
  52. Column(
  53. crossAxisAlignment: CrossAxisAlignment.start,
  54. children: [
  55. SizedBox(height: 19.h),
  56. _buildAddHeader(),
  57. SizedBox(height: 18.h),
  58. _buildPhone(),
  59. SizedBox(height: 16.h),
  60. _buildShareWx(),
  61. SizedBox(height: 20.h),
  62. Visibility(
  63. visible: Platform.isAndroid,
  64. child: Center(
  65. child: Text(StringName.friendAddRule,
  66. style: TextStyle(
  67. fontSize: 12.sp, color: '#A7A7A7'.color))),
  68. ),
  69. SizedBox(height: 30.h),
  70. ],
  71. )
  72. ],
  73. ),
  74. ),
  75. ),
  76. );
  77. }
  78. Widget _buildShareWx() {
  79. return GestureDetector(
  80. onTap: controller.shareWxClick,
  81. child: Container(
  82. height: 54.w,
  83. decoration: BoxDecoration(boxShadow: [
  84. BoxShadow(
  85. color: ColorName.black5.withOpacity(0.05), // 阴影颜色
  86. blurRadius: 23, // 阴影模糊半径
  87. spreadRadius: 2, // 阴影扩展半径
  88. offset: const Offset(0, 0), // 阴影位置,向上偏移
  89. ),
  90. ], color: ColorName.white, borderRadius: BorderRadius.circular(12.w)),
  91. margin: EdgeInsets.symmetric(horizontal: 12.w),
  92. child: Row(
  93. children: [
  94. SizedBox(width: 15.w),
  95. Assets.images.iconLoginWx.image(width: 25.w),
  96. SizedBox(width: 15.w),
  97. Text(StringName.friendAddFromWx,
  98. style: TextStyle(
  99. fontWeight: FontWeight.bold,
  100. color: ColorName.primaryTextColor,
  101. fontSize: 14.sp)),
  102. Spacer(),
  103. Assets.images.iconLoginGoWxArrow.image(width: 18.w, height: 18.w),
  104. SizedBox(width: 12.w),
  105. ],
  106. ),
  107. ),
  108. );
  109. }
  110. Container _buildPhone() {
  111. return Container(
  112. padding: EdgeInsets.symmetric(horizontal: 12.w),
  113. margin: EdgeInsets.symmetric(horizontal: 12.w),
  114. decoration: BoxDecoration(boxShadow: [
  115. BoxShadow(
  116. color: ColorName.black5.withOpacity(0.05), // 阴影颜色
  117. blurRadius: 23, // 阴影模糊半径
  118. spreadRadius: 2, // 阴影扩展半径
  119. offset: const Offset(0, 0), // 阴影位置,向上偏移
  120. ),
  121. ], color: ColorName.white, borderRadius: BorderRadius.circular(12.w)),
  122. child: Column(
  123. children: [
  124. SizedBox(height: 13.h),
  125. Row(
  126. crossAxisAlignment: CrossAxisAlignment.center,
  127. children: [
  128. Assets.images.iconLoginPhone.image(width: 18.w, height: 18.w),
  129. SizedBox(width: 7.w),
  130. Text(
  131. Platform.isAndroid
  132. ? StringName.friendAddFromPhone
  133. : StringName.friendAddFromPhoneIos,
  134. style: TextStyle(
  135. fontWeight: FontWeight.bold,
  136. fontSize: 14.sp,
  137. color: ColorName.primaryTextColor,
  138. ),
  139. ),
  140. Spacer(),
  141. Obx(() {
  142. return Visibility(
  143. maintainSize: true,
  144. maintainAnimation: true,
  145. maintainState: true,
  146. visible: controller.phone.length == 11,
  147. child: GestureDetector(
  148. onTap: controller.onAddFriendClick,
  149. child: Container(
  150. decoration: getPrimaryBtnDecoration(30.w),
  151. padding: EdgeInsets.symmetric(
  152. horizontal: 15.w, vertical: 8.w),
  153. child: Text(StringName.friendAddNow,
  154. style: TextStyle(
  155. fontSize: 14.sp,
  156. color: Colors.white,
  157. height: 1))),
  158. ),
  159. );
  160. })
  161. ],
  162. ),
  163. SizedBox(height: 18.h),
  164. _buildPhoneView(),
  165. SizedBox(height: 18.h),
  166. ],
  167. ),
  168. );
  169. }
  170. Widget _buildPhoneView() {
  171. return Row(
  172. children: [
  173. Expanded(
  174. child: Container(
  175. height: 50.w,
  176. decoration: BoxDecoration(
  177. color: '#F9F9F9'.color,
  178. borderRadius: BorderRadius.circular(10.w),
  179. ),
  180. padding: EdgeInsets.symmetric(horizontal: 10.w),
  181. child: Center(
  182. child: TextField(
  183. controller: controller.etController,
  184. style: TextStyle(
  185. fontSize: 14.sp, color: ColorName.primaryTextColor),
  186. maxLines: 1,
  187. maxLength: 11,
  188. keyboardType: TextInputType.phone,
  189. textAlignVertical: TextAlignVertical.center,
  190. textInputAction: TextInputAction.next,
  191. decoration: InputDecoration(
  192. hintText: StringName.friendAddPhoneEtHint,
  193. counterText: '',
  194. hintStyle:
  195. TextStyle(fontSize: 16, color: "#AFAFAF".toColor()),
  196. labelStyle: const TextStyle(
  197. fontSize: 16,
  198. color: ColorName.primaryTextColor,
  199. ),
  200. contentPadding: const EdgeInsets.all(0),
  201. border: const OutlineInputBorder(borderSide: BorderSide.none),
  202. enabled: true,
  203. ),
  204. ),
  205. ),
  206. ),
  207. ),
  208. SizedBox(width: 14.w),
  209. Assets.images.iconLoginAddressBook.image(width: 15.w, height: 15.w),
  210. SizedBox(width: 3.w),
  211. GestureDetector(
  212. onTap: controller.onSelectContactClick,
  213. child: Text(StringName.friendAddAddressBook,
  214. style: TextStyle(fontSize: 14.sp, color: '#202020'.color)),
  215. ),
  216. ],
  217. );
  218. }
  219. Widget _buildAddHeader() {
  220. return Padding(
  221. padding: EdgeInsets.only(left: 18.w),
  222. child: Column(
  223. crossAxisAlignment: CrossAxisAlignment.start,
  224. children: [
  225. Text(
  226. Platform.isAndroid
  227. ? StringName.friendAddTitle
  228. : StringName.friendAddIosTitle,
  229. style: TextStyle(
  230. fontSize: 20.sp,
  231. color: ColorName.primaryTextColor,
  232. fontWeight: FontWeight.bold)),
  233. SizedBox(height: 10.h),
  234. Text(StringName.friendAddDesc,
  235. style: TextStyle(fontSize: 14.sp, color: '#545454'.color)),
  236. ],
  237. ),
  238. );
  239. }
  240. Widget _buildClose() {
  241. return Padding(
  242. padding: EdgeInsets.all(12.w),
  243. child: GestureDetector(
  244. onTap: () {
  245. Get.back();
  246. },
  247. child: Align(
  248. alignment: Alignment.topRight,
  249. child:
  250. Assets.images.iconLoginClose.image(width: 24.w, height: 24.w)),
  251. ),
  252. );
  253. }
  254. }