mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
feat: nicer loading bar
This commit is contained in:
parent
8b537db443
commit
b8b68ec6ef
@ -182,7 +182,6 @@ class ChatListView extends StatelessWidget {
|
||||
.displayname),
|
||||
),
|
||||
body: Column(children: [
|
||||
const ConnectionStatusHeader(),
|
||||
AnimatedContainer(
|
||||
height: controller.showChatBackupBanner ? 54 : 0,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
@ -219,10 +218,15 @@ class ChatListView extends StatelessWidget {
|
||||
child: const Icon(CupertinoIcons.chat_bubble),
|
||||
)
|
||||
: null,
|
||||
bottomNavigationBar: controller.spaces.isEmpty ||
|
||||
controller.selectedRoomIds.isNotEmpty
|
||||
? null
|
||||
: SpacesBottomBar(controller),
|
||||
bottomNavigationBar: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const ConnectionStatusHeader(),
|
||||
if (controller.spaces.isNotEmpty &&
|
||||
controller.selectedRoomIds.isEmpty)
|
||||
SpacesBottomBar(controller),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
@ -19,19 +19,14 @@ class ConnectionStatusHeader extends StatefulWidget {
|
||||
|
||||
class _ConnectionStatusHeaderState extends State<ConnectionStatusHeader> {
|
||||
StreamSubscription? _onSyncSub;
|
||||
StreamSubscription? _onSyncErrorSub;
|
||||
bool get _connected =>
|
||||
DateTime.now().millisecondsSinceEpoch -
|
||||
_lastSyncReceived.millisecondsSinceEpoch <
|
||||
(Matrix.of(context).client.sendMessageTimeoutSeconds + 2) * 1000;
|
||||
static DateTime _lastSyncReceived = DateTime(0);
|
||||
static bool _anySyncReceived = false;
|
||||
|
||||
SyncStatusUpdate _status =
|
||||
const SyncStatusUpdate(SyncStatus.waitingForResponse);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_onSyncSub?.cancel();
|
||||
_onSyncErrorSub?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@ -40,22 +35,24 @@ class _ConnectionStatusHeaderState extends State<ConnectionStatusHeader> {
|
||||
_onSyncSub ??= Matrix.of(context).client.onSyncStatus.stream.listen(
|
||||
(status) => setState(
|
||||
() {
|
||||
if ((status.status == SyncStatus.processing &&
|
||||
Matrix.of(context).client.prevBatch != null) ||
|
||||
status.status == SyncStatus.finished) {
|
||||
_lastSyncReceived = DateTime.now();
|
||||
}
|
||||
_status = status;
|
||||
if (status.status == SyncStatus.finished) {
|
||||
_anySyncReceived = true;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
final hide = _anySyncReceived &&
|
||||
_status.status != SyncStatus.error &&
|
||||
Matrix.of(context).client.prevBatch != null;
|
||||
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.bounceInOut,
|
||||
height: _connected ? 0 : 36,
|
||||
height: hide ? 0 : 36,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(color: Theme.of(context).colorScheme.surface),
|
||||
decoration: BoxDecoration(color: Theme.of(context).secondaryHeaderColor),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@ -65,7 +62,7 @@ class _ConnectionStatusHeaderState extends State<ConnectionStatusHeader> {
|
||||
height: 24,
|
||||
child: CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2,
|
||||
value: _connected ? 1.0 : _status.progress,
|
||||
value: hide ? 1.0 : _status.progress,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
|
Loading…
Reference in New Issue
Block a user