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.

134 lines
4.2 KiB

import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter/cupertino.dart';
import '../../generated/l10n.dart';
import '../../utils/font_weight.dart';
import '../main.dart';
import '../retrofit/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;
@override
void initState() {
super.initState();
initData();
}
void initData() async {
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(widget.arguments["userId"] ?? "");
4 months ago
// SmartDialog.showToast("删除成功",
// alignment: Alignment.center);
},
)
],
),
),
Expanded(
child: Container(
color: Colors.white,
))
],
),
),
);
}
}