parent
d373d9e528
commit
c3e6506c1d
@ -0,0 +1,25 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
part 'blacklist_model.g.dart';
|
||||
|
||||
|
||||
@JsonSerializable()
|
||||
class BlacklistModel extends Equatable {
|
||||
int id;
|
||||
List imgList;
|
||||
String name;
|
||||
|
||||
factory BlacklistModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$BlacklistModelFromJson(json);
|
||||
|
||||
|
||||
BlacklistModel({
|
||||
required this.id,
|
||||
required this.imgList,
|
||||
required this.name,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id, imgList, name,];
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'blacklist_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
BlacklistModel _$BlacklistModelFromJson(Map<String, dynamic> json) =>
|
||||
BlacklistModel(
|
||||
id: json['id'] as int,
|
||||
imgList: json['imgList'] as List<dynamic>,
|
||||
name: json['name'] as String,
|
||||
);
|
@ -0,0 +1,40 @@
|
||||
import 'package:aku_new_community/constants/saas_api.dart';
|
||||
import 'package:aku_new_community/model/user/blacklist_model.dart';
|
||||
import 'package:aku_new_community/utils/network/base_list_model.dart';
|
||||
import 'package:aku_new_community/utils/network/base_model.dart';
|
||||
import 'package:aku_new_community/utils/network/net_util.dart';
|
||||
|
||||
class BlackListFunc {
|
||||
///获取黑名单列表
|
||||
static Future<List<BlacklistModel>> getBlackList() async {
|
||||
BaseListModel model = await NetUtil().getList(
|
||||
SAASAPI.user.blackList,
|
||||
params: {
|
||||
'pageNum': 1,
|
||||
'size': 9,
|
||||
},
|
||||
);
|
||||
if (model.rows.length == 0) return [];
|
||||
return model.rows.map((e) => BlacklistModel.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
///取消拉黑用户
|
||||
static Future<bool> cancelBlock(int userId) async {
|
||||
var base = await NetUtil().get(SAASAPI.user.cancelBlock,
|
||||
params: {
|
||||
'userId': userId,
|
||||
},
|
||||
showMessage: true);
|
||||
return base.success;
|
||||
}
|
||||
|
||||
///拉黑用户
|
||||
static Future<bool> Block(int userId) async {
|
||||
var base = await NetUtil().get(SAASAPI.user.Block,
|
||||
params: {
|
||||
'userId': userId,
|
||||
},
|
||||
showMessage: true);
|
||||
return base.success;
|
||||
}
|
||||
}
|
@ -0,0 +1,216 @@
|
||||
import 'package:aku_new_community/base/base_style.dart';
|
||||
import 'package:aku_new_community/gen/assets.gen.dart';
|
||||
import 'package:aku_new_community/model/user/blacklist_model.dart';
|
||||
import 'package:aku_new_community/pages/setting_page/blacklist_page/blacklist_func.dart';
|
||||
|
||||
import 'package:aku_new_community/widget/dialog/bee_custom_dialog.dart';
|
||||
import 'package:aku_new_community/widget/others/user_tool.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:aku_new_community/utils/headers.dart';
|
||||
import 'package:aku_new_community/widget/bee_scaffold.dart';
|
||||
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class blackListPage extends StatefulWidget {
|
||||
blackListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_blackListPageState createState() => _blackListPageState();
|
||||
}
|
||||
|
||||
class _blackListPageState extends State<blackListPage> {
|
||||
List<BlacklistModel> blackList = [];
|
||||
|
||||
// List blackList2 = [
|
||||
// {
|
||||
// 'id': 1,
|
||||
// 'name': '天天',
|
||||
// 'img': [
|
||||
// Assets.images.vegetableBanner.path,
|
||||
// Assets.images.vegetableBanner.path
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// 'id': 1,
|
||||
// 'name': '天天',
|
||||
// 'img': [
|
||||
// Assets.images.vegetableBanner.path,
|
||||
// Assets.images.vegetableBanner.path
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// 'id': 1,
|
||||
// 'name': '天天',
|
||||
// 'img': [
|
||||
// Assets.images.vegetableBanner.path,
|
||||
// Assets.images.vegetableBanner.path
|
||||
// ]
|
||||
// }
|
||||
// ];
|
||||
final EasyRefreshController _refreshController = EasyRefreshController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// ///动态appbar导致 refresh组件刷新判出现问题 首次刷新手动触发
|
||||
// Future.delayed(Duration(milliseconds: 0), () async {
|
||||
// await _refresh();
|
||||
// setState(() {});
|
||||
// });
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_refreshController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// Future _refresh() async {
|
||||
// blackList = await BlackListFunc.getBlackList();
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BeeScaffold(
|
||||
title: '黑名单列表',
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
color: Color(0xF000000).withOpacity(0.06),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: 75.w,
|
||||
alignment: Alignment.center,
|
||||
child: Text.rich(TextSpan(children: [
|
||||
TextSpan(
|
||||
text: '点击',
|
||||
style:
|
||||
TextStyle(fontSize: 24.sp, color: Color(0xA6000000))),
|
||||
TextSpan(
|
||||
text: ' 移出黑名单 ',
|
||||
style: TextStyle(fontSize: 24.sp, color: Colors.blue)),
|
||||
TextSpan(
|
||||
text: '即可在社区中显示对方的动态',
|
||||
style:
|
||||
TextStyle(fontSize: 24.sp, color: Color(0xA6000000))),
|
||||
])),
|
||||
),
|
||||
Expanded(
|
||||
child: EasyRefresh(
|
||||
firstRefresh: true,
|
||||
header: MaterialHeader(),
|
||||
footer: MaterialFooter(),
|
||||
controller: _refreshController,
|
||||
onRefresh: () async {
|
||||
blackList = await BlackListFunc.getBlackList();
|
||||
// blackList = [
|
||||
// BlacklistModel(
|
||||
// id: 0,
|
||||
// imgList: [Assets.images.vegetableBanner.path],
|
||||
// name: '张天天')
|
||||
// ];
|
||||
setState(() {});
|
||||
// _page
|
||||
},
|
||||
onLoad: () async {},
|
||||
child: ListView.builder(
|
||||
itemBuilder: (context, index) {
|
||||
return _blackList(blackList[index]);
|
||||
},
|
||||
itemCount: blackList.length,
|
||||
)))
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
_blackList(BlacklistModel model) {
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Container(
|
||||
width: 88.w,
|
||||
height: 88.w,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(40),
|
||||
image: DecorationImage(
|
||||
image: ExactAssetImage(
|
||||
R.ASSETS_IMAGES_PLACEHOLDER_WEBP ?? model.imgList.first,
|
||||
),
|
||||
fit: BoxFit.cover)),
|
||||
),
|
||||
title: Text(
|
||||
_getText(model.name),
|
||||
style: TextStyle(fontSize: 28.sp, color: ktextSubColor),
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
onTap: () async {
|
||||
await Get.dialog(
|
||||
BeeCustomDialog(
|
||||
height: 247.w,
|
||||
content: Padding(
|
||||
padding: EdgeInsets.only(top: 64.w),
|
||||
child: Text(
|
||||
'确认将该用户移出黑名单列表吗',
|
||||
style: UserTool.myAppStyle.dialogContentText,
|
||||
)),
|
||||
actions: [
|
||||
MaterialButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
child: Text('考虑一下',
|
||||
style: TextStyle(
|
||||
fontSize: 28.w,
|
||||
color: Colors.black.withOpacity(0.45))),
|
||||
),
|
||||
MaterialButton(
|
||||
onPressed: () async {
|
||||
var cancelBlock =
|
||||
await BlackListFunc.cancelBlock(model.id);
|
||||
if (cancelBlock) {
|
||||
Get.back();
|
||||
_refreshController.callRefresh();
|
||||
}
|
||||
},
|
||||
child: Text('确认移出',
|
||||
style: UserTool.myAppStyle.dialogActionButtonText),
|
||||
),
|
||||
],
|
||||
),
|
||||
// barrierDismissible: false,
|
||||
);
|
||||
},
|
||||
child: '移出黑名单'.text.size(24.sp).color(Colors.blue).make()),
|
||||
),
|
||||
Divider()
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
_getText(String name) {
|
||||
String name2 = name.substring(0, 1);
|
||||
for (var i = 0; i < name.length - 1; i++) {
|
||||
name2 += '*';
|
||||
}
|
||||
return name2;
|
||||
}
|
||||
// _blackList(BlacklistModel model) {
|
||||
// return ListTile(
|
||||
// leading: Container(
|
||||
// width: 88.w,
|
||||
// height: 88.w,
|
||||
// decoration: BoxDecoration(
|
||||
// borderRadius: BorderRadius.circular(40),
|
||||
// image: DecorationImage(
|
||||
// image: ExactAssetImage(model.imgList.first),
|
||||
// fit: BoxFit.cover)),
|
||||
// ),
|
||||
// title: model.name.text.size(20.sp).color(ktextSubColor).make(),
|
||||
// subtitle: GestureDetector(
|
||||
// onTap: () {},
|
||||
// child: '移出黑名单'.text.size(24.sp).color(Colors.blue).make()),
|
||||
// );
|
||||
// }
|
||||
}
|
Loading…
Reference in new issue