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.
358 lines
12 KiB
358 lines
12 KiB
2 years ago
|
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:huixiang/retrofit/retrofit_api.dart';
|
||
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
||
|
import 'package:flutter/cupertino.dart';
|
||
|
|
||
|
import '../../generated/l10n.dart';
|
||
|
import '../../retrofit/data/base_data.dart';
|
||
|
import '../../utils/font_weight.dart';
|
||
|
|
||
|
class NoticeSetting extends StatefulWidget {
|
||
|
@override
|
||
|
State<StatefulWidget> createState() {
|
||
|
return _NoticeSetting();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class _NoticeSetting extends State<NoticeSetting> {
|
||
|
ApiService apiService;
|
||
|
bool commentSetting = true;
|
||
|
bool followSetting = true;
|
||
|
bool likesSetting = false;
|
||
|
int index = 0;
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
}
|
||
|
|
||
|
@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(
|
||
|
color: Color(0xFFF9FAF7),
|
||
|
child: Column(
|
||
|
children: [
|
||
|
SizedBox(
|
||
|
height: 12,
|
||
|
),
|
||
|
// Container(
|
||
|
// decoration: BoxDecoration(
|
||
|
// color: Colors.white,
|
||
|
// ),
|
||
|
// padding: EdgeInsets.only(
|
||
|
// left: 16.w, right: 16.w, top: 14.h, bottom: 16.h),
|
||
|
// child: Row(
|
||
|
// children: [
|
||
|
// Expanded(
|
||
|
// child: Text(
|
||
|
// S.of(context).pinglun,
|
||
|
// style: TextStyle(
|
||
|
// fontSize: 15.sp,
|
||
|
// color: Color(0xFF353535),
|
||
|
// fontWeight: MyFontWeight.semi_bold,
|
||
|
// ),
|
||
|
// )),
|
||
|
// CupertinoSwitch(
|
||
|
// value: (commentSetting),
|
||
|
// activeColor: Color(0xFF32A060),
|
||
|
// onChanged: (bool value) {
|
||
|
// setState(() {
|
||
|
// commentSetting = !commentSetting;
|
||
|
// });
|
||
|
// },
|
||
|
// ),
|
||
|
// ],
|
||
|
// ),
|
||
|
// ),
|
||
|
// Container(
|
||
|
// decoration: BoxDecoration(
|
||
|
// color: Colors.white,
|
||
|
// ),
|
||
|
// padding: EdgeInsets.only(
|
||
|
// left: 16.w, right: 16.w, top: 14.h, bottom: 16.h),
|
||
|
// child: Row(
|
||
|
// children: [
|
||
|
// Expanded(
|
||
|
// child: Text(
|
||
|
// S.of(context).guanzhu,
|
||
|
// style: TextStyle(
|
||
|
// fontSize: 15.sp,
|
||
|
// color: Color(0xFF353535),
|
||
|
// fontWeight: MyFontWeight.semi_bold,
|
||
|
// ),
|
||
|
// )),
|
||
|
// CupertinoSwitch(
|
||
|
// value: (followSetting),
|
||
|
// activeColor: Color(0xFF32A060),
|
||
|
// onChanged: (bool value) {
|
||
|
// setState(() {
|
||
|
// followSetting = !followSetting;
|
||
|
// });
|
||
|
// },
|
||
|
// ),
|
||
|
// ],
|
||
|
// ),
|
||
|
// ),
|
||
|
// Container(
|
||
|
// decoration: BoxDecoration(
|
||
|
// color: Colors.white,
|
||
|
// ),
|
||
|
// padding: EdgeInsets.only(
|
||
|
// left: 16.w, right: 16.w, top: 14.h, bottom: 16.h),
|
||
|
// child: Row(
|
||
|
// children: [
|
||
|
// Expanded(
|
||
|
// child: Text(
|
||
|
// S.of(context).dianzan,
|
||
|
// style: TextStyle(
|
||
|
// fontSize: 15.sp,
|
||
|
// color: Color(0xFF353535),
|
||
|
// fontWeight: MyFontWeight.semi_bold,
|
||
|
// ),
|
||
|
// )),
|
||
|
// CupertinoSwitch(
|
||
|
// value: (likesSetting),
|
||
|
// activeColor: Color(0xFF32A060),
|
||
|
// onChanged: (bool value) {
|
||
|
// setState(() {
|
||
|
// likesSetting = !likesSetting;
|
||
|
// });
|
||
|
// },
|
||
|
// ),
|
||
|
// ],
|
||
|
// ),
|
||
|
// ),
|
||
|
settingItem(S.of(context).pinglun,commentSetting,(){
|
||
|
setState(() {
|
||
|
commentSetting = !commentSetting;
|
||
|
});
|
||
|
}),
|
||
|
settingItem(S.of(context).guanzhu,followSetting,(){
|
||
|
setState(() {
|
||
|
followSetting = !followSetting;
|
||
|
});
|
||
|
}),
|
||
|
settingItem(S.of(context).dianzan,likesSetting,(){
|
||
|
setState(() {
|
||
|
likesSetting = !likesSetting;
|
||
|
});
|
||
|
}),
|
||
|
SizedBox(
|
||
|
height: 12,
|
||
|
),
|
||
|
Expanded(
|
||
|
child: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
),
|
||
|
padding: EdgeInsets.only(
|
||
|
left: 16.w, right: 16.w, top: 14.h, bottom: 16.h),
|
||
|
child: Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Expanded(child: Text(
|
||
|
"谁可以私信我",
|
||
|
style: TextStyle(
|
||
|
fontSize: 15.sp,
|
||
|
color: Color(0xFF353535),
|
||
|
fontWeight: MyFontWeight.semi_bold,
|
||
|
),
|
||
|
)),
|
||
|
GestureDetector(
|
||
|
onTap: (){
|
||
|
showAlertDialog();
|
||
|
},
|
||
|
child: Text(
|
||
|
index == 0?"默认接收":(index == 1 ? "互关好友": "不接收"),
|
||
|
style: TextStyle(
|
||
|
fontSize: 14.sp,
|
||
|
color: Color(0xFF353535),
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
GestureDetector(
|
||
|
behavior: HitTestBehavior.opaque,
|
||
|
onTap: (){
|
||
|
showAlertDialog();
|
||
|
},
|
||
|
child: Image.asset(
|
||
|
"assets/image/icon_right_z.webp",
|
||
|
height:16,
|
||
|
width:16,
|
||
|
color: Colors.black,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget settingItem(text, buttonSet,fun) {
|
||
|
return Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
),
|
||
|
padding:
|
||
|
EdgeInsets.only(left: 16.w, right: 16.w, top: 14.h, bottom: 16.h),
|
||
|
child: Row(
|
||
|
children: [
|
||
|
Expanded(
|
||
|
child: Text(
|
||
|
text,
|
||
|
style: TextStyle(
|
||
|
fontSize: 15.sp,
|
||
|
color: Color(0xFF353535),
|
||
|
fontWeight: MyFontWeight.semi_bold,
|
||
|
),
|
||
|
)),
|
||
|
CupertinoSwitch(
|
||
|
value: (buttonSet),
|
||
|
activeColor: Color(0xFF32A060),
|
||
|
onChanged: (bool value) {
|
||
|
fun();
|
||
|
},
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
///私信接受设置弹窗
|
||
|
showAlertDialog() {
|
||
|
showModalBottomSheet(
|
||
|
builder: (BuildContext context) {
|
||
|
return StatefulBuilder(builder: (
|
||
|
context,
|
||
|
state,
|
||
|
) {
|
||
|
return WillPopScope(
|
||
|
///点击背景不收起弹窗;
|
||
|
// onWillPop: () async => false,
|
||
|
child: Container(
|
||
|
width: double.infinity,
|
||
|
height: 225.h,
|
||
|
padding:
|
||
|
EdgeInsets.only(left: 16.w, top:21.h),
|
||
|
decoration: new BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
borderRadius: BorderRadius.only(
|
||
|
topLeft: Radius.circular(8),
|
||
|
topRight: Radius.circular(8),
|
||
|
),
|
||
|
),
|
||
|
child: SingleChildScrollView(
|
||
|
physics: BouncingScrollPhysics(),
|
||
|
child: Container(
|
||
|
padding: EdgeInsets.only(right: 18.w),
|
||
|
width: double.infinity,
|
||
|
child: Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
GestureDetector(
|
||
|
behavior: HitTestBehavior.opaque,
|
||
|
onTap: (){
|
||
|
setState((){
|
||
|
index = 0;
|
||
|
Navigator.of(context).pop();
|
||
|
});
|
||
|
},
|
||
|
child:Container(
|
||
|
width: double.infinity,
|
||
|
padding: EdgeInsets.only(bottom: 23.h),
|
||
|
child: Text(
|
||
|
"默认接收",
|
||
|
style: TextStyle(
|
||
|
fontWeight: MyFontWeight.medium,
|
||
|
fontSize: 16.sp,
|
||
|
color: Color(0xFF353535),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
Container(
|
||
|
color: Color(0xFFF7F7F7),
|
||
|
width: double.infinity,
|
||
|
height: 1.h,
|
||
|
),
|
||
|
GestureDetector(
|
||
|
behavior: HitTestBehavior.opaque,
|
||
|
onTap: (){
|
||
|
setState((){
|
||
|
index = 1;
|
||
|
Navigator.of(context).pop();
|
||
|
});
|
||
|
},
|
||
|
child:Container(
|
||
|
width: double.infinity,
|
||
|
padding: EdgeInsets.only(top: 20.h,bottom: 23.h),
|
||
|
child: Text(
|
||
|
"互关好友",
|
||
|
style: TextStyle(
|
||
|
fontWeight: MyFontWeight.medium,
|
||
|
fontSize: 16.sp,
|
||
|
color: Color(0xFF353535),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
Container(
|
||
|
color: Color(0xFFF7F7F7),
|
||
|
width: double.infinity,
|
||
|
height: 1.h,
|
||
|
),
|
||
|
GestureDetector(
|
||
|
behavior: HitTestBehavior.opaque,
|
||
|
onTap: (){
|
||
|
setState((){
|
||
|
index = 2;
|
||
|
Navigator.of(context).pop();
|
||
|
});
|
||
|
},
|
||
|
child:Container(
|
||
|
width: double.infinity,
|
||
|
padding: EdgeInsets.only(top: 20.h),
|
||
|
child: Text(
|
||
|
"不接收",
|
||
|
style: TextStyle(
|
||
|
fontWeight: MyFontWeight.medium,
|
||
|
fontSize: 16.sp,
|
||
|
color: Color(0xFF353535),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
));
|
||
|
});
|
||
|
},
|
||
|
backgroundColor: Colors.transparent,
|
||
|
context: context);
|
||
|
}
|
||
|
}
|