add_friend_page.dart 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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(
  98. Platform.isIOS
  99. ? StringName.friendAddFromWxIos
  100. : StringName.friendAddFromWx,
  101. style: TextStyle(
  102. fontWeight: FontWeight.bold,
  103. color: ColorName.primaryTextColor,
  104. fontSize: 14.sp)),
  105. Spacer(),
  106. Assets.images.iconLoginGoWxArrow.image(width: 18.w, height: 18.w),
  107. SizedBox(width: 12.w),
  108. ],
  109. ),
  110. ),
  111. );
  112. }
  113. Container _buildPhone() {
  114. return Container(
  115. padding: EdgeInsets.symmetric(horizontal: 12.w),
  116. margin: EdgeInsets.symmetric(horizontal: 12.w),
  117. decoration: BoxDecoration(boxShadow: [
  118. BoxShadow(
  119. color: ColorName.black5.withOpacity(0.05), // 阴影颜色
  120. blurRadius: 23, // 阴影模糊半径
  121. spreadRadius: 2, // 阴影扩展半径
  122. offset: const Offset(0, 0), // 阴影位置,向上偏移
  123. ),
  124. ], color: ColorName.white, borderRadius: BorderRadius.circular(12.w)),
  125. child: Column(
  126. children: [
  127. SizedBox(height: 13.h),
  128. Row(
  129. crossAxisAlignment: CrossAxisAlignment.center,
  130. children: [
  131. Assets.images.iconLoginPhone.image(width: 18.w, height: 18.w),
  132. SizedBox(width: 7.w),
  133. Text(
  134. Platform.isAndroid
  135. ? StringName.friendAddFromPhone
  136. : StringName.friendAddFromPhoneIos,
  137. style: TextStyle(
  138. fontWeight: FontWeight.bold,
  139. fontSize: 14.sp,
  140. color: ColorName.primaryTextColor,
  141. ),
  142. ),
  143. Spacer(),
  144. Obx(() {
  145. return Visibility(
  146. maintainSize: true,
  147. maintainAnimation: true,
  148. maintainState: true,
  149. visible: controller.phone.length == 11,
  150. child: GestureDetector(
  151. onTap: controller.onAddFriendClick,
  152. child: Container(
  153. decoration: getPrimaryBtnDecoration(30.w),
  154. padding: EdgeInsets.symmetric(
  155. horizontal: 15.w, vertical: 8.w),
  156. child: Text(StringName.friendAddNow,
  157. style: TextStyle(
  158. fontSize: 14.sp,
  159. color: Colors.white,
  160. height: 1))),
  161. ),
  162. );
  163. })
  164. ],
  165. ),
  166. SizedBox(height: 18.h),
  167. _buildPhoneView(),
  168. SizedBox(height: 18.h),
  169. ],
  170. ),
  171. );
  172. }
  173. Widget _buildPhoneView() {
  174. return Row(
  175. children: [
  176. Expanded(
  177. child: Container(
  178. height: 50.w,
  179. decoration: BoxDecoration(
  180. color: '#F9F9F9'.color,
  181. borderRadius: BorderRadius.circular(10.w),
  182. ),
  183. padding: EdgeInsets.symmetric(horizontal: 10.w),
  184. child: Center(
  185. child: TextField(
  186. controller: controller.etController,
  187. style: TextStyle(
  188. fontSize: 14.sp, color: ColorName.primaryTextColor),
  189. maxLines: 1,
  190. maxLength: 11,
  191. keyboardType: TextInputType.phone,
  192. textAlignVertical: TextAlignVertical.center,
  193. textInputAction: TextInputAction.next,
  194. decoration: InputDecoration(
  195. hintText: StringName.friendAddPhoneEtHint,
  196. counterText: '',
  197. hintStyle:
  198. TextStyle(fontSize: 16, color: "#AFAFAF".toColor()),
  199. labelStyle: const TextStyle(
  200. fontSize: 16,
  201. color: ColorName.primaryTextColor,
  202. ),
  203. contentPadding: const EdgeInsets.all(0),
  204. border: const OutlineInputBorder(borderSide: BorderSide.none),
  205. enabled: true,
  206. ),
  207. ),
  208. ),
  209. ),
  210. ),
  211. SizedBox(width: 14.w),
  212. Assets.images.iconLoginAddressBook.image(width: 15.w, height: 15.w),
  213. SizedBox(width: 3.w),
  214. GestureDetector(
  215. onTap: controller.onSelectContactClick,
  216. child: Text(StringName.friendAddAddressBook,
  217. style: TextStyle(fontSize: 14.sp, color: '#202020'.color)),
  218. ),
  219. ],
  220. );
  221. }
  222. Widget _buildAddHeader() {
  223. return Padding(
  224. padding: EdgeInsets.only(left: 18.w),
  225. child: Column(
  226. crossAxisAlignment: CrossAxisAlignment.start,
  227. children: [
  228. Text(
  229. Platform.isAndroid
  230. ? StringName.friendAddTitle
  231. : StringName.friendAddIosTitle,
  232. style: TextStyle(
  233. fontSize: 20.sp,
  234. color: ColorName.primaryTextColor,
  235. fontWeight: FontWeight.bold)),
  236. SizedBox(height: 10.h),
  237. Text(StringName.friendAddDesc,
  238. style: TextStyle(fontSize: 14.sp, color: '#545454'.color)),
  239. ],
  240. ),
  241. );
  242. }
  243. Widget _buildClose() {
  244. return Padding(
  245. padding: EdgeInsets.all(12.w),
  246. child: GestureDetector(
  247. onTap: () {
  248. Get.back();
  249. },
  250. child: Align(
  251. alignment: Alignment.topRight,
  252. child:
  253. Assets.images.iconLoginClose.image(width: 24.w, height: 24.w)),
  254. ),
  255. );
  256. }
  257. }