From 7279ae34f42340f1d9743a077193d5c893ad795a Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 25 Jan 2021 16:33:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=BB=BA=E8=AE=AE=E8=AF=84?= =?UTF-8?q?=E4=BB=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 + lib/ui/manager/advice/advice_card.dart | 31 +++++++ lib/ui/manager/advice/advice_detail_page.dart | 3 +- .../manager/advice/advice_evaluate_page.dart | 84 +++++++++++++++++++ pubspec.lock | 7 ++ pubspec.yaml | 2 +- 6 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 lib/ui/manager/advice/advice_evaluate_page.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index a8607af7..832a945b 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -99,6 +99,9 @@ class _Manager { ///建议继续提问 String get adviceQuestion => '/user/advice/reQuestion'; + + ///建议评价 + String get adviceEvaluate => '/user/advice/evaluate'; } class _Upload { diff --git a/lib/ui/manager/advice/advice_card.dart b/lib/ui/manager/advice/advice_card.dart index dbdb1214..2eee5a63 100644 --- a/lib/ui/manager/advice/advice_card.dart +++ b/lib/ui/manager/advice/advice_card.dart @@ -1,9 +1,11 @@ +import 'package:akuCommunity/base/base_style.dart'; 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/views/horizontal_image_view.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:velocity_x/velocity_x.dart'; class AdviceCard extends StatefulWidget { @@ -21,6 +23,28 @@ class _AdviceCardState extends State { 2: '反馈中', 3: '已反馈', }[widget.model.status]; + + Widget _buildRating() { + if (widget.model.score == null) + return SizedBox(); + else + return [ + 120.hb, + 24.wb, + '评测得分'.text.size(32.sp).color(ktextSubColor).make(), + Spacer(), + RatingBarIndicator( + itemBuilder: (context, index) => Icon( + Icons.star_rounded, + color: kPrimaryColor, + ), + rating: widget.model.score / 2, + itemSize: 40.w, + ), + 24.wb, + ].row(); + } + @override Widget build(BuildContext context) { return MaterialButton( @@ -54,6 +78,13 @@ class _AdviceCardState extends State { ), widget.model.content.text.size(28.w).black.make().pSymmetric(h: 28.w), HorizontalImageView(widget.model.imgUrls.map((e) => e.url).toList()), + widget.model.score == null + ? SizedBox() + : Divider( + indent: 32.w, + endIndent: 32.w, + ), + _buildRating(), ], ), ); diff --git a/lib/ui/manager/advice/advice_detail_page.dart b/lib/ui/manager/advice/advice_detail_page.dart index 2094988b..5160fa8d 100644 --- a/lib/ui/manager/advice/advice_detail_page.dart +++ b/lib/ui/manager/advice/advice_detail_page.dart @@ -3,6 +3,7 @@ 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/ui/manager/advice/advice_evaluate_page.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/utils/headers.dart'; @@ -160,7 +161,7 @@ class _AdviceDetailPageState extends State { title: '查看详情', actions: [ FlatButton( - onPressed: () {}, + onPressed: AdviceEvaluatePage(id: widget.model.id).to, child: '评价'.text.make(), ), ], diff --git a/lib/ui/manager/advice/advice_evaluate_page.dart b/lib/ui/manager/advice/advice_evaluate_page.dart new file mode 100644 index 00000000..b9fa9a2e --- /dev/null +++ b/lib/ui/manager/advice/advice_evaluate_page.dart @@ -0,0 +1,84 @@ +import 'package:akuCommunity/base/base_style.dart'; +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:flutter/material.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class AdviceEvaluatePage extends StatefulWidget { + final int id; + AdviceEvaluatePage({Key key, @required this.id}) : super(key: key); + + @override + _AdviceEvaluatePageState createState() => _AdviceEvaluatePageState(); +} + +class _AdviceEvaluatePageState extends State { + int _rating = 10; + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '评价', + body: ListView( + padding: EdgeInsets.all(32.w), + children: [ + VxBox( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '请您对本次服务进行评价'.text.size(28.sp).color(Color(0xFF999999)).make(), + 50.hb, + Row( + children: [ + '综合评价'.text.size(28.sp).color(Color(0xFF999999)).make(), + 50.wb, + RatingBar.builder( + initialRating: _rating / 2, + minRating: 0.5, + direction: Axis.horizontal, + allowHalfRating: true, + itemCount: 5, + // itemPadding: EdgeInsets.symmetric(horizontal: 16.w), + itemBuilder: (context, _) => Icon( + Icons.star_border_rounded, + color: kPrimaryColor, + ), + itemSize: 64.w, + onRatingUpdate: (rating) { + _rating = (rating * 2).floor(); + }, + glow: false, + ) + ], + ), + ], + ), + ).padding(EdgeInsets.all(32.w)).white.make(), + 42.hb, + MaterialButton( + height: 96.w, + shape: StadiumBorder(), + color: kPrimaryColor, + elevation: 0, + onPressed: () async { + BaseModel baseModel = await NetUtil().post( + API.manager.adviceEvaluate, + params: {'id': widget.id, 'score': _rating}, + showMessage: true, + ); + if (baseModel.status) { + Get.back(); + Get.back(); + } + }, + child: '确认'.text.bold.size(32.sp).make(), + ), + ], + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 05d4110e..1f914f0b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -410,6 +410,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.11" + flutter_rating_bar: + dependency: "direct main" + description: + name: flutter_rating_bar + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.0+1" flutter_redux: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 3ca07b1c..0b4e37d5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -102,7 +102,7 @@ dependencies: power_logger: git: url: http://192.168.2.201:8099/aku_fe/power_logger.git - + flutter_rating_bar: ^3.2.0+1 dev_dependencies: