Now can load more messages via click the tile

This commit is contained in:
2024-06-23 19:02:41 +08:00
parent aa8eec1a5a
commit d0cd75d653
3 changed files with 52 additions and 20 deletions

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:get/get.dart';
import 'package:solian/controllers/chat_history_controller.dart';
import 'package:solian/exts.dart';
@ -330,23 +331,41 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
Obx(() {
final amount = _chatController.totalHistoryCount -
_chatController.currentHistory.length;
if (amount > 0) {
return SliverToBoxAdapter(
child: ListTile(
tileColor: Theme.of(context)
.colorScheme
.surfaceContainerLow,
leading: const Icon(Icons.sync_disabled),
title: Text('messageUnsync'.tr),
subtitle: Text('messageUnsyncCaption'.trParams({
'count': amount.string,
})),
onTap: () {},
),
);
} else {
if (amount.value <= 0 ||
_chatController.isLoading.isTrue) {
return const SliverToBoxAdapter(child: SizedBox());
}
return SliverToBoxAdapter(
child: ListTile(
tileColor:
Theme.of(context).colorScheme.surfaceContainerLow,
leading: const Icon(Icons.sync_disabled),
title: Text('messageUnsync'.tr),
subtitle: Text('messageUnsyncCaption'.trParams({
'count': amount.string,
})),
onTap: () {
_chatController.getMoreMessages(
_channel!,
widget.realm,
);
},
),
);
}),
Obx(() {
if (_chatController.isLoading.isFalse) {
return const SliverToBoxAdapter(child: SizedBox());
}
return SliverToBoxAdapter(
child: const LinearProgressIndicator()
.animate()
.slideY()
.paddingOnly(bottom: 4),
);
}),
],
),