change: Place backup hint banner in chat list

This commit is contained in:
Christian Pauly 2021-06-20 13:16:51 +02:00
commit 347d7f67fd
5 changed files with 95 additions and 48 deletions

View file

@ -194,23 +194,73 @@ class ChatListView extends StatelessWidget {
],
);
}
final totalCount = rooms.length;
final totalCount = rooms.length + 1;
return ListView.builder(
itemCount: totalCount,
itemBuilder: (BuildContext context, int i) =>
ChatListItem(
rooms[i],
selected: controller.selectedRoomIds
.contains(rooms[i].id),
onTap: selectMode == SelectMode.select
? () => controller
.toggleSelection(rooms[i].id)
: null,
onLongPress: () =>
controller.toggleSelection(rooms[i].id),
activeChat:
controller.activeChat == rooms[i].id,
),
itemBuilder: (BuildContext context, int i) {
if (i == 0) {
return FutureBuilder(
future: controller
.crossSigningCachedFuture,
builder: (context, snapshot) {
final needsBootstrap =
Matrix.of(context)
.client
.encryption
?.crossSigning
?.enabled ==
false ||
snapshot.data == false;
final isUnknownSession =
Matrix.of(context)
.client
.isUnknownSession;
final displayHeader =
needsBootstrap ||
isUnknownSession;
if (!displayHeader ||
controller
.hideChatBackupBanner) {
return Container();
}
return Material(
color: Colors.orange,
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.white,
foregroundColor: Colors.black,
child: Icon(Icons.cloud),
),
trailing: IconButton(
icon: Icon(Icons.close),
onPressed: controller
.hideChatBackupBannerAction,
),
title: Text(L10n.of(context)
.chatBackup),
subtitle: Text(L10n.of(context)
.enableChatBackup),
onTap: controller
.firstRunBootstrapAction,
),
);
});
}
i--;
return ChatListItem(
rooms[i],
selected: controller.selectedRoomIds
.contains(rooms[i].id),
onTap: selectMode == SelectMode.select
? () => controller
.toggleSelection(rooms[i].id)
: null,
onLongPress: () => controller
.toggleSelection(rooms[i].id),
activeChat:
controller.activeChat == rooms[i].id,
);
},
);
} else {
return Center(

View file

@ -36,31 +36,6 @@ class SettingsView extends StatelessWidget {
floating: true,
pinned: true,
title: Text(L10n.of(context).settings),
actions: [
FutureBuilder(
future: controller.crossSigningCachedFuture,
builder: (context, snapshot) {
final needsBootstrap = Matrix.of(context)
.client
.encryption
?.crossSigning
?.enabled ==
false ||
snapshot.data == false;
final isUnknownSession =
Matrix.of(context).client.isUnknownSession;
final displayHeader = needsBootstrap || isUnknownSession;
if (!displayHeader) return Container();
return TextButton.icon(
icon: Icon(Icons.cloud, color: Colors.red),
label: Text(
L10n.of(context).chatBackup,
style: TextStyle(color: Colors.red),
),
onPressed: controller.firstRunBootstrapAction,
);
}),
],
backgroundColor: Theme.of(context).appBarTheme.color,
flexibleSpace: FlexibleSpaceBar(
background: ContentBanner(