You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
323 lines
8.5 KiB
323 lines
8.5 KiB
import 'package:dating_touchme_app/extension/ex_widget.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../controller/message/chat_settings_controller.dart';
|
|
import '../../generated/assets.dart';
|
|
|
|
class ChatSettingsPage extends StatelessWidget {
|
|
final String userId;
|
|
|
|
const ChatSettingsPage({required this.userId, super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// 初始化控制器
|
|
Get.put(ChatSettingsController(userId: userId));
|
|
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: AppBar(
|
|
title: Text(
|
|
'聊天设置',
|
|
style: TextStyle(
|
|
fontSize: 18.sp,
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
centerTitle: true,
|
|
backgroundColor: Colors.white,
|
|
elevation: 0,
|
|
leading: IconButton(
|
|
icon: Icon(Icons.arrow_back_ios, color: Colors.black, size: 20.w),
|
|
onPressed: () => Get.back(),
|
|
),
|
|
),
|
|
body: GetBuilder<ChatSettingsController>(
|
|
builder: (controller) {
|
|
return Column(
|
|
children: [
|
|
// 用户信息区域
|
|
_buildUserInfoSection(controller),
|
|
|
|
// 分隔线
|
|
Container(
|
|
height: 8.h,
|
|
color: Color(0xFFF5F5F5),
|
|
),
|
|
|
|
// 设置选项
|
|
_buildSettingsList(controller),
|
|
|
|
// 间隔
|
|
SizedBox(height: 17.h),
|
|
|
|
// 关注按钮
|
|
_buildFollowButton(controller),
|
|
|
|
SizedBox(height: MediaQuery.of(context).padding.bottom + 20.h),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
// 用户信息区域
|
|
Widget _buildUserInfoSection(ChatSettingsController controller) {
|
|
return Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h),
|
|
child: Row(
|
|
children: [
|
|
// 头像
|
|
Obx(() {
|
|
final userInfo = controller.userInfo.value;
|
|
return ClipOval(
|
|
child: userInfo?.avatarUrl != null && userInfo!.avatarUrl!.isNotEmpty
|
|
? Image.network(
|
|
userInfo.avatarUrl!,
|
|
width: 50.w,
|
|
height: 50.w,
|
|
fit: BoxFit.cover,
|
|
errorBuilder: (context, error, stackTrace) {
|
|
return Image.asset(
|
|
Assets.imagesAvatarsExample,
|
|
width: 50.w,
|
|
height: 50.w,
|
|
fit: BoxFit.cover,
|
|
);
|
|
},
|
|
)
|
|
: Image.asset(
|
|
Assets.imagesAvatarsExample,
|
|
width: 50.w,
|
|
height: 50.w,
|
|
fit: BoxFit.cover,
|
|
),
|
|
);
|
|
}),
|
|
|
|
SizedBox(width: 12.w),
|
|
|
|
// 昵称
|
|
Expanded(
|
|
child: Obx(() {
|
|
final userInfo = controller.userInfo.value;
|
|
return Text(
|
|
userInfo?.nickName ?? '加载中...',
|
|
style: TextStyle(
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.black,
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
|
|
// 右箭头
|
|
Icon(
|
|
Icons.arrow_forward_ios,
|
|
size: 16.w,
|
|
color: Color(0xFF999999),
|
|
),
|
|
],
|
|
),
|
|
).onTap(() {
|
|
// 点击跳转到用户详情页
|
|
// TODO: 导航到用户详情页
|
|
});
|
|
}
|
|
|
|
// 设置选项列表
|
|
Widget _buildSettingsList(ChatSettingsController controller) {
|
|
return Column(
|
|
children: [
|
|
// 设置备注名
|
|
_buildSettingItem(
|
|
title: '设置备注名',
|
|
showArrow: true,
|
|
onTap: () {
|
|
// TODO: 打开设置备注名弹窗
|
|
_showSetRemarkDialog(controller);
|
|
},
|
|
),
|
|
|
|
_buildDivider(),
|
|
|
|
// 加入黑名单
|
|
_buildSwitchItem(
|
|
title: '加入黑名单',
|
|
value: controller.isBlacklisted.value,
|
|
onChanged: (value) {
|
|
controller.toggleBlacklist(value);
|
|
},
|
|
),
|
|
|
|
_buildDivider(),
|
|
|
|
// 举报
|
|
_buildSettingItem(
|
|
title: '举报',
|
|
showArrow: true,
|
|
onTap: () {
|
|
// TODO: 跳转到举报页面
|
|
controller.reportUser();
|
|
},
|
|
),
|
|
|
|
_buildDivider(),
|
|
|
|
],
|
|
);
|
|
}
|
|
|
|
// 设置项(带箭头)
|
|
Widget _buildSettingItem({
|
|
required String title,
|
|
bool showArrow = false,
|
|
VoidCallback? onTap,
|
|
}) {
|
|
return Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 16.sp,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
if (showArrow)
|
|
Icon(
|
|
Icons.arrow_forward_ios,
|
|
size: 16.w,
|
|
color: Color(0xFF999999),
|
|
),
|
|
],
|
|
),
|
|
).onTap(onTap);
|
|
}
|
|
|
|
// 开关项
|
|
Widget _buildSwitchItem({
|
|
required String title,
|
|
required bool value,
|
|
required ValueChanged<bool> onChanged,
|
|
}) {
|
|
return Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 16.sp,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
Obx(() {
|
|
final controller = Get.find<ChatSettingsController>();
|
|
return CupertinoSwitch(
|
|
value: controller.isBlacklisted.value,
|
|
onChanged: onChanged,
|
|
activeColor: Color.fromRGBO(117, 98, 249, 1),
|
|
);
|
|
}),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// 分隔线
|
|
Widget _buildDivider() {
|
|
return Container(
|
|
margin: EdgeInsets.only(left: 16.w),
|
|
height: 1.h,
|
|
color: Color(0xFFF5F5F5),
|
|
);
|
|
}
|
|
|
|
// 关注按钮
|
|
Widget _buildFollowButton(ChatSettingsController controller) {
|
|
return Obx(() {
|
|
final isFollowing = controller.isFollowing.value;
|
|
return Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 25.w),
|
|
width: double.infinity,
|
|
height: 50.h,
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
controller.toggleFollow();
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Color.fromRGBO(117, 98, 249, 1),
|
|
foregroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(24.r),
|
|
),
|
|
elevation: 0,
|
|
),
|
|
child: Text(
|
|
isFollowing ? '已关注' : '关注',
|
|
style: TextStyle(
|
|
fontSize: 18.sp,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
// 设置备注名对话框
|
|
void _showSetRemarkDialog(ChatSettingsController controller) {
|
|
final TextEditingController textController = TextEditingController();
|
|
|
|
Get.dialog(
|
|
AlertDialog(
|
|
title: Text('设置备注名'),
|
|
content: TextField(
|
|
controller: textController,
|
|
decoration: InputDecoration(
|
|
hintText: '请输入备注名',
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8.r),
|
|
),
|
|
),
|
|
autofocus: true,
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Get.back(),
|
|
child: Text(
|
|
'取消',
|
|
style: TextStyle(color: Color(0xFF999999)),
|
|
),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
final remark = textController.text.trim();
|
|
if (remark.isNotEmpty) {
|
|
controller.setRemark(remark);
|
|
Get.back();
|
|
}
|
|
},
|
|
child: Text(
|
|
'确定',
|
|
style: TextStyle(color: Color(0xFFA05CFF)),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|