From c7dabba3b2f8ed2df2e6a64259ce792c59138312 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Sat, 7 Jun 2025 23:00:27 +0800 Subject: [PATCH] opt pgc review score Signed-off-by: bggRGjQaUbCoE --- lib/pages/pgc_review/post/view.dart | 63 ++++++++++++++----------- lib/pages/space_setting/controller.dart | 6 +-- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/lib/pages/pgc_review/post/view.dart b/lib/pages/pgc_review/post/view.dart index b5a99a82..a6f2538e 100644 --- a/lib/pages/pgc_review/post/view.dart +++ b/lib/pages/pgc_review/post/view.dart @@ -42,6 +42,12 @@ class _PgcReviewPostPanelState super.dispose(); } + void _onScore(double dx) { + int index = (dx / 50).toInt().clamp(0, 4); + _enablePost.value = true; + _score.value = index + 1; + } + @override Widget buildPage(ThemeData theme) { final theme = Theme.of(context); @@ -76,34 +82,35 @@ class _PgcReviewPostPanelState ), ), ), - Padding( - padding: const EdgeInsets.only(top: 20, bottom: 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: List.generate( - 5, - (index) { - return Obx( - () => GestureDetector( - onTap: () { - _enablePost.value = true; - _score.value = index + 1; - }, - behavior: HitTestBehavior.opaque, - child: index <= _score.value - 1 - ? const Icon( - CustomIcon.star_favorite_solid, - size: 50, - color: Color(0xFFFFAD35), - ) - : const Icon( - CustomIcon.star_favorite_line, - size: 50, - color: Colors.grey, - ), - ), - ); - }, + Center( + child: Padding( + padding: const EdgeInsets.only(top: 20, bottom: 10), + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onHorizontalDragUpdate: (details) => + _onScore(details.localPosition.dx), + onTapDown: (details) => _onScore(details.localPosition.dx), + child: Row( + mainAxisSize: MainAxisSize.min, + children: List.generate( + 5, + (index) { + return Obx( + () => index <= _score.value - 1 + ? const Icon( + CustomIcon.star_favorite_solid, + size: 50, + color: Color(0xFFFFAD35), + ) + : const Icon( + CustomIcon.star_favorite_line, + size: 50, + color: Colors.grey, + ), + ); + }, + ), + ), ), ), ), diff --git a/lib/pages/space_setting/controller.dart b/lib/pages/space_setting/controller.dart index f55444a6..ee0885a6 100644 --- a/lib/pages/space_setting/controller.dart +++ b/lib/pages/space_setting/controller.dart @@ -32,9 +32,9 @@ class SpaceSettingController if (data != null) { var res = await UserHttp.spaceSettingMod( { - for (var e in data.list1) ...{e.key: e.value}, - for (var e in data.list2) ...{e.key: e.value}, - for (var e in data.list3) ...{e.key: e.value}, + for (var e in data.list1) e.key: e.value, + for (var e in data.list2) e.key: e.value, + for (var e in data.list3) e.key: e.value, }, ); if (!res['status']) {