| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- import 'package:animated_toggle_switch/animated_toggle_switch.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/src/widgets/framework.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/base/base_page.dart';
- import 'package:location/data/bean/user_info.dart';
- import 'package:location/resource/assets.gen.dart';
- import 'package:location/router/app_pages.dart';
- import 'package:location/utils/common_expand.dart';
- import 'package:location/widget/load_switch.dart';
- import '../../../resource/colors.gen.dart';
- import '../../../resource/string.gen.dart';
- import '../../../widget/common_view.dart';
- import 'friend_setting_controller.dart';
- class FriendSettingPage extends BasePage<FriendSettingController> {
- const FriendSettingPage({super.key});
- static void start(UserInfo userInfo) {
- Get.toNamed(RoutePath.friendSetting, arguments: userInfo);
- }
- @override
- Color backgroundColor() {
- return '#F7F7F7'.color;
- }
- @override
- Widget buildBody(BuildContext context) {
- return Column(
- children: [
- buildHeadView(),
- Expanded(
- child: Padding(
- padding: EdgeInsets.symmetric(horizontal: 12.w),
- child: Column(
- children: [
- SizedBox(height: 15.w),
- Container(
- padding: EdgeInsets.symmetric(horizontal: 12.w),
- width: double.infinity,
- decoration: _getSettingCardDecoration(),
- child: Column(
- children: [
- Obx(() {
- return _buildInfoEditType(
- StringName.friendEditRemarkTitle,
- controller.userInfo?.remark ?? '',
- Assets.images.iconFriendEditArrow.provider(),
- onTap: controller.editRemarkClick);
- }),
- Container(
- width: double.infinity,
- height: 1.w,
- color: '#F8F8F8'.color),
- _buildInfoEditType(
- StringName.friendEditPhoneTitle,
- controller.userInfo?.phoneNumber ?? '',
- Assets.images.iconFriendSettingCopy.provider(),
- onTap: controller.copyPhoneClick),
- ],
- ),
- ),
- SizedBox(height: 10.w),
- Obx(() {
- return buildInfoSwitchType(StringName.friendEditBlockTitle,
- controller.userInfo?.blockedHim ?? false,
- future: (value) => controller.blockHimFuture(value));
- }),
- SizedBox(height: 16.w),
- GestureDetector(
- onTap: controller.deleteFriendClick,
- child: Container(
- height: 54.w,
- decoration: _getSettingCardDecoration(),
- child: Center(
- child: Text(StringName.friendDelete,
- style: TextStyle(
- fontSize: 15.sp,
- color: '#E1261A'.color,
- fontWeight: FontWeight.bold)))),
- )
- ],
- ),
- ))
- ],
- );
- }
- Widget buildHeadView() {
- return Container(
- width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w),
- child: Stack(
- children: [
- GestureDetector(
- onTap: controller.back, child: CommonView.getBackBtnView()),
- Positioned(
- left: 0,
- right: 0,
- top: 0,
- bottom: 0,
- child: Center(
- child: Text(StringName.friendInfoEdit,
- style: TextStyle(
- height: 1,
- fontSize: 16.sp,
- color: ColorName.black90,
- fontWeight: FontWeight.bold)),
- ),
- )
- ],
- ),
- );
- }
- BoxDecoration _getSettingCardDecoration() {
- return BoxDecoration(
- color: ColorName.white, borderRadius: BorderRadius.circular(8.w));
- }
- Widget _buildInfoEditType(
- String title, String content, ImageProvider imageProvider,
- {VoidCallback? onTap}) {
- return GestureDetector(
- behavior: HitTestBehavior.translucent,
- onTap: onTap,
- child: SizedBox(
- height: 50.w,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Text(
- title,
- style: TextStyle(
- fontSize: 15.sp,
- color: '#202020'.color,
- fontWeight: FontWeight.bold),
- ),
- Spacer(),
- Text(content,
- style: TextStyle(fontSize: 14.sp, color: '#666666'.color)),
- SizedBox(width: 5.w),
- Image(image: imageProvider, width: 20.w, height: 20.w)
- ],
- ),
- ),
- );
- }
- Widget buildInfoSwitchType(String title, bool isSwitchOn,
- {required LoadFutureCallback future}) {
- return Container(
- height: 54.w,
- padding: EdgeInsets.symmetric(horizontal: 12.w),
- decoration: _getSettingCardDecoration(),
- child: Row(children: [
- Text(
- title,
- style: TextStyle(
- fontSize: 15.sp,
- color: '#202020'.color,
- fontWeight: FontWeight.bold),
- ),
- Spacer(),
- LoadSwitch(
- value: isSwitchOn,
- future: future,
- height: 24.w,
- borderWidth: 4.w,
- loadingColor: ColorName.colorPrimary,
- selectedColor: ColorName.colorPrimary,
- unselectedColor: '#EBEBEB'.color)
- ]),
- );
- }
- }
|