From cfa7b2c54dc9975a94c1a51a853ed8c16937e5bc Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 25 Jan 2021 13:07:29 +0800 Subject: [PATCH 1/4] update beeImagePreview update horizontal image view --- lib/const/resource.dart | 3 +-- lib/widget/horizontal_image_view.dart | 33 +++++++++++++++++------- lib/widget/picker/bee_image_preview.dart | 32 +++++++++++++++++++---- lib/widget/picker/grid_image_picker.dart | 2 +- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/lib/const/resource.dart b/lib/const/resource.dart index ae65be93..aeb32a6d 100644 --- a/lib/const/resource.dart +++ b/lib/const/resource.dart @@ -1,8 +1,7 @@ /// Generate by [resource_generator](https://github.com/CaiJingLong/flutter_resource_generator) library. /// PLEASE DO NOT EDIT MANUALLY. class R { - /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/.DS_Store) - static const String ASSETS__DS_STORE = 'assets/.DS_Store'; + const R._(); /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/example/QR_code.png) static const String ASSETS_EXAMPLE_QR_CODE_PNG = 'assets/example/QR_code.png'; diff --git a/lib/widget/horizontal_image_view.dart b/lib/widget/horizontal_image_view.dart index 020249db..66a51641 100644 --- a/lib/widget/horizontal_image_view.dart +++ b/lib/widget/horizontal_image_view.dart @@ -1,9 +1,11 @@ import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/picker/bee_image_preview.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:akuCommunity/const/resource.dart'; +import 'package:get/get.dart'; class HorizontalImageView extends StatefulWidget { final List urls; @@ -21,17 +23,30 @@ class _HorizontalImageViewState extends State { Widget build(BuildContext context) { if (widget.urls.isEmpty) return 15.hb; return Container( - height: 184.w + 24.w, - child: ListView.builder( + height: 184.w + 32.w, + child: ListView.separated( + padding: EdgeInsets.all(16.w), + separatorBuilder: (_, __) => 16.wb, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { - return Padding( - padding: EdgeInsets.all(16.w), - child: ClipRRect( - borderRadius: BorderRadius.circular(8.w), - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_ICONS_PROPOSAL_PNG, - image: API.image(widget.urls[index]), + return ClipRRect( + borderRadius: BorderRadius.circular(8.w), + child: GestureDetector( + onTap: () { + Get.to( + BeeImagePreview.path(path: widget.urls[index]), + opaque: false, + ); + }, + child: Hero( + tag: widget.urls[index], + child: FadeInImage.assetNetwork( + height: 184.w, + width: 184.w, + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image(widget.urls[index]), + fit: BoxFit.cover, + ), ), ), ); diff --git a/lib/widget/picker/bee_image_preview.dart b/lib/widget/picker/bee_image_preview.dart index bb6781c9..4534954c 100644 --- a/lib/widget/picker/bee_image_preview.dart +++ b/lib/widget/picker/bee_image_preview.dart @@ -1,17 +1,42 @@ import 'dart:io'; +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/constants/api.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class BeeImagePreview extends StatefulWidget { final File file; - BeeImagePreview({Key key, @required this.file}) : super(key: key); + final String path; + BeeImagePreview.file({Key key, @required this.file}) + : path = null, + super(key: key); + + BeeImagePreview.path({Key key, @required this.path}) + : file = null, + super(key: key); @override _BeeImagePreviewState createState() => _BeeImagePreviewState(); } class _BeeImagePreviewState extends State { + Widget get image { + if (widget.file == null) + return Hero( + tag: widget.path, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image(widget.path), + ), + ); + else + return Hero( + tag: widget.file.hashCode, + child: Image.file(widget.file), + ); + } + @override Widget build(BuildContext context) { return GestureDetector( @@ -21,10 +46,7 @@ class _BeeImagePreviewState extends State { body: Center( child: InteractiveViewer( minScale: 0.2, - child: Hero( - tag: widget.file.hashCode, - child: Image.file(widget.file), - ), + child: image, ), ), ), diff --git a/lib/widget/picker/grid_image_picker.dart b/lib/widget/picker/grid_image_picker.dart index a0b29eef..9bcbc420 100644 --- a/lib/widget/picker/grid_image_picker.dart +++ b/lib/widget/picker/grid_image_picker.dart @@ -77,7 +77,7 @@ class _GridImagePickerState extends State { ), child: MaterialButton( onPressed: () { - Get.to(BeeImagePreview(file: file),opaque: false); + Get.to(BeeImagePreview.file(file: file), opaque: false); }, onLongPress: () async { bool result = await Get.dialog(CupertinoAlertDialog( From c342e4be561783056dd5141cf89800e186dabe16 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 25 Jan 2021 14:09:43 +0800 Subject: [PATCH 2/4] update advice page --- lib/model/manager/advice_detail_model.dart | 161 ++++++++++++++++++ lib/ui/manager/advice/advice_card.dart | 3 +- lib/ui/manager/advice/advice_detail_page.dart | 89 ++++++++++ lib/ui/manager/advice/advice_page.dart | 17 +- lib/ui/manager/advice/new_advice_page.dart | 3 +- pubspec.yaml | 4 +- 6 files changed, 273 insertions(+), 4 deletions(-) create mode 100644 lib/model/manager/advice_detail_model.dart create mode 100644 lib/ui/manager/advice/advice_detail_page.dart diff --git a/lib/model/manager/advice_detail_model.dart b/lib/model/manager/advice_detail_model.dart new file mode 100644 index 00000000..7f2e3b24 --- /dev/null +++ b/lib/model/manager/advice_detail_model.dart @@ -0,0 +1,161 @@ +import 'package:common_utils/common_utils.dart'; + +class AdviceDetailModel { + AppAdviceDetailVo appAdviceDetailVo; + + AdviceDetailModel({this.appAdviceDetailVo}); + + AdviceDetailModel.fromJson(Map json) { + appAdviceDetailVo = json['appAdviceDetailVo'] != null + ? new AppAdviceDetailVo.fromJson(json['appAdviceDetailVo']) + : null; + } + + Map toJson() { + final Map data = new Map(); + if (this.appAdviceDetailVo != null) { + data['appAdviceDetailVo'] = this.appAdviceDetailVo.toJson(); + } + return data; + } +} + +class AppAdviceDetailVo { + AppAdviceVo appAdviceVo; + List appAdviceContentVos; + + AppAdviceDetailVo({this.appAdviceVo, this.appAdviceContentVos}); + + AppAdviceDetailVo.fromJson(Map json) { + appAdviceVo = json['appAdviceVo'] != null + ? new AppAdviceVo.fromJson(json['appAdviceVo']) + : null; + if (json['appAdviceContentVos'] != null) { + appAdviceContentVos = new List(); + json['appAdviceContentVos'].forEach((v) { + appAdviceContentVos.add(new AppAdviceContentVos.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + if (this.appAdviceVo != null) { + data['appAdviceVo'] = this.appAdviceVo.toJson(); + } + if (this.appAdviceContentVos != null) { + data['appAdviceContentVos'] = + this.appAdviceContentVos.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class AppAdviceVo { + int id; + int type; + int status; + String content; + String createDate; + List imgUrls; + + DateTime get date => DateUtil.getDateTime(createDate); + + AppAdviceVo( + {this.id, + this.type, + this.status, + this.content, + this.createDate, + this.imgUrls}); + + AppAdviceVo.fromJson(Map json) { + id = json['id']; + type = json['type']; + status = json['status']; + content = json['content']; + createDate = json['createDate']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgUrls.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['type'] = this.type; + data['status'] = this.status; + data['content'] = this.content; + data['createDate'] = this.createDate; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ImgUrls { + String url; + String size; + int longs; + int paragraph; + int sort; + + ImgUrls({this.url, this.size, this.longs, this.paragraph, this.sort}); + + ImgUrls.fromJson(Map json) { + url = json['url']; + size = json['size']; + longs = json['longs']; + paragraph = json['paragraph']; + sort = json['sort']; + } + + Map toJson() { + final Map data = new Map(); + data['url'] = this.url; + data['size'] = this.size; + data['longs'] = this.longs; + data['paragraph'] = this.paragraph; + data['sort'] = this.sort; + return data; + } +} + +class AppAdviceContentVos { + int id; + int createUserType; + String content; + String createDate; + int parentId; + + AppAdviceContentVos( + {this.id, + this.createUserType, + this.content, + this.createDate, + this.parentId}); + + DateTime get date => DateUtil.getDateTime(createDate); + + AppAdviceContentVos.fromJson(Map json) { + id = json['id']; + createUserType = json['createUserType']; + content = json['content']; + createDate = json['createDate']; + parentId = json['parentId']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['createUserType'] = this.createUserType; + data['content'] = this.content; + data['createDate'] = this.createDate; + data['parentId'] = this.parentId; + return data; + } +} diff --git a/lib/ui/manager/advice/advice_card.dart b/lib/ui/manager/advice/advice_card.dart index d4c11ee6..ea6bfb73 100644 --- a/lib/ui/manager/advice/advice_card.dart +++ b/lib/ui/manager/advice/advice_card.dart @@ -1,4 +1,5 @@ import 'package:akuCommunity/model/manager/suggestion_or_complain_model.dart'; +import 'package:akuCommunity/ui/manager/advice/advice_detail_page.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/horizontal_image_view.dart'; import 'package:common_utils/common_utils.dart'; @@ -26,7 +27,7 @@ class _AdviceCardState extends State { elevation: 0, padding: EdgeInsets.zero, color: Colors.white, - onPressed: () {}, + onPressed: AdviceDetailPage(type: widget.model.type).to, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.w), ), diff --git a/lib/ui/manager/advice/advice_detail_page.dart b/lib/ui/manager/advice/advice_detail_page.dart new file mode 100644 index 00000000..8f7695e9 --- /dev/null +++ b/lib/ui/manager/advice/advice_detail_page.dart @@ -0,0 +1,89 @@ +import 'package:akuCommunity/model/manager/advice_detail_model.dart'; +import 'package:akuCommunity/ui/manager/advice/advice_page.dart'; +import 'package:akuCommunity/utils/network/net_util.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:shimmer/shimmer.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class AdviceDetailPage extends StatefulWidget { + final int type; + AdviceDetailPage({Key key, @required this.type}) : super(key: key); + + @override + _AdviceDetailPageState createState() => _AdviceDetailPageState(); +} + +class _AdviceDetailPageState extends State { + bool _loading = true; + EasyRefreshController _refreshController = EasyRefreshController(); + AdviceDetailModel _model; + String get adviceValue { + switch (widget.type) { + case 1: + return '咨询'; + case 2: + return '建议'; + case 3: + return '投诉'; + case 4: + return '表扬'; + } + return ''; + } + + _buildShimmer() { + return Shimmer.fromColors( + child: Padding( + padding: EdgeInsets.all(32.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + VxBox().height(53.w).width(152.w).color(Colors.white).make(), + 30.hb, + VxBox().height(40.w).width(600.w).color(Colors.white).make(), + 24.hb, + VxBox().height(33.w).width(263.w).color(Colors.white).make(), + 50.hb, + VxBox().height(53.w).width(152.w).color(Colors.white).make(), + 30.hb, + VxBox().height(40.w).width(600.w).color(Colors.white).make(), + 24.hb, + VxBox().height(33.w).width(263.w).color(Colors.white).make(), + ], + ), + ), + baseColor: Colors.black12, + highlightColor: Colors.white10, + ); + } + + _buildChild() { + return ListView( + padding: EdgeInsets.all(32.w), + children: [ + '您的$adviceValue'.text.black.bold.size(38.sp).make(), + 30.hb, + ], + ); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '查看详情', + body: EasyRefresh( + firstRefresh: true, + child: _loading ? _buildShimmer() : _buildChild(), + controller: _refreshController, + header: MaterialHeader(), + onRefresh: () async { + _loading = false; + setState(() {}); + }, + ), + ); + } +} diff --git a/lib/ui/manager/advice/advice_page.dart b/lib/ui/manager/advice/advice_page.dart index 91f17431..dbdc9dc5 100644 --- a/lib/ui/manager/advice/advice_page.dart +++ b/lib/ui/manager/advice/advice_page.dart @@ -7,8 +7,11 @@ import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:akuCommunity/widget/tab_bar/bee_tab_bar.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; enum AdviceType { SUGGESTION, @@ -107,7 +110,19 @@ class _AdvicePageState extends State with TickerProviderStateMixin { }).toList(), ), bottomNavi: BottomButton( - onPressed: NewAdvicePage(type: widget.type).to, + onPressed: () async { + bool needRefresh = await Get.to(NewAdvicePage(type: widget.type)); + if (needRefresh == true) _refreshController.callRefresh(); + Get.dialog(CupertinoAlertDialog( + title: '您的信息已提交,我们会尽快回复您,祝您生活愉快'.text.isIntrinsic.make(), + actions: [ + CupertinoDialogAction( + child: '确定'.text.color(Color(0xFFFF8200)).isIntrinsic.make(), + onPressed: Get.back, + ), + ], + )); + }, child: Text('新增'), ), ); diff --git a/lib/ui/manager/advice/new_advice_page.dart b/lib/ui/manager/advice/new_advice_page.dart index 0923f932..daa44393 100644 --- a/lib/ui/manager/advice/new_advice_page.dart +++ b/lib/ui/manager/advice/new_advice_page.dart @@ -11,6 +11,7 @@ import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:akuCommunity/widget/picker/grid_image_picker.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:common_utils/common_utils.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -104,7 +105,7 @@ class _NewAdvicePageState extends State { ); cancel(); if (baseModel.status) { - Get.back(); + Get.back(result: true); } } diff --git a/pubspec.yaml b/pubspec.yaml index 22e15e54..3ca07b1c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -69,7 +69,7 @@ dependencies: #http dio: ^3.0.10 #骨架 - shimmer: ^1.1.1 + shimmer: ^1.1.2 #动画alert rflutter_alert: ^1.1.0 @@ -102,6 +102,8 @@ dependencies: power_logger: git: url: http://192.168.2.201:8099/aku_fe/power_logger.git + + dev_dependencies: flutter_test: From 080b222b701647c8109e85f3f99d3d1b04f25e24 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 25 Jan 2021 14:59:11 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=BB=BA=E8=AE=AE=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 4 + lib/pages/community/widget/trend_card.dart | 2 +- .../widget/goods_comments_card.dart | 2 +- lib/pages/things_page/fixed_submit_page.dart | 2 +- .../things_detail_page.dart | 2 +- lib/pages/things_page/widget/things_card.dart | 2 +- lib/ui/manager/advice/advice_card.dart | 4 +- lib/ui/manager/advice/advice_detail_page.dart | 100 +++++++++++++----- lib/ui/manager/advice/advice_page.dart | 22 ++-- lib/utils/network/net_util.dart | 41 ++++--- lib/widget/picker/bee_image_preview.dart | 12 ++- lib/widget/views/bee_grid_image_view.dart | 54 ++++++++++ .../{ => views}/horizontal_image_view.dart | 35 +++--- 13 files changed, 193 insertions(+), 89 deletions(-) create mode 100644 lib/widget/views/bee_grid_image_view.dart rename lib/widget/{ => views}/horizontal_image_view.dart (60%) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 68572bfe..4bf44669 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -90,8 +90,12 @@ class _Manager { ///报事报修:app根据用户id和报事报修主键id查询报事报修详情(报修信息详情) String get reportRepairFindBYLD => '/user/reportRepair/findById'; + /// 咨询建议/投诉表扬:添加建议咨询/投诉表扬 信息 String get addAdvice => '/user/advice/insert'; + + ///建议详情 + String get adviceDetail => '/user/advice/findAdviceDetailByAdviceId'; } class _Upload { diff --git a/lib/pages/community/widget/trend_card.dart b/lib/pages/community/widget/trend_card.dart index eb85b937..659eeb23 100644 --- a/lib/pages/community/widget/trend_card.dart +++ b/lib/pages/community/widget/trend_card.dart @@ -1,6 +1,6 @@ import 'dart:ui'; import 'package:akuCommunity/base/base_style.dart'; -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; diff --git a/lib/pages/goods_details/widget/goods_comments_card.dart b/lib/pages/goods_details/widget/goods_comments_card.dart index 3206d26f..4963b6c1 100644 --- a/lib/pages/goods_details/widget/goods_comments_card.dart +++ b/lib/pages/goods_details/widget/goods_comments_card.dart @@ -1,4 +1,4 @@ -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_icons/flutter_icons.dart'; diff --git a/lib/pages/things_page/fixed_submit_page.dart b/lib/pages/things_page/fixed_submit_page.dart index cac0cd42..f95e05d0 100644 --- a/lib/pages/things_page/fixed_submit_page.dart +++ b/lib/pages/things_page/fixed_submit_page.dart @@ -8,7 +8,7 @@ import 'package:akuCommunity/pages/things_page/widget/fixed_check_box.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/bee_map.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; diff --git a/lib/pages/things_page/things_detail_page/things_detail_page.dart b/lib/pages/things_page/things_detail_page/things_detail_page.dart index fb553faa..ec5702b0 100644 --- a/lib/pages/things_page/things_detail_page/things_detail_page.dart +++ b/lib/pages/things_page/things_detail_page/things_detail_page.dart @@ -1,6 +1,6 @@ import 'package:akuCommunity/pages/things_page/things_evaluate_page/things_evaluate_page.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:akuCommunity/utils/headers.dart'; diff --git a/lib/pages/things_page/widget/things_card.dart b/lib/pages/things_page/widget/things_card.dart index af30c4a1..81a6766a 100644 --- a/lib/pages/things_page/widget/things_card.dart +++ b/lib/pages/things_page/widget/things_card.dart @@ -1,5 +1,5 @@ import 'package:akuCommunity/pages/things_page/things_detail_page/things_detail_page.dart'; -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:akuCommunity/utils/headers.dart'; diff --git a/lib/ui/manager/advice/advice_card.dart b/lib/ui/manager/advice/advice_card.dart index ea6bfb73..dbdb1214 100644 --- a/lib/ui/manager/advice/advice_card.dart +++ b/lib/ui/manager/advice/advice_card.dart @@ -1,7 +1,7 @@ import 'package:akuCommunity/model/manager/suggestion_or_complain_model.dart'; import 'package:akuCommunity/ui/manager/advice/advice_detail_page.dart'; import 'package:akuCommunity/utils/headers.dart'; -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; import 'package:velocity_x/velocity_x.dart'; @@ -27,7 +27,7 @@ class _AdviceCardState extends State { elevation: 0, padding: EdgeInsets.zero, color: Colors.white, - onPressed: AdviceDetailPage(type: widget.model.type).to, + onPressed: AdviceDetailPage(model: widget.model).to, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.w), ), diff --git a/lib/ui/manager/advice/advice_detail_page.dart b/lib/ui/manager/advice/advice_detail_page.dart index 8f7695e9..47984121 100644 --- a/lib/ui/manager/advice/advice_detail_page.dart +++ b/lib/ui/manager/advice/advice_detail_page.dart @@ -1,16 +1,21 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/manager/advice_detail_model.dart'; -import 'package:akuCommunity/ui/manager/advice/advice_page.dart'; +import 'package:akuCommunity/model/manager/suggestion_or_complain_model.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/views/bee_grid_image_view.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:shimmer/shimmer.dart'; import 'package:velocity_x/velocity_x.dart'; class AdviceDetailPage extends StatefulWidget { - final int type; - AdviceDetailPage({Key key, @required this.type}) : super(key: key); + final SuggestionOrComplainModel model; + AdviceDetailPage({Key key, @required this.model}) : super(key: key); @override _AdviceDetailPageState createState() => _AdviceDetailPageState(); @@ -21,7 +26,7 @@ class _AdviceDetailPageState extends State { EasyRefreshController _refreshController = EasyRefreshController(); AdviceDetailModel _model; String get adviceValue { - switch (widget.type) { + switch (widget.model.type) { case 1: return '咨询'; case 2: @@ -35,28 +40,42 @@ class _AdviceDetailPageState extends State { } _buildShimmer() { - return Shimmer.fromColors( - child: Padding( - padding: EdgeInsets.all(32.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - VxBox().height(53.w).width(152.w).color(Colors.white).make(), - 30.hb, - VxBox().height(40.w).width(600.w).color(Colors.white).make(), - 24.hb, - VxBox().height(33.w).width(263.w).color(Colors.white).make(), - 50.hb, - VxBox().height(53.w).width(152.w).color(Colors.white).make(), - 30.hb, - VxBox().height(40.w).width(600.w).color(Colors.white).make(), - 24.hb, - VxBox().height(33.w).width(263.w).color(Colors.white).make(), - ], - ), + return Padding( + padding: EdgeInsets.all(32.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Shimmer.fromColors( + baseColor: Colors.black12, + highlightColor: Colors.white10, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + VxBox().height(53.w).width(152.w).color(Colors.white).make(), + 30.hb, + VxBox().height(40.w).width(600.w).color(Colors.white).make(), + 24.hb, + VxBox().height(33.w).width(263.w).color(Colors.white).make(), + 50.hb, + VxBox().height(53.w).width(152.w).color(Colors.white).make(), + 30.hb, + VxBox().height(40.w).width(600.w).color(Colors.white).make(), + 24.hb, + VxBox().height(33.w).width(263.w).color(Colors.white).make(), + ], + ), + ), + Divider( + height: 50.w, + thickness: 1.w, + color: Color(0xFFD8D8D8), + ), + BeeGridImageView( + urls: widget.model.imgUrls.map((e) => e.url).toList(), + padding: EdgeInsets.only(right: 100.w), + ), + ], ), - baseColor: Colors.black12, - highlightColor: Colors.white10, ); } @@ -66,10 +85,34 @@ class _AdviceDetailPageState extends State { children: [ '您的$adviceValue'.text.black.bold.size(38.sp).make(), 30.hb, + _model.appAdviceDetailVo.appAdviceVo.content.text + .color(ktextSubColor) + .size(28.sp) + .make(), + 24.hb, + DateUtil.formatDate( + _model.appAdviceDetailVo.appAdviceVo.date, + format: 'yyyy年MM月dd日 HH:mm', + ).text.make(), + Divider( + height: 50.w, + thickness: 1.w, + color: Color(0xFFD8D8D8), + ), + BeeGridImageView( + urls: widget.model.imgUrls.map((e) => e.url).toList(), + padding: EdgeInsets.only(right: 100.w), + ), ], ); } + @override + void dispose() { + _refreshController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return BeeScaffold( @@ -80,8 +123,13 @@ class _AdviceDetailPageState extends State { controller: _refreshController, header: MaterialHeader(), onRefresh: () async { + Response res = await NetUtil().dio.get( + API.manager.adviceDetail, + queryParameters: {'adviceId': widget.model.id}, + ); + _model = AdviceDetailModel.fromJson(res.data); _loading = false; - setState(() {}); + if (mounted) setState(() {}); }, ), ); diff --git a/lib/ui/manager/advice/advice_page.dart b/lib/ui/manager/advice/advice_page.dart index dbdc9dc5..a9c0b07f 100644 --- a/lib/ui/manager/advice/advice_page.dart +++ b/lib/ui/manager/advice/advice_page.dart @@ -112,16 +112,18 @@ class _AdvicePageState extends State with TickerProviderStateMixin { bottomNavi: BottomButton( onPressed: () async { bool needRefresh = await Get.to(NewAdvicePage(type: widget.type)); - if (needRefresh == true) _refreshController.callRefresh(); - Get.dialog(CupertinoAlertDialog( - title: '您的信息已提交,我们会尽快回复您,祝您生活愉快'.text.isIntrinsic.make(), - actions: [ - CupertinoDialogAction( - child: '确定'.text.color(Color(0xFFFF8200)).isIntrinsic.make(), - onPressed: Get.back, - ), - ], - )); + if (needRefresh == true) { + _refreshController.callRefresh(); + Get.dialog(CupertinoAlertDialog( + title: '您的信息已提交,我们会尽快回复您,祝您生活愉快'.text.isIntrinsic.make(), + actions: [ + CupertinoDialogAction( + child: '确定'.text.color(Color(0xFFFF8200)).isIntrinsic.make(), + onPressed: Get.back, + ), + ], + )); + } }, child: Text('新增'), ), diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index 942bc99c..8c3fe6ee 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -37,6 +37,23 @@ class NetUtil { headers: {}, ); if (_dio == null) _dio = Dio(options); + dio.interceptors.add(InterceptorsWrapper( + onRequest: (RequestOptions options) async => options, + onResponse: (Response response) async { + _logger.v({ + 'path': response.request.path, + 'header': response.request.headers, + 'params': response.request.queryParameters, + 'data': response.data, + }); + LoggerData.addData(response); + return response; + }, + onError: (DioError error) async { + _parseErr(error); + return error; + }, + )); } ///call auth after login @@ -55,13 +72,6 @@ class NetUtil { }) async { try { Response res = await _dio.get(path, queryParameters: params); - _logger.v({ - 'path': res.request.path, - 'header': res.request.headers, - 'params': res.request.queryParameters, - 'data': res.data, - }); - LoggerData.addData(res); BaseModel baseModel = BaseModel.fromJson(res.data); _parseRequestError(baseModel, showMessage: showMessage); return baseModel; @@ -83,13 +93,7 @@ class NetUtil { }) async { try { Response res = await _dio.post(path, data: params); - _logger.v({ - 'path': res.request.path, - 'header': res.request.headers, - 'params': res.request.queryParameters, - 'data': res.data, - }); - LoggerData.addData(res); + BaseModel baseModel = BaseModel.fromJson(res.data); _parseRequestError(baseModel, showMessage: showMessage); @@ -127,17 +131,10 @@ class NetUtil { data: FormData.fromMap({ 'file': await MultipartFile.fromFile(file.path), })); - _logger.v({ - 'path': res.request.path, - 'header': res.request.headers, - 'params': res.request.queryParameters, - 'data': res.data, - }); - LoggerData.addData(res); BaseFileModel baseListModel = BaseFileModel.fromJson(res.data); return baseListModel; } on DioError catch (e) { - _parseErr(e); + print(e); } return BaseFileModel.err(); } diff --git a/lib/widget/picker/bee_image_preview.dart b/lib/widget/picker/bee_image_preview.dart index 4534954c..d5473f51 100644 --- a/lib/widget/picker/bee_image_preview.dart +++ b/lib/widget/picker/bee_image_preview.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'dart:ui'; import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/constants/api.dart'; @@ -43,10 +44,13 @@ class _BeeImagePreviewState extends State { onTap: Get.back, child: Scaffold( backgroundColor: Colors.black54, - body: Center( - child: InteractiveViewer( - minScale: 0.2, - child: image, + body: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), + child: Center( + child: InteractiveViewer( + minScale: 0.2, + child: image, + ), ), ), ), diff --git a/lib/widget/views/bee_grid_image_view.dart b/lib/widget/views/bee_grid_image_view.dart new file mode 100644 index 00000000..4d64afbf --- /dev/null +++ b/lib/widget/views/bee_grid_image_view.dart @@ -0,0 +1,54 @@ +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/picker/bee_image_preview.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class BeeGridImageView extends StatelessWidget { + final List urls; + final EdgeInsetsGeometry padding; + const BeeGridImageView({ + Key key, + @required this.urls, + this.padding = EdgeInsets.zero, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return GridView.builder( + padding: padding, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 16.w, + mainAxisSpacing: 16.w, + ), + itemBuilder: (context, index) { + return GestureDetector( + onTap: () { + Get.to( + BeeImagePreview.path(path: urls[index]), + opaque: false, + ); + }, + child: Hero( + tag: urls[index], + child: ClipRRect( + borderRadius: BorderRadius.circular(8.w), + child: FadeInImage.assetNetwork( + height: 184.w, + width: 184.w, + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image(urls[index]), + fit: BoxFit.cover, + ), + ), + ), + ); + }, + itemCount: urls.length, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + ); + } +} diff --git a/lib/widget/horizontal_image_view.dart b/lib/widget/views/horizontal_image_view.dart similarity index 60% rename from lib/widget/horizontal_image_view.dart rename to lib/widget/views/horizontal_image_view.dart index 66a51641..bc78eaf6 100644 --- a/lib/widget/horizontal_image_view.dart +++ b/lib/widget/views/horizontal_image_view.dart @@ -7,21 +7,16 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:akuCommunity/const/resource.dart'; import 'package:get/get.dart'; -class HorizontalImageView extends StatefulWidget { +class HorizontalImageView extends StatelessWidget { final List urls; HorizontalImageView( this.urls, { Key key, }) : super(key: key); - @override - _HorizontalImageViewState createState() => _HorizontalImageViewState(); -} - -class _HorizontalImageViewState extends State { @override Widget build(BuildContext context) { - if (widget.urls.isEmpty) return 15.hb; + if (urls.isEmpty) return 15.hb; return Container( height: 184.w + 32.w, child: ListView.separated( @@ -29,29 +24,29 @@ class _HorizontalImageViewState extends State { separatorBuilder: (_, __) => 16.wb, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { - return ClipRRect( - borderRadius: BorderRadius.circular(8.w), - child: GestureDetector( - onTap: () { - Get.to( - BeeImagePreview.path(path: widget.urls[index]), - opaque: false, - ); - }, - child: Hero( - tag: widget.urls[index], + return GestureDetector( + onTap: () { + Get.to( + BeeImagePreview.path(path: urls[index]), + opaque: false, + ); + }, + child: Hero( + tag: urls[index], + child: ClipRRect( + borderRadius: BorderRadius.circular(8.w), child: FadeInImage.assetNetwork( height: 184.w, width: 184.w, placeholder: R.ASSETS_IMAGES_LOGO_PNG, - image: API.image(widget.urls[index]), + image: API.image(urls[index]), fit: BoxFit.cover, ), ), ), ); }, - itemCount: widget.urls.length, + itemCount: urls.length, ), ); } From ee499642b92c8b17ebb925297db2d2f5934ef235 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 25 Jan 2021 15:59:17 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=BB=BA=E8=AE=AE=E7=BB=A7=E7=BB=AD?= =?UTF-8?q?=E6=8F=90=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 + .../advice/advice_add_comment_page.dart | 86 +++++++++++++++++++ lib/ui/manager/advice/advice_detail_page.dart | 56 +++++++++++- 3 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 lib/ui/manager/advice/advice_add_comment_page.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 4bf44669..a8607af7 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -96,6 +96,9 @@ class _Manager { ///建议详情 String get adviceDetail => '/user/advice/findAdviceDetailByAdviceId'; + + ///建议继续提问 + String get adviceQuestion => '/user/advice/reQuestion'; } class _Upload { diff --git a/lib/ui/manager/advice/advice_add_comment_page.dart b/lib/ui/manager/advice/advice_add_comment_page.dart new file mode 100644 index 00000000..cb372254 --- /dev/null +++ b/lib/ui/manager/advice/advice_add_comment_page.dart @@ -0,0 +1,86 @@ +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/utils/network/base_model.dart'; +import 'package:akuCommunity/utils/network/net_util.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/widget/buttons/bottom_button.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class AdviceAddCommentPage extends StatefulWidget { + final int id; + AdviceAddCommentPage({Key key, @required this.id}) : super(key: key); + + @override + _AdviceAddCommentPageState createState() => _AdviceAddCommentPageState(); +} + +class _AdviceAddCommentPageState extends State { + TextEditingController _textEditingController = TextEditingController(); + GlobalKey _formKey = GlobalKey(); + + @override + void dispose() { + _textEditingController?.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '继续回复', + body: ListView( + padding: EdgeInsets.all(32.w), + children: [ + '请输入内容'.text.size(28.sp).make(), + 24.hb, + Form( + key: _formKey, + child: TextFormField( + controller: _textEditingController, + validator: (text) { + if (TextUtil.isEmpty(text)) return '内容不能为空'; + return null; + }, + minLines: 7, + maxLines: 99, + decoration: InputDecoration( + border: OutlineInputBorder( + borderSide: BorderSide( + color: Color(0xFFD4CFBE), + width: 1.w, + ), + ), + contentPadding: EdgeInsets.symmetric( + vertical: 32.w, + horizontal: 22.w, + ), + ), + ), + ), + ], + ), + bottomNavi: BottomButton( + onPressed: () async { + if (_formKey.currentState.validate()) { + BaseModel baseModel = await NetUtil().post( + API.manager.adviceQuestion, + params: { + 'adviceId': widget.id, + 'content': _textEditingController.text, + 'parentId': 0, + }, + showMessage: true, + ); + if (baseModel.status) { + Get.back(result: true); + } + } + }, + child: '提交'.text.bold.make(), + ), + ); + } +} diff --git a/lib/ui/manager/advice/advice_detail_page.dart b/lib/ui/manager/advice/advice_detail_page.dart index 47984121..2094988b 100644 --- a/lib/ui/manager/advice/advice_detail_page.dart +++ b/lib/ui/manager/advice/advice_detail_page.dart @@ -2,14 +2,17 @@ import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/manager/advice_detail_model.dart'; import 'package:akuCommunity/model/manager/suggestion_or_complain_model.dart'; +import 'package:akuCommunity/ui/manager/advice/advice_add_comment_page.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:akuCommunity/widget/views/bee_grid_image_view.dart'; import 'package:common_utils/common_utils.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart' hide Response; import 'package:shimmer/shimmer.dart'; import 'package:velocity_x/velocity_x.dart'; @@ -79,6 +82,36 @@ class _AdviceDetailPageState extends State { ); } + _buildAdviceContent(AppAdviceContentVos item) { + String type = ''; + switch (item.createUserType) { + case 1: + type = '您'; + break; + case 2: + type = '装修公司'; + break; + case 3: + type = '物业'; + break; + } + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '$type\的回复'.text.size(38.sp).bold.make(), + 28.hb, + item.content.text.size(28.sp).color(ktextSubColor).make(), + 24.hb, + DateUtil.formatDate(item.date, format: 'yyyy年MM月dd日 HH:mm') + .text + .size(24.sp) + .color(Color(0xFF999999)) + .make(), + 50.hb, + ], + ); + } + _buildChild() { return ListView( padding: EdgeInsets.all(32.w), @@ -93,7 +126,7 @@ class _AdviceDetailPageState extends State { DateUtil.formatDate( _model.appAdviceDetailVo.appAdviceVo.date, format: 'yyyy年MM月dd日 HH:mm', - ).text.make(), + ).text.size(24.sp).color(Color(0xFF999999)).make(), Divider( height: 50.w, thickness: 1.w, @@ -103,6 +136,14 @@ class _AdviceDetailPageState extends State { urls: widget.model.imgUrls.map((e) => e.url).toList(), padding: EdgeInsets.only(right: 100.w), ), + Divider( + height: 50.w, + thickness: 1.w, + color: Color(0xFFD8D8D8), + ), + ..._model.appAdviceDetailVo.appAdviceContentVos + .map((e) => _buildAdviceContent(e)) + .toList(), ], ); } @@ -117,6 +158,12 @@ class _AdviceDetailPageState extends State { Widget build(BuildContext context) { return BeeScaffold( title: '查看详情', + actions: [ + FlatButton( + onPressed: () {}, + child: '评价'.text.make(), + ), + ], body: EasyRefresh( firstRefresh: true, child: _loading ? _buildShimmer() : _buildChild(), @@ -132,6 +179,13 @@ class _AdviceDetailPageState extends State { if (mounted) setState(() {}); }, ), + bottomNavi: BottomButton( + onPressed: () async { + bool result = await Get.to(AdviceAddCommentPage(id: widget.model.id)); + if (result && mounted) _refreshController.callRefresh(); + }, + child: '继续提问'.text.bold.make(), + ), ); } }