add_friend_page.dart 8.3 KB

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