From f9c365011b73fc2591bd9eeced74b84f038c017b Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Wed, 8 Jan 2025 22:04:54 +0800 Subject: [PATCH] Revert "opt: msg badge" This reverts commit 8ce50267783ffd19b56436f16cbb4324b797d0ca. --- lib/pages/home/view.dart | 58 +++++++++++++++++++++++++--------------- lib/pages/main/view.dart | 58 +++++++++++++++++++++++++--------------- 2 files changed, 72 insertions(+), 44 deletions(-) diff --git a/lib/pages/home/view.dart b/lib/pages/home/view.dart index 4f1d7c96..05eb38bd 100644 --- a/lib/pages/home/view.dart +++ b/lib/pages/home/view.dart @@ -90,29 +90,43 @@ class _HomePageState extends State const SizedBox(width: 4), Obx( () => _homeController.isLogin.value - ? Badge( - isLabelVisible: - _mainController.msgBadgeMode != DynamicBadgeMode.hidden && - _mainController.msgUnReadCount.value.isNotEmpty, - alignment: - _mainController.msgBadgeMode == DynamicBadgeMode.number - ? Alignment(0, -0.5) - : Alignment(0.5, -0.5), - label: _mainController.msgBadgeMode == - DynamicBadgeMode.number && - _mainController.msgUnReadCount.value.isNotEmpty - ? Text(_mainController.msgUnReadCount.value.toString()) - : null, - child: IconButton( - tooltip: '消息', - onPressed: () { - Get.toNamed('/whisper'); - _mainController.msgUnReadCount.value = ''; - }, - icon: const Icon( - Icons.notifications_none, + ? Stack( + clipBehavior: Clip.none, + alignment: Alignment.center, + children: [ + IconButton( + tooltip: '消息', + onPressed: () { + Get.toNamed('/whisper'); + _mainController.msgUnReadCount.value = ''; + }, + icon: const Icon( + Icons.notifications_none, + ), ), - ), + if (_mainController.msgBadgeMode != + DynamicBadgeMode.hidden && + _mainController.msgUnReadCount.value.isNotEmpty) + Positioned( + top: _mainController.msgBadgeMode == + DynamicBadgeMode.number + ? 8 + : 12, + left: _mainController.msgBadgeMode == + DynamicBadgeMode.number + ? 22 + : 32, + child: IgnorePointer( + child: Badge( + label: _mainController.msgBadgeMode == + DynamicBadgeMode.number + ? Text(_mainController.msgUnReadCount.value + .toString()) + : null, + ), + ), + ), + ], ) : const SizedBox.shrink(), ), diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index 484365ad..54e13b53 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -434,29 +434,43 @@ class _MainAppState extends State const SizedBox(height: 8), Obx( () => _homeController.isLogin.value - ? Badge( - isLabelVisible: - _mainController.msgBadgeMode != DynamicBadgeMode.hidden && - _mainController.msgUnReadCount.value.isNotEmpty, - alignment: - _mainController.msgBadgeMode == DynamicBadgeMode.number - ? Alignment(0, -0.5) - : Alignment(0.5, -0.5), - label: _mainController.msgBadgeMode == - DynamicBadgeMode.number && - _mainController.msgUnReadCount.value.isNotEmpty - ? Text(_mainController.msgUnReadCount.value.toString()) - : null, - child: IconButton( - tooltip: '消息', - onPressed: () { - Get.toNamed('/whisper'); - _mainController.msgUnReadCount.value = ''; - }, - icon: const Icon( - Icons.notifications_none, + ? Stack( + clipBehavior: Clip.none, + alignment: Alignment.center, + children: [ + IconButton( + tooltip: '消息', + onPressed: () { + Get.toNamed('/whisper'); + _mainController.msgUnReadCount.value = ''; + }, + icon: const Icon( + Icons.notifications_none, + ), ), - ), + if (_mainController.msgBadgeMode != + DynamicBadgeMode.hidden && + _mainController.msgUnReadCount.value.isNotEmpty) + Positioned( + top: _mainController.msgBadgeMode == + DynamicBadgeMode.number + ? 8 + : 12, + left: _mainController.msgBadgeMode == + DynamicBadgeMode.number + ? 22 + : 32, + child: IgnorePointer( + child: Badge( + label: _mainController.msgBadgeMode == + DynamicBadgeMode.number + ? Text(_mainController.msgUnReadCount.value + .toString()) + : null, + ), + ), + ), + ], ) : const SizedBox.shrink(), ),