opt remove sc

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-09-03 20:00:43 +08:00
parent 04830c7789
commit 28a58ade84
5 changed files with 24 additions and 14 deletions

View File

@@ -269,6 +269,10 @@ class _CustomGridViewDelegate extends MultiChildLayoutDelegate {
@override @override
bool shouldRelayout(_CustomGridViewDelegate oldDelegate) { bool shouldRelayout(_CustomGridViewDelegate oldDelegate) {
return space != oldDelegate.space || itemCount != oldDelegate.itemCount; return space != oldDelegate.space ||
itemCount != oldDelegate.itemCount ||
column != oldDelegate.column ||
width != oldDelegate.width ||
height != oldDelegate.height;
} }
} }

View File

@@ -23,13 +23,13 @@ class SuperChatCard extends StatefulWidget {
class _SuperChatCardState extends State<SuperChatCard> { class _SuperChatCardState extends State<SuperChatCard> {
Timer? _timer; Timer? _timer;
RxInt _remains = 0.obs; RxInt? _remains;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
if (widget.item.expired) { if (widget.item.expired) {
_onRemove(); _remove();
return; return;
} }
final now = DateTime.now().millisecondsSinceEpoch ~/ 1000; final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
@@ -38,10 +38,16 @@ class _SuperChatCardState extends State<SuperChatCard> {
_remains = offset.obs; _remains = offset.obs;
_timer = Timer.periodic(const Duration(seconds: 1), _callback); _timer = Timer.periodic(const Duration(seconds: 1), _callback);
} else { } else {
_onRemove(); _remove();
} }
} }
void _remove() {
WidgetsBinding.instance.addPostFrameCallback(
(_) => Future.delayed(const Duration(seconds: 1), _onRemove),
);
}
void _onRemove() { void _onRemove() {
widget widget
..item.expired = true ..item.expired = true
@@ -49,9 +55,9 @@ class _SuperChatCardState extends State<SuperChatCard> {
} }
void _callback(_) { void _callback(_) {
final remains = _remains.value; final remains = _remains!.value;
if (remains > 0) { if (remains > 0) {
_remains.value = remains - 1; _remains!.value = remains - 1;
} else { } else {
_cancelTimer(); _cancelTimer();
_onRemove(); _onRemove();
@@ -120,12 +126,13 @@ class _SuperChatCardState extends State<SuperChatCard> {
], ],
), ),
), ),
Obx( if (_remains != null)
() => Text( Obx(
_remains.toString(), () => Text(
style: const TextStyle(fontSize: 14, color: Colors.grey), _remains.toString(),
style: const TextStyle(fontSize: 14, color: Colors.grey),
),
), ),
),
], ],
), ),
), ),

View File

@@ -254,7 +254,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
"id": Utils.generateRandomString(8), "id": Utils.generateRandomString(8),
"price": 66, "price": 66,
"end_time": "end_time":
DateTime.now().millisecondsSinceEpoch ~/ 1000 + 5, DateTime.now().millisecondsSinceEpoch ~/ 1000 - 5,
"message": Utils.generateRandomString(55), "message": Utils.generateRandomString(55),
"user_info": { "user_info": {
"face": "", "face": "",

View File

@@ -89,7 +89,7 @@ class LiveRoomChatPanel extends StatelessWidget {
"id": Utils.generateRandomString(8), "id": Utils.generateRandomString(8),
"price": 66, "price": 66,
"end_time": "end_time":
DateTime.now().millisecondsSinceEpoch ~/ 1000 + 5, DateTime.now().millisecondsSinceEpoch ~/ 1000 - 5,
"message": "message message message message message", "message": "message message message message message",
"user_info": { "user_info": {
"face": "", "face": "",

View File

@@ -69,7 +69,6 @@ class SSearchController extends GetxController
// suggestion // suggestion
final bool searchSuggestion = Pref.searchSuggestion; final bool searchSuggestion = Pref.searchSuggestion;
late final RxList<SearchSuggestItem> searchSuggestList; late final RxList<SearchSuggestItem> searchSuggestList;
// trending // trending