add_friend_page.dart 8.1 KB

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