This commit is contained in:
Christian Pauly 2020-05-09 11:54:10 +02:00
parent 6d294fe576
commit a46a3a3c1d
2 changed files with 69 additions and 80 deletions

View File

@ -58,75 +58,71 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
return Center(child: CircularProgressIndicator()); return Center(child: CircularProgressIndicator());
} }
final List<DeviceKeys> deviceKeys = snapshot.data; final List<DeviceKeys> deviceKeys = snapshot.data;
return Expanded( return ListView.separated(
child: ListView.separated( separatorBuilder: (BuildContext context, int i) =>
separatorBuilder: (BuildContext context, int i) => Divider(height: 1),
Divider(height: 1), itemCount: deviceKeys.length,
itemCount: deviceKeys.length, itemBuilder: (BuildContext context, int i) => Column(
itemBuilder: (BuildContext context, int i) => Column( mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min, children: <Widget>[
children: <Widget>[ if (i == 0 ||
if (i == 0 || deviceKeys[i].userId != deviceKeys[i - 1].userId)
deviceKeys[i].userId != deviceKeys[i - 1].userId) Material(
Material( child: ListTile(
child: ListTile( leading: Avatar(
leading: Avatar( room
room
.getUserByMXIDSync(deviceKeys[i].userId)
.avatarUrl,
room
.getUserByMXIDSync(deviceKeys[i].userId)
.calcDisplayname(),
),
title: Text(room
.getUserByMXIDSync(deviceKeys[i].userId) .getUserByMXIDSync(deviceKeys[i].userId)
.calcDisplayname()), .avatarUrl,
subtitle: Text(deviceKeys[i].userId), room
.getUserByMXIDSync(deviceKeys[i].userId)
.calcDisplayname(),
), ),
elevation: 2, title: Text(room
.getUserByMXIDSync(deviceKeys[i].userId)
.calcDisplayname()),
subtitle: Text(deviceKeys[i].userId),
), ),
CheckboxListTile( elevation: 2,
title: Text(
"${deviceKeys[i].unsigned["device_display_name"] ?? L10n.of(context).unknownDevice} - ${deviceKeys[i].deviceId}",
style: TextStyle(
color: deviceKeys[i].blocked
? Colors.red
: deviceKeys[i].verified
? Colors.green
: Colors.orange),
),
subtitle: Text(
deviceKeys[i]
.keys["ed25519:${deviceKeys[i].deviceId}"]
.beautified,
style: TextStyle(
color: Theme.of(context)
.textTheme
.bodyText2
.color),
),
value: deviceKeys[i].verified,
onChanged: (bool newVal) {
if (newVal == true) {
if (deviceKeys[i].blocked) {
deviceKeys[i].setBlocked(
false, Matrix.of(context).client);
}
deviceKeys[i]
.setVerified(true, Matrix.of(context).client);
} else {
if (deviceKeys[i].verified) {
deviceKeys[i].setVerified(
false, Matrix.of(context).client);
}
deviceKeys[i]
.setBlocked(true, Matrix.of(context).client);
}
setState(() => null);
},
), ),
], CheckboxListTile(
), title: Text(
"${deviceKeys[i].unsigned["device_display_name"] ?? L10n.of(context).unknownDevice} - ${deviceKeys[i].deviceId}",
style: TextStyle(
color: deviceKeys[i].blocked
? Colors.red
: deviceKeys[i].verified
? Colors.green
: Colors.orange),
),
subtitle: Text(
deviceKeys[i]
.keys["ed25519:${deviceKeys[i].deviceId}"]
.beautified,
style: TextStyle(
color:
Theme.of(context).textTheme.bodyText2.color),
),
value: deviceKeys[i].verified,
onChanged: (bool newVal) {
if (newVal == true) {
if (deviceKeys[i].blocked) {
deviceKeys[i]
.setBlocked(false, Matrix.of(context).client);
}
deviceKeys[i]
.setVerified(true, Matrix.of(context).client);
} else {
if (deviceKeys[i].verified) {
deviceKeys[i].setVerified(
false, Matrix.of(context).client);
}
deviceKeys[i]
.setBlocked(true, Matrix.of(context).client);
}
setState(() => null);
},
),
],
), ),
); );
}, },

View File

@ -64,13 +64,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.3" version: "1.1.3"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
@ -120,13 +113,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.3" version: "1.3.3"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
famedlysdk: famedlysdk:
dependency: "direct main" dependency: "direct main"
description: description:
@ -446,7 +432,7 @@ packages:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.6.4"
path_drawing: path_drawing:
dependency: transitive dependency: transitive
description: description:
@ -524,6 +510,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.4.2" version: "1.4.2"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
receive_sharing_intent: receive_sharing_intent:
dependency: "direct main" dependency: "direct main"
description: description: