feat: Display progress value for initial sync

This commit is contained in:
Krille 2023-06-03 17:28:32 +02:00
parent ec9155d8f0
commit 299aac134d
No known key found for this signature in database

View File

@ -32,6 +32,11 @@ class ChatListViewBody extends StatelessWidget {
final roomSearchResult = controller.roomSearchResult; final roomSearchResult = controller.roomSearchResult;
final userSearchResult = controller.userSearchResult; final userSearchResult = controller.userSearchResult;
final client = Matrix.of(context).client; final client = Matrix.of(context).client;
const dummyChatCount = 4;
final titleColor =
Theme.of(context).textTheme.bodyLarge!.color!.withAlpha(100);
final subtitleColor =
Theme.of(context).textTheme.bodyLarge!.color!.withAlpha(50);
return PageTransitionSwitcher( return PageTransitionSwitcher(
transitionBuilder: ( transitionBuilder: (
@ -65,7 +70,6 @@ class ChatListViewBody extends StatelessWidget {
key: Key(controller.activeSpaceId ?? 'Spaces'), key: Key(controller.activeSpaceId ?? 'Spaces'),
); );
} }
if (controller.waitForFirstSync && client.prevBatch != null) {
final rooms = controller.filteredRooms; final rooms = controller.filteredRooms;
final displayStoriesHeader = { final displayStoriesHeader = {
ActiveFilter.allChats, ActiveFilter.allChats,
@ -101,11 +105,10 @@ class ChatListViewBody extends StatelessWidget {
itemCount: roomSearchResult.chunk.length, itemCount: roomSearchResult.chunk.length,
itemBuilder: (context, i) => _SearchItem( itemBuilder: (context, i) => _SearchItem(
title: roomSearchResult.chunk[i].name ?? title: roomSearchResult.chunk[i].name ??
roomSearchResult.chunk[i] roomSearchResult.chunk[i].canonicalAlias
.canonicalAlias?.localpart ?? ?.localpart ??
L10n.of(context)!.group, L10n.of(context)!.group,
avatar: avatar: roomSearchResult.chunk[i].avatarUrl,
roomSearchResult.chunk[i].avatarUrl,
onPressed: () => showAdaptiveBottomSheet( onPressed: () => showAdaptiveBottomSheet(
context: context, context: context,
builder: (c) => PublicRoomBottomSheet( builder: (c) => PublicRoomBottomSheet(
@ -148,8 +151,8 @@ class ChatListViewBody extends StatelessWidget {
onPressed: () => showAdaptiveBottomSheet( onPressed: () => showAdaptiveBottomSheet(
context: context, context: context,
builder: (c) => ProfileBottomSheet( builder: (c) => ProfileBottomSheet(
userId: userSearchResult userId:
.results[i].userId, userSearchResult.results[i].userId,
outerContext: context, outerContext: context,
), ),
), ),
@ -178,10 +181,8 @@ class ChatListViewBody extends StatelessWidget {
child: ListTile( child: ListTile(
leading: const Icon(Icons.vpn_key), leading: const Icon(Icons.vpn_key),
title: Text(L10n.of(context)!.dehydrateTor), title: Text(L10n.of(context)!.dehydrateTor),
subtitle: subtitle: Text(L10n.of(context)!.dehydrateTorLong),
Text(L10n.of(context)!.dehydrateTorLong), trailing: const Icon(Icons.chevron_right_outlined),
trailing:
const Icon(Icons.chevron_right_outlined),
onTap: controller.dehydrate, onTap: controller.dehydrate,
), ),
), ),
@ -191,7 +192,9 @@ class ChatListViewBody extends StatelessWidget {
title: L10n.of(context)!.chats, title: L10n.of(context)!.chats,
icon: const Icon(Icons.forum_outlined), icon: const Icon(Icons.forum_outlined),
), ),
if (rooms.isEmpty && !controller.isSearchMode) ...[ if (client.prevBatch != null &&
rooms.isEmpty &&
!controller.isSearchMode) ...[
Padding( Padding(
padding: const EdgeInsets.all(32.0), padding: const EdgeInsets.all(32.0),
child: Column( child: Column(
@ -216,55 +219,18 @@ class ChatListViewBody extends StatelessWidget {
], ],
), ),
), ),
if (client.prevBatch == null)
SliverList( SliverList(
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
(BuildContext context, int i) { (context, i) => Opacity(
if (!rooms[i]
.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
)
.toLowerCase()
.contains(
controller.searchController.text.toLowerCase(),
)) {
return const SizedBox.shrink();
}
return ChatListItem(
rooms[i],
key: Key('chat_list_item_${rooms[i].id}'),
selected:
controller.selectedRoomIds.contains(rooms[i].id),
onTap: controller.selectMode == SelectMode.select
? () => controller.toggleSelection(rooms[i].id)
: null,
onLongPress: () =>
controller.toggleSelection(rooms[i].id),
activeChat: controller.activeChat == rooms[i].id,
);
},
childCount: rooms.length,
),
),
],
),
);
}
const dummyChatCount = 5;
final titleColor =
Theme.of(context).textTheme.bodyLarge!.color!.withAlpha(100);
final subtitleColor =
Theme.of(context).textTheme.bodyLarge!.color!.withAlpha(50);
return ListView.builder(
key: const Key('dummychats'),
itemCount: dummyChatCount,
itemBuilder: (context, i) => Opacity(
opacity: (dummyChatCount - i) / dummyChatCount, opacity: (dummyChatCount - i) / dummyChatCount,
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: titleColor, backgroundColor: titleColor,
child: CircularProgressIndicator( child: CircularProgressIndicator(
strokeWidth: 1, strokeWidth: 1,
color: Theme.of(context).textTheme.bodyLarge!.color, color:
Theme.of(context).textTheme.bodyLarge!.color,
), ),
), ),
title: Row( title: Row(
@ -308,6 +274,41 @@ class ChatListViewBody extends StatelessWidget {
), ),
), ),
), ),
childCount: dummyChatCount,
),
),
if (client.prevBatch != null)
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int i) {
if (!rooms[i]
.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
)
.toLowerCase()
.contains(
controller.searchController.text.toLowerCase(),
)) {
return const SizedBox.shrink();
}
return ChatListItem(
rooms[i],
key: Key('chat_list_item_${rooms[i].id}'),
selected:
controller.selectedRoomIds.contains(rooms[i].id),
onTap: controller.selectMode == SelectMode.select
? () => controller.toggleSelection(rooms[i].id)
: null,
onLongPress: () =>
controller.toggleSelection(rooms[i].id),
activeChat: controller.activeChat == rooms[i].id,
);
},
childCount: rooms.length,
),
),
],
),
); );
}, },
), ),