import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:get/get_core/src/get_main.dart'; import 'package:location/utils/common_expand.dart'; import 'package:location/utils/common_style.dart'; import '../../../base/base_view.dart'; import '../../../resource/assets.gen.dart'; import '../../../resource/colors.gen.dart'; import '../../../resource/string.gen.dart'; import 'add_friend_dialog_controller.dart'; class AddFriendPage extends BaseView { const AddFriendPage({super.key}); static Future show() { return Get.bottomSheet(AddFriendPage(), isScrollControlled: true, barrierColor: ColorName.black55, backgroundColor: ColorName.transparent); } static void dismiss() { Get.back(); } @override Widget buildBody(BuildContext context) { return _addFriendView(); } @override backgroundColor() { return ColorName.transparent; } Widget _addFriendView() { return GestureDetector( onTap: () => FocusScope.of(Get.context!).unfocus(), child: IntrinsicHeight( child: Container( decoration: BoxDecoration( color: '#FDFCFE'.color, borderRadius: BorderRadius.only( topLeft: Radius.circular(16.w), topRight: Radius.circular(16.w), ), ), child: Stack( children: [ Positioned( top: 0, child: Assets.images.bgAddFriendDialog.image(width: 1.sw), ), _buildClose(), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox(height: 19.h), _buildAddHeader(), SizedBox(height: 18.h), _buildPhone(), SizedBox(height: 16.h), _buildShareWx(), SizedBox(height: 20.h), Visibility( visible: Platform.isAndroid, child: Center( child: Text(StringName.friendAddRule, style: TextStyle( fontSize: 12.sp, color: '#A7A7A7'.color))), ), SizedBox(height: 30.h), ], ) ], ), ), ), ); } Widget _buildShareWx() { return GestureDetector( onTap: controller.shareWxClick, child: Container( height: 54.w, decoration: BoxDecoration(boxShadow: [ BoxShadow( color: ColorName.black5.withOpacity(0.05), // 阴影颜色 blurRadius: 23, // 阴影模糊半径 spreadRadius: 2, // 阴影扩展半径 offset: const Offset(0, 0), // 阴影位置,向上偏移 ), ], color: ColorName.white, borderRadius: BorderRadius.circular(12.w)), margin: EdgeInsets.symmetric(horizontal: 12.w), child: Row( children: [ SizedBox(width: 15.w), Assets.images.iconLoginWx.image(width: 25.w), SizedBox(width: 15.w), Text(StringName.friendAddFromWx, style: TextStyle( fontWeight: FontWeight.bold, color: ColorName.primaryTextColor, fontSize: 14.sp)), Spacer(), Assets.images.iconLoginGoWxArrow.image(width: 18.w, height: 18.w), SizedBox(width: 12.w), ], ), ), ); } Container _buildPhone() { return Container( padding: EdgeInsets.symmetric(horizontal: 12.w), margin: EdgeInsets.symmetric(horizontal: 12.w), decoration: BoxDecoration(boxShadow: [ BoxShadow( color: ColorName.black5.withOpacity(0.05), // 阴影颜色 blurRadius: 23, // 阴影模糊半径 spreadRadius: 2, // 阴影扩展半径 offset: const Offset(0, 0), // 阴影位置,向上偏移 ), ], color: ColorName.white, borderRadius: BorderRadius.circular(12.w)), child: Column( children: [ SizedBox(height: 13.h), Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Assets.images.iconLoginPhone.image(width: 18.w, height: 18.w), SizedBox(width: 7.w), Text( Platform.isAndroid ? StringName.friendAddFromPhone : StringName.friendAddFromPhoneIos, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 14.sp, color: ColorName.primaryTextColor, ), ), Spacer(), Obx(() { return Visibility( maintainSize: true, maintainAnimation: true, maintainState: true, visible: controller.phone.length == 11, child: GestureDetector( onTap: controller.onAddFriendClick, child: Container( decoration: getPrimaryBtnDecoration(30.w), padding: EdgeInsets.symmetric( horizontal: 15.w, vertical: 8.w), child: Text(StringName.friendAddNow, style: TextStyle( fontSize: 14.sp, color: Colors.white, height: 1))), ), ); }) ], ), SizedBox(height: 18.h), _buildPhoneView(), SizedBox(height: 18.h), ], ), ); } Widget _buildPhoneView() { return Row( children: [ Expanded( child: Container( height: 50.w, decoration: BoxDecoration( color: '#F9F9F9'.color, borderRadius: BorderRadius.circular(10.w), ), padding: EdgeInsets.symmetric(horizontal: 10.w), child: Center( child: TextField( controller: controller.etController, style: TextStyle( fontSize: 14.sp, color: ColorName.primaryTextColor), maxLines: 1, maxLength: 11, keyboardType: TextInputType.phone, textAlignVertical: TextAlignVertical.center, textInputAction: TextInputAction.next, decoration: InputDecoration( hintText: StringName.friendAddPhoneEtHint, counterText: '', hintStyle: TextStyle(fontSize: 16, color: "#AFAFAF".toColor()), labelStyle: const TextStyle( fontSize: 16, color: ColorName.primaryTextColor, ), contentPadding: const EdgeInsets.all(0), border: const OutlineInputBorder(borderSide: BorderSide.none), enabled: true, ), ), ), ), ), SizedBox(width: 14.w), Assets.images.iconLoginAddressBook.image(width: 15.w, height: 15.w), SizedBox(width: 3.w), GestureDetector( onTap: controller.onSelectContactClick, child: Text(StringName.friendAddAddressBook, style: TextStyle(fontSize: 14.sp, color: '#202020'.color)), ), ], ); } Widget _buildAddHeader() { return Padding( padding: EdgeInsets.only(left: 18.w), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( Platform.isAndroid ? StringName.friendAddTitle : StringName.friendAddIosTitle, style: TextStyle( fontSize: 20.sp, color: ColorName.primaryTextColor, fontWeight: FontWeight.bold)), SizedBox(height: 10.h), Text(StringName.friendAddDesc, style: TextStyle(fontSize: 14.sp, color: '#545454'.color)), ], ), ); } Widget _buildClose() { return Padding( padding: EdgeInsets.all(12.w), child: GestureDetector( onTap: () { Get.back(); }, child: Align( alignment: Alignment.topRight, child: Assets.images.iconLoginClose.image(width: 24.w, height: 24.w)), ), ); } }