mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
style: Nicer chips in encryption settings and icons showing device status
This commit is contained in:
parent
92fa8e1ca5
commit
4c91ea6002
@ -79,72 +79,103 @@ class ChatEncryptionSettingsView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
StreamBuilder(
|
StreamBuilder(
|
||||||
stream: room.onUpdate.stream,
|
stream: room.onUpdate.stream,
|
||||||
builder: (context, snapshot) =>
|
builder: (context, snapshot) => FutureBuilder<
|
||||||
FutureBuilder<List<DeviceKeys>>(
|
List<DeviceKeys>>(
|
||||||
future: room.getUserDeviceKeys(),
|
future: room.getUserDeviceKeys(),
|
||||||
builder: (BuildContext context, snapshot) {
|
builder: (BuildContext context, snapshot) {
|
||||||
if (snapshot.hasError) {
|
if (snapshot.hasError) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${L10n.of(context)!.oopsSomethingWentWrong}: ${snapshot.error}'),
|
'${L10n.of(context)!.oopsSomethingWentWrong}: ${snapshot.error}'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
return const Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator.adaptive(
|
child: CircularProgressIndicator.adaptive(
|
||||||
strokeWidth: 2));
|
strokeWidth: 2));
|
||||||
}
|
}
|
||||||
final deviceKeys = snapshot.data!;
|
final deviceKeys = snapshot.data!;
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
itemCount: deviceKeys.length,
|
itemCount: deviceKeys.length,
|
||||||
itemBuilder: (BuildContext context, int i) =>
|
itemBuilder: (BuildContext context, int i) =>
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
value: !deviceKeys[i].blocked,
|
value: !deviceKeys[i].blocked,
|
||||||
activeColor: deviceKeys[i].verified
|
activeColor: deviceKeys[i].verified
|
||||||
? Colors.green
|
? Colors.green
|
||||||
: Colors.orange,
|
: Colors.orange,
|
||||||
onChanged: (_) => controller
|
onChanged: (_) =>
|
||||||
.toggleDeviceKey(deviceKeys[i]),
|
controller.toggleDeviceKey(deviceKeys[i]),
|
||||||
title: Row(
|
title: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Icon(
|
||||||
child: Text(
|
deviceKeys[i].verified
|
||||||
deviceKeys[i].deviceId ??
|
? Icons.verified_outlined
|
||||||
L10n.of(context)!.unknownDevice,
|
: 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,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
color: Theme.of(context)
|
||||||
Padding(
|
.colorScheme
|
||||||
padding: const EdgeInsets.symmetric(
|
.primaryContainer,
|
||||||
vertical: 4.0),
|
child: Padding(
|
||||||
child: Chip(
|
padding: const EdgeInsets.all(4.0),
|
||||||
label: Text(
|
child: Text(
|
||||||
deviceKeys[i].userId,
|
deviceKeys[i].userId,
|
||||||
style: const TextStyle(
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.primary,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontStyle: FontStyle.italic,
|
fontStyle: FontStyle.italic,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
deviceKeys[i]
|
|
||||||
.ed25519Key
|
|
||||||
?.replaceAllMapped(
|
|
||||||
RegExp(r'.{4}'),
|
|
||||||
(s) => '${s.group(0)} ') ??
|
|
||||||
L10n.of(context)!
|
|
||||||
.unknownEncryptionAlgorithm,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontFamily: 'monospace',
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
deviceKeys[i].ed25519Key?.replaceAllMapped(
|
||||||
|
RegExp(r'.{4}'),
|
||||||
|
(s) => '${s.group(0)} ') ??
|
||||||
|
L10n.of(context)!
|
||||||
|
.unknownEncryptionAlgorithm,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontFamily: 'monospace',
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}),
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
] else
|
] else
|
||||||
Padding(
|
Padding(
|
||||||
|
@ -2277,5 +2277,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.1"
|
version: "3.1.1"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.19.0 <4.0.0"
|
dart: ">=2.19.0 <3.0.0"
|
||||||
flutter: ">=3.4.0-17.0.pre"
|
flutter: ">=3.4.0-17.0.pre"
|
||||||
|
Loading…
Reference in New Issue
Block a user