diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index 103b526d..9ab21a31 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -410,25 +410,26 @@ class _CommunityDynamic extends State { ], ), ), - // Expanded( - // child: GestureDetector( - // behavior: HitTestBehavior.opaque, - // onTap: () { - // setState(() { - // choiceShowBottomSheet(); - // }); - // }, - // child: Container( - // alignment: Alignment.center, - // child: Text( - // "...", - // style: TextStyle( - // fontSize: 18.sp, - // fontWeight: MyFontWeight.medium, - // color: Colors.black, - // ), - // ), - // ))), + if (widget?.article?.author != widget.userId ?? "") + Expanded( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + choiceShowBottomSheet(); + }); + }, + child: Container( + alignment: Alignment.center, + child: Text( + "...", + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.medium, + color: Colors.black, + ), + ), + ))), ], ), ], @@ -772,50 +773,53 @@ class _CommunityDynamic extends State { SizedBox( height: 10, ), - GestureDetector( - onTap: () { - setState(() { - Navigator.of(context).pop(); - share(); - }); - }, - child: Container( - child: Row( - children: [ - SizedBox( - width: 4, - ), - Image.asset( - "assets/image/icon_share.webp", - fit: BoxFit.cover, - width: 25, - height: 25, - color: Color(0xff515151), - ), - SizedBox( - width: 12, - ), - Text( - "分享", - style: TextStyle( - fontSize: 17.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF1A1A1A), - ), - ), - ], - ), - )), - Container( - margin: EdgeInsets.symmetric(vertical: 12), - height: 1.h, - color: Color(0xFFF7F7F7), - ), + // GestureDetector( + // onTap: () { + // setState(() { + // Navigator.of(context).pop(); + // share(); + // }); + // }, + // child: Container( + // child: Row( + // children: [ + // SizedBox( + // width: 4, + // ), + // Image.asset( + // "assets/image/icon_share.webp", + // fit: BoxFit.cover, + // width: 25, + // height: 25, + // color: Color(0xff515151), + // ), + // SizedBox( + // width: 12, + // ), + // Text( + // "分享", + // style: TextStyle( + // fontSize: 17.sp, + // fontWeight: MyFontWeight.medium, + // color: Color(0xFF1A1A1A), + // ), + // ), + // ], + // ), + // )), + // Container( + // margin: EdgeInsets.symmetric(vertical: 12), + // height: 1.h, + // color: Color(0xFFF7F7F7), + // ), GestureDetector( onTap: () { setState(() { Navigator.of(context) - .popAndPushNamed('/router/report_page'); + .popAndPushNamed('/router/report_page',arguments: { + "userName":widget?.article?.authorName ?? "", + "authorId":widget?.article?.author ?? "", + }); }); }, child: Row( diff --git a/lib/community/report/report_page.dart b/lib/community/report/report_page.dart index d857f279..47a6d92b 100644 --- a/lib/community/report/report_page.dart +++ b/lib/community/report/report_page.dart @@ -1,13 +1,16 @@ import 'dart:ui'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import 'package:huixiang/generated/l10n.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class ReportPage extends StatefulWidget { final Map arguments; @@ -24,10 +27,37 @@ class _ReportPage extends State { ApiService apiService; int textLength = 0; final TextEditingController editingController = TextEditingController(); + String textContext; + String userName; + String authorId; @override void initState() { super.initState(); + userName = widget.arguments['userName']; + authorId = widget.arguments['authorId']; + } + + report() async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData baseData = await apiService.complaint({ + "content": editingController.text, + "informationId":authorId, + }).catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + Navigator.of(context) + .pushNamed('/router/report_success'); + editingController.clear(); + } else { + SmartDialog.showToast(baseData.msg,alignment: Alignment.center); + } } @override @@ -67,7 +97,7 @@ class _ReportPage extends State { ), ), TextSpan( - text: "@百花谷", + text: "@${userName.toString()}", style: TextStyle( fontSize: 16.sp, fontWeight: MyFontWeight.medium, @@ -86,41 +116,41 @@ class _ReportPage extends State { ), ), ), - report(), + reportContent(), SizedBox(height: 12), + if(checkIndex == 9) Container( - width: double.infinity, - height: 186.h, - margin: EdgeInsets.only(right: 16,left:40,bottom:100), - decoration: new BoxDecoration( - color: Color(0xFFF7F7F7), - borderRadius: BorderRadius.circular(4.0), - ), - child: Container( - margin: EdgeInsets.fromLTRB(20.w, 5.h, 20.w, 0), - alignment: Alignment.topLeft, - child: TextField( - maxLines: 5, - controller: editingController, - onChanged: (value) { - setState(() { - textLength = value.length; - }); - }, - maxLength: 100, - decoration: InputDecoration( - border: InputBorder.none, - hintText: "请输入举报原因,以便我们更快定位问题,快速处理", - hintStyle: TextStyle( - fontSize: 12.sp, - height: 1.2, - fontWeight: MyFontWeight.regular, - color: Color(0xFF999999), + width: double.infinity, + height: 186.h, + margin: EdgeInsets.only(right: 16, left: 40, bottom: 100), + decoration: new BoxDecoration( + color: Color(0xFFF7F7F7), + borderRadius: BorderRadius.circular(4.0), + ), + child: Container( + margin: EdgeInsets.fromLTRB(20.w, 5.h, 20.w, 0), + alignment: Alignment.topLeft, + child: TextField( + maxLines: 5, + controller: editingController, + onChanged: (value) { + setState(() { + textLength = value.length; + }); + }, + maxLength: 100, + decoration: InputDecoration( + border: InputBorder.none, + hintText: "请输入举报原因,以便我们更快定位问题,快速处理", + hintStyle: TextStyle( + fontSize: 12.sp, + height: 1.2, + fontWeight: MyFontWeight.regular, + color: Color(0xFF999999), + ), ), ), - ), - ) - ) + )) ], ), ), @@ -128,7 +158,7 @@ class _ReportPage extends State { alignment: Alignment.bottomCenter, child: Container( width: double.infinity, - height:95, + height: 95, child: Column( children: [ GestureDetector( @@ -138,7 +168,7 @@ class _ReportPage extends State { }, child: Container( alignment: Alignment.bottomCenter, - margin: EdgeInsets.only(bottom:25), + margin: EdgeInsets.only(bottom: 25), child: Text( "投诉须知", style: TextStyle( @@ -148,15 +178,16 @@ class _ReportPage extends State { ), ), )), - Expanded(child: - GestureDetector( - onTap: (){ - Navigator.of(context) - .pushNamed('/router/report_success'); - }, - child: Container( + Expanded( + child: GestureDetector( + onTap: () { + report(); + }, + child: Opacity( + opacity: checkIndex == 0 ? 0.3 : 0.9, + child: Container( width: double.infinity, - height:double.infinity, + height: double.infinity, color: Color(0xFF319E5F), alignment: Alignment.center, child: Text( @@ -167,7 +198,9 @@ class _ReportPage extends State { color: Color(0xFFFFFFFF), ), ), - ),)) + ), + ), + )) ], ), )) @@ -177,55 +210,178 @@ class _ReportPage extends State { ); } - Widget report() { + Widget reportContent() { return Container( - padding: EdgeInsets.only(left: 16, right: 16), - child: - // (articles == null || articles.length == 0) - // ? NoDataView( - // src: "assets/image/dong_tai.webp", - // isShowBtn: false, - // text: "目前暂无发布动态,要把开心的事讲出来哦~", - // fontSize: 16.sp, - // margin: EdgeInsets.only(left: 60.w, right: 60.w), - // ) : - ListView.builder( - physics: BouncingScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, position) { - return GestureDetector( - onTap: () {}, - child: reportList(), - ); - }, - itemCount: 9, + width: double.infinity, + padding: EdgeInsets.only(left:16, right:16,top:20), + child: Column( + children: [ + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + checkIndex = 1; + }); + }, + child: + content( + "色情低俗", + 1 + ), + ), + SizedBox(height: 18,), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + checkIndex = 2; + }); + }, + child: + content( + "政治宗教", + 2 + ), + ), + SizedBox(height: 18,), + GestureDetector ( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + checkIndex = 3; + }); + }, + child: + content( + "广告骚扰", + 3 + ), + ), + SizedBox(height: 18,), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + checkIndex = 4; + }); + }, + child: + content( + "虚假欺骗", + 4 + ), + ), + SizedBox(height: 18,), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + checkIndex = 5; + }); + }, + child: + content( + "侵权(诽谤、抄袭、冒用)", + 5 + ), + ), + SizedBox(height: 18,), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + checkIndex = 6; + }); + }, + child: + content( + "不良封面/标题", + 6 + ), + ), + SizedBox(height: 18,), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + checkIndex = 7; + }); + }, + child: + content( + "赌博诈骗", + 7 + ), + ), + SizedBox(height: 18,), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + checkIndex = 8; + }); + }, + child: + content( + editingController.text = "违禁内容(暴利恐怖、令人不适、宣言仇恨)", + 8 + ), + ), + SizedBox(height: 18,), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + checkIndex = 9; + }); + }, + child: + content( + "其他", + 9 + ), + ), + ], + )); + } + + var checkIndex = 0; + + Widget checkView(var index) { + return Container( + padding: EdgeInsets.only(right: 16.w,left: 5), + alignment: Alignment.center, + // color: Colors.red, + child: Image.asset( + checkIndex != index + ? "assets/image/icon_radio_unselected.webp" + : "assets/image/icon_radio_selected.webp", + width:20.w, + height:20.h, ), ); } - Widget reportList() { + Widget content(textContext,var index) { return Container( - padding: EdgeInsets.only(top: 18, bottom: 20), - color: Color(0xFFFFFFFF), - child: Row( - children: [ - Image.asset( - "assets/image/icon_radio_unselected.webp", - width: 16, - height: 16, + alignment: Alignment.center, + child:Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + checkView(index), + Container(), + Expanded(child: + Text( + textContext, + style: TextStyle( + fontSize: 16.sp, + color: Color(0xFF353535), + fontWeight: MyFontWeight.regular, ), - SizedBox( - width: 8, - ), - Expanded( - child: Text( - "色情低俗", - style: TextStyle( - color: Color(0xFF353535), - fontSize: 14.sp, - fontWeight: MyFontWeight.regular), - )) - ], - )); + ),) + ], + ), + ); } }