diff --git a/lib/model/user/blacklist_model.dart b/lib/model/user/blacklist_model.dart index 4943ca4c..f1419f68 100644 --- a/lib/model/user/blacklist_model.dart +++ b/lib/model/user/blacklist_model.dart @@ -1,19 +1,18 @@ +import 'package:aku_new_community/model/common/img_model.dart'; 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; + final int id; + final List imgList; + final String? name; factory BlacklistModel.fromJson(Map json) => _$BlacklistModelFromJson(json); - BlacklistModel({ required this.id, required this.imgList, @@ -21,5 +20,9 @@ class BlacklistModel extends Equatable { }); @override - List get props => [id, imgList, name,]; -} \ No newline at end of file + List get props => [ + id, + imgList, + name, + ]; +} diff --git a/lib/model/user/blacklist_model.g.dart b/lib/model/user/blacklist_model.g.dart index 00706b1e..fe41c88e 100644 --- a/lib/model/user/blacklist_model.g.dart +++ b/lib/model/user/blacklist_model.g.dart @@ -9,6 +9,8 @@ part of 'blacklist_model.dart'; BlacklistModel _$BlacklistModelFromJson(Map json) => BlacklistModel( id: json['id'] as int, - imgList: json['imgList'] as List, - name: json['name'] as String, + imgList: (json['imgList'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + name: json['name'] as String?, ); diff --git a/lib/pages/setting_page/blacklist_page/blacklist_page.dart b/lib/pages/setting_page/blacklist_page/blacklist_page.dart index 412445af..636b8400 100644 --- a/lib/pages/setting_page/blacklist_page/blacklist_page.dart +++ b/lib/pages/setting_page/blacklist_page/blacklist_page.dart @@ -2,9 +2,11 @@ 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/bee_avatar_widget.dart'; import 'package:aku_new_community/widget/dialog/bee_custom_dialog.dart'; import 'package:aku_new_community/widget/others/user_tool.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; @@ -55,11 +57,11 @@ class _blackListPageState extends State { void initState() { super.initState(); - // ///动态appbar导致 refresh组件刷新判出现问题 首次刷新手动触发 - // Future.delayed(Duration(milliseconds: 0), () async { - // await _refresh(); - // setState(() {}); - // }); + ///动态appbar导致 refresh组件刷新判出现问题 首次刷新手动触发 + Future.delayed(Duration(milliseconds: 0), () async { + await _refresh(); + //setState(() {}); + }); } @override @@ -68,9 +70,10 @@ class _blackListPageState extends State { super.dispose(); } - // Future _refresh() async { - // blackList = await BlackListFunc.getBlackList(); - // } + Future _refresh() async { + blackList = await BlackListFunc.getBlackList(); + setState(() {}); + } @override Widget build(BuildContext context) { @@ -98,29 +101,42 @@ class _blackListPageState extends State { ])), ), 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, - ))) + child: + // ListView.builder( + // itemBuilder: (context, index) { + // //return Text('这是一个开始'); + // return _blackList(blackList[index]); + // }, + // //itemCount: 6, + // itemCount: blackList.length, + // ) + 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: blackList.isEmpty + ? SizedBox() + : ListView.builder( + itemBuilder: (context, index) { + //return Text('这是一个开始'); + return _blackList(blackList[index]); + }, + //itemCount: 6, + itemCount: blackList.length, + ))) ], )); } @@ -129,19 +145,24 @@ class _blackListPageState extends State { 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)), - ), + leading: BeeAvatarWidget( + imgs: model.imgList, + ) + + // 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), + model.name == null ? '' : _getText(model.name!), style: TextStyle(fontSize: 28.sp, color: ktextSubColor), ), trailing: GestureDetector( diff --git a/lib/pages/sign/login/other_login_page.dart b/lib/pages/sign/login/other_login_page.dart index 2403e2fd..464511aa 100644 --- a/lib/pages/sign/login/other_login_page.dart +++ b/lib/pages/sign/login/other_login_page.dart @@ -193,13 +193,13 @@ class _OtherLoginPageState extends State { }, text: clockTimer.timerStart ? '${clockTimer.second}秒后重新获取' : '获取验证码'), - 32.hb, - IconButton( - icon: Icon(Icons.ac_unit_outlined), - onPressed: () { - //Get.to(() => RootPage()); - }, - ), + // 32.hb, + // IconButton( + // icon: Icon(Icons.ac_unit_outlined), + // onPressed: () { + // //Get.to(() => RootPage()); + // }, + // ), 24.w.heightBox, Row( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/ui/community/community_views/community_page.dart b/lib/ui/community/community_views/community_page.dart index 94a9f4b8..fcd21b2c 100644 --- a/lib/ui/community/community_views/community_page.dart +++ b/lib/ui/community/community_views/community_page.dart @@ -165,6 +165,7 @@ class _CommunityPageState extends State await (getNewInfo()); _gambitModels = await CommunityFunc.getListGambit(); _hotNewsModels = await CommunityFunc.getHotNews(); + _onload = false; setState(() {}); }, diff --git a/lib/ui/community/community_views/event_detail_page.dart b/lib/ui/community/community_views/event_detail_page.dart index 48373144..2cbe220c 100644 --- a/lib/ui/community/community_views/event_detail_page.dart +++ b/lib/ui/community/community_views/event_detail_page.dart @@ -124,7 +124,7 @@ class _EventDetailPageState extends State { onSelect: (int value) async { if (LoginUtil.isNotLogin) return; if (value == 3) { - await Get.dialog(CupertinoAlertDialog( + bool? result = await Get.dialog(CupertinoAlertDialog( title: '你确定要拉黑他吗'.text.isIntrinsic.make(), actions: [ CupertinoDialogAction( @@ -132,17 +132,23 @@ class _EventDetailPageState extends State { onPressed: () => Get.back(), ), CupertinoDialogAction( - child: '确定'.text.color(Colors.orange).isIntrinsic.make(), - onPressed: () async { - var isShielding = - await BlackListFunc.Block(widget.dynamicId); - if (isShielding) { - Get.back(); - } - }, - ), + child: '确定'.text.color(Colors.orange).isIntrinsic.make(), + onPressed: () => Get.back(result: true) + // async { + // var isShielding = + // await BlackListFunc.Block(widget.dynamicId); + // if (isShielding) { + // Get.back(); + // } + // }, + ), ], )); + if (result == true) { + await BlackListFunc.Block(widget.dynamicId); + Get.back(); + widget.refresh!(); + } } else { if (!_isMyself) { VoidCallback cancel = BotToast.showLoading(); diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index f35c11c4..98d0d5f2 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -188,6 +188,7 @@ class _ChatCardState extends State { @override Widget build(BuildContext context) { + final userProvider = Provider.of(context); return DecoratedBox( decoration: BoxDecoration( color: Colors.white, @@ -255,27 +256,68 @@ class _ChatCardState extends State { isMyself: _isMyself, onSelect: (int value) async { if (LoginUtil.isNotLogin) return; - if (value == 3) { - await Get.dialog(CupertinoAlertDialog( - title: '你确定要拉黑他吗'.text.isIntrinsic.make(), - actions: [ - CupertinoDialogAction( - child: '取消'.text.black.isIntrinsic.make(), - onPressed: () => Get.back(), - ), - CupertinoDialogAction( - child: - '确定'.text.color(Colors.orange).isIntrinsic.make(), - onPressed: () async { - var isShielding = - await BlackListFunc.Block(widget.model.id); - if (isShielding) { - Get.back(); - } - }, - ), - ], - )); + if (widget.model.createId == userProvider.userInfoModel?.id) { + if (value == 3) { + //bool? result = + await Get.dialog(CupertinoAlertDialog( + title: '你确定要拉黑他吗'.text.isIntrinsic.make(), + actions: [ + CupertinoDialogAction( + child: '取消'.text.black.isIntrinsic.make(), + onPressed: () => Get.back(), + ), + CupertinoDialogAction( + child: '确定' + .text + .color(Colors.orange) + .isIntrinsic + .make(), + onPressed: () //=> Get.back(result: true), + async { + var isShielding = + await BlackListFunc.Block(widget.model.id); + if (isShielding) { + Get.back(); + } + }, + ), + ], + )); // if (result == true) { + // await BlackListFunc.Block(widget.model.id); + // widget.refresh(); + // } + + } else { + if (!_isMyself) { + VoidCallback cancel = BotToast.showLoading(); + await Future.delayed(Duration( + milliseconds: 500 + Random().nextInt(500))); + cancel(); + BotToast.showText(text: '举报成功'); + } else { + bool? result = await Get.dialog(CupertinoAlertDialog( + title: '你确定删除吗'.text.isIntrinsic.make(), + actions: [ + CupertinoDialogAction( + child: '取消'.text.black.isIntrinsic.make(), + onPressed: () => Get.back(), + ), + CupertinoDialogAction( + child: '确定' + .text + .color(Colors.orange) + .isIntrinsic + .make(), + onPressed: () => Get.back(result: true), + ), + ], + )); + if (result == true) { + await CommunityFunc.deleteDynamic(widget.model.id); + widget.refresh(); + } + } + } } else { if (!_isMyself) { VoidCallback cancel = BotToast.showLoading(); @@ -362,19 +404,21 @@ class CommunityPopButton extends StatelessWidget { shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.w)), itemBuilder: (context) { return [ - PopupMenuItem( - child: '拉黑'.text.isIntrinsic.make(), - value: 3, - ), - isMyself - ? PopupMenuItem( - child: '删除'.text.isIntrinsic.make(), - value: 0, - ) - : PopupMenuItem( - child: '举报'.text.isIntrinsic.make(), - value: 1, - ), + if (isMyself) + PopupMenuItem( + child: '删除'.text.isIntrinsic.make(), + value: 0, + ), + if (!isMyself) + PopupMenuItem( + child: '举报'.text.isIntrinsic.make(), + value: 1, + ), + if (!isMyself) + PopupMenuItem( + child: '拉黑'.text.isIntrinsic.make(), + value: 3, + ), ]; }, onSelected: onSelect,