style: Nicer chips in encryption settings and icons showing device status

This commit is contained in:
Krille 2023-02-04 16:56:42 +01:00
parent 92fa8e1ca5
commit 4c91ea6002
2 changed files with 87 additions and 56 deletions

View File

@ -79,8 +79,8 @@ class ChatEncryptionSettingsView extends StatelessWidget {
),
StreamBuilder(
stream: room.onUpdate.stream,
builder: (context, snapshot) =>
FutureBuilder<List<DeviceKeys>>(
builder: (context, snapshot) => FutureBuilder<
List<DeviceKeys>>(
future: room.getUserDeviceKeys(),
builder: (BuildContext context, snapshot) {
if (snapshot.hasError) {
@ -105,35 +105,66 @@ class ChatEncryptionSettingsView extends StatelessWidget {
activeColor: deviceKeys[i].verified
? Colors.green
: Colors.orange,
onChanged: (_) => controller
.toggleDeviceKey(deviceKeys[i]),
onChanged: (_) =>
controller.toggleDeviceKey(deviceKeys[i]),
title: Row(
children: [
Expanded(
child: Text(
Icon(
deviceKeys[i].verified
? Icons.verified_outlined
: deviceKeys[i].blocked
? Icons.block_outlined
: Icons.info_outlined,
color: deviceKeys[i].verified
? Colors.green
: deviceKeys[i].blocked
? Colors.red
: Colors.orange,
size: 20,
),
Text(
deviceKeys[i].deviceId ??
L10n.of(context)!.unknownDevice,
),
const SizedBox(width: 4),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Material(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
AppConfig.borderRadius),
side: BorderSide(
color: Theme.of(context)
.colorScheme
.primary,
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0),
child: Chip(
label: Text(
),
color: Theme.of(context)
.colorScheme
.primaryContainer,
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
deviceKeys[i].userId,
style: const TextStyle(
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Theme.of(context)
.colorScheme
.primary,
fontSize: 12,
fontStyle: FontStyle.italic,
),
),
),
),
),
),
],
),
subtitle: Text(
deviceKeys[i]
.ed25519Key
?.replaceAllMapped(
deviceKeys[i].ed25519Key?.replaceAllMapped(
RegExp(r'.{4}'),
(s) => '${s.group(0)} ') ??
L10n.of(context)!

View File

@ -2277,5 +2277,5 @@ packages:
source: hosted
version: "3.1.1"
sdks:
dart: ">=2.19.0 <4.0.0"
dart: ">=2.19.0 <3.0.0"
flutter: ">=3.4.0-17.0.pre"