|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:huixiang/im/database/message.dart';
|
|
|
|
import 'package:huixiang/utils/shared_preference.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
|
|
|
import '../../utils/font_weight.dart';
|
|
|
|
import '../main.dart';
|
|
|
|
import '../data/im_user.dart';
|
|
|
|
|
|
|
|
class ChatSetting extends StatefulWidget {
|
|
|
|
final Map<String, dynamic>? arguments;
|
|
|
|
|
|
|
|
ChatSetting({this.arguments});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _ChatSetting();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ChatSetting extends State<ChatSetting> {
|
|
|
|
ImUser? imUser;
|
|
|
|
String selfUserId = "";
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
initData();
|
|
|
|
}
|
|
|
|
|
|
|
|
void initData() async {
|
|
|
|
selfUserId = SharedInstance.instance.userId;
|
|
|
|
imUser = await hxDatabase.queryImUserById(widget.arguments?["userId"]);
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: Color(0xFFF9FAF7),
|
|
|
|
appBar: MyAppBar(
|
|
|
|
title: "聊天设置",
|
|
|
|
titleColor: Colors.black,
|
|
|
|
titleSize: 18.sp,
|
|
|
|
background: Colors.white,
|
|
|
|
leading: true,
|
|
|
|
leadingColor: Colors.black,
|
|
|
|
),
|
|
|
|
body: Container(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
color: Colors.white,
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 14.h),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 14.h),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"置顶聊天",
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
fontSize: 15.sp,
|
|
|
|
fontWeight: MyFontWeight.semi_bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
CupertinoSwitch(
|
|
|
|
value: ((imUser?.isTop ?? 0) == 1),
|
|
|
|
activeColor: Color(0xFF32A060),
|
|
|
|
onChanged: (bool value) async {
|
|
|
|
if (imUser == null) return;
|
|
|
|
imUser!.isTop = value ? 1 : 0;
|
|
|
|
await hxDatabase.insertOrUpdateImUser(imUser!.toJson());
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 31.h,
|
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"清空聊天记录",
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
fontSize: 15.sp,
|
|
|
|
fontWeight: MyFontWeight.semi_bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Image.asset(
|
|
|
|
"assets/image/icon_right_z.webp",
|
|
|
|
height: 16,
|
|
|
|
width: 16,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
onTap: () async {
|
|
|
|
await hxDatabase.deleteByUser(conversationId(widget.arguments?["userId"] ?? "", selfUserId));
|
|
|
|
// SmartDialog.showToast("删除成功",
|
|
|
|
// alignment: Alignment.center);
|
|
|
|
},
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
color: Colors.white,
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|