|
|
@ -28,158 +28,162 @@ class ChatEncryptionSettingsView extends StatelessWidget {
|
|
|
|
VRouter.of(context).toSegments(['rooms', controller.roomId]),
|
|
|
|
VRouter.of(context).toSegments(['rooms', controller.roomId]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
title: Text(L10n.of(context).tapOnDeviceToVerify),
|
|
|
|
title: Text(L10n.of(context).tapOnDeviceToVerify),
|
|
|
|
bottom: PreferredSize(
|
|
|
|
elevation: 0,
|
|
|
|
preferredSize: const Size.fromHeight(56),
|
|
|
|
|
|
|
|
child: ListTile(
|
|
|
|
|
|
|
|
title: Text(L10n.of(context).deviceVerifyDescription),
|
|
|
|
|
|
|
|
leading: CircleAvatar(
|
|
|
|
|
|
|
|
backgroundColor: Theme.of(context).secondaryHeaderColor,
|
|
|
|
|
|
|
|
foregroundColor: Theme.of(context).colorScheme.secondary,
|
|
|
|
|
|
|
|
child: const Icon(Icons.lock),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: MaxWidthBody(
|
|
|
|
body: MaxWidthBody(
|
|
|
|
withScrolling: true,
|
|
|
|
withScrolling: true,
|
|
|
|
child: StreamBuilder(
|
|
|
|
child: Column(
|
|
|
|
stream: room.onUpdate.stream,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
children: [
|
|
|
|
return FutureBuilder<List<DeviceKeys>>(
|
|
|
|
ListTile(
|
|
|
|
future: room.getUserDeviceKeys(),
|
|
|
|
title: Text(L10n.of(context).deviceVerifyDescription),
|
|
|
|
builder: (BuildContext context, snapshot) {
|
|
|
|
leading: CircleAvatar(
|
|
|
|
if (snapshot.hasError) {
|
|
|
|
backgroundColor: Theme.of(context).secondaryHeaderColor,
|
|
|
|
return Center(
|
|
|
|
foregroundColor: Theme.of(context).colorScheme.secondary,
|
|
|
|
child: Text(L10n.of(context).oopsSomethingWentWrong +
|
|
|
|
child: const Icon(Icons.lock),
|
|
|
|
': ' +
|
|
|
|
),
|
|
|
|
snapshot.error.toString()),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
const Divider(height: 1),
|
|
|
|
}
|
|
|
|
StreamBuilder(
|
|
|
|
if (!snapshot.hasData) {
|
|
|
|
stream: room.onUpdate.stream,
|
|
|
|
return const Center(
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
child:
|
|
|
|
return FutureBuilder<List<DeviceKeys>>(
|
|
|
|
CircularProgressIndicator.adaptive(strokeWidth: 2));
|
|
|
|
future: room.getUserDeviceKeys(),
|
|
|
|
}
|
|
|
|
builder: (BuildContext context, snapshot) {
|
|
|
|
final deviceKeys = snapshot.data;
|
|
|
|
if (snapshot.hasError) {
|
|
|
|
return ListView.builder(
|
|
|
|
return Center(
|
|
|
|
shrinkWrap: true,
|
|
|
|
child: Text(L10n.of(context).oopsSomethingWentWrong +
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
': ' +
|
|
|
|
itemCount: deviceKeys.length,
|
|
|
|
snapshot.error.toString()),
|
|
|
|
itemBuilder: (BuildContext context, int i) => Column(
|
|
|
|
);
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
}
|
|
|
|
children: <Widget>[
|
|
|
|
if (!snapshot.hasData) {
|
|
|
|
if (i == 0 ||
|
|
|
|
return const Center(
|
|
|
|
deviceKeys[i].userId !=
|
|
|
|
child: CircularProgressIndicator.adaptive(
|
|
|
|
deviceKeys[i - 1].userId) ...{
|
|
|
|
strokeWidth: 2));
|
|
|
|
const Divider(height: 1, thickness: 1),
|
|
|
|
}
|
|
|
|
PopupMenuButton(
|
|
|
|
final deviceKeys = snapshot.data;
|
|
|
|
onSelected: (action) => controller.onSelected(
|
|
|
|
return ListView.builder(
|
|
|
|
context, action, deviceKeys[i]),
|
|
|
|
shrinkWrap: true,
|
|
|
|
itemBuilder: (c) {
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
final items = <PopupMenuEntry<String>>[];
|
|
|
|
itemCount: deviceKeys.length,
|
|
|
|
if (room
|
|
|
|
itemBuilder: (BuildContext context, int i) => Column(
|
|
|
|
.client
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
.userDeviceKeys[deviceKeys[i].userId]
|
|
|
|
children: <Widget>[
|
|
|
|
.verified ==
|
|
|
|
if (i == 0 ||
|
|
|
|
UserVerifiedStatus.unknown) {
|
|
|
|
deviceKeys[i].userId !=
|
|
|
|
items.add(PopupMenuItem(
|
|
|
|
deviceKeys[i - 1].userId) ...{
|
|
|
|
value: 'verify_user',
|
|
|
|
const Divider(height: 1, thickness: 1),
|
|
|
|
child: Text(L10n.of(context).verifyUser),
|
|
|
|
PopupMenuButton(
|
|
|
|
));
|
|
|
|
onSelected: (action) => controller.onSelected(
|
|
|
|
}
|
|
|
|
context, action, deviceKeys[i]),
|
|
|
|
return items;
|
|
|
|
itemBuilder: (c) {
|
|
|
|
},
|
|
|
|
final items = <PopupMenuEntry<String>>[];
|
|
|
|
child: ListTile(
|
|
|
|
if (room
|
|
|
|
leading: Avatar(
|
|
|
|
.client
|
|
|
|
mxContent: room
|
|
|
|
.userDeviceKeys[deviceKeys[i].userId]
|
|
|
|
.getUserByMXIDSync(deviceKeys[i].userId)
|
|
|
|
.verified ==
|
|
|
|
.avatarUrl,
|
|
|
|
UserVerifiedStatus.unknown) {
|
|
|
|
name: room
|
|
|
|
items.add(PopupMenuItem(
|
|
|
|
.getUserByMXIDSync(deviceKeys[i].userId)
|
|
|
|
value: 'verify_user',
|
|
|
|
.calcDisplayname(),
|
|
|
|
child: Text(L10n.of(context).verifyUser),
|
|
|
|
),
|
|
|
|
));
|
|
|
|
title: Text(
|
|
|
|
}
|
|
|
|
room
|
|
|
|
return items;
|
|
|
|
.getUserByMXIDSync(deviceKeys[i].userId)
|
|
|
|
},
|
|
|
|
.calcDisplayname(),
|
|
|
|
child: ListTile(
|
|
|
|
),
|
|
|
|
leading: Avatar(
|
|
|
|
subtitle: Text(
|
|
|
|
mxContent: room
|
|
|
|
deviceKeys[i].userId,
|
|
|
|
.getUserByMXIDSync(deviceKeys[i].userId)
|
|
|
|
style: const TextStyle(
|
|
|
|
.avatarUrl,
|
|
|
|
fontWeight: FontWeight.w300),
|
|
|
|
name: room
|
|
|
|
|
|
|
|
.getUserByMXIDSync(deviceKeys[i].userId)
|
|
|
|
|
|
|
|
.calcDisplayname(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
title: Text(
|
|
|
|
|
|
|
|
room
|
|
|
|
|
|
|
|
.getUserByMXIDSync(deviceKeys[i].userId)
|
|
|
|
|
|
|
|
.calcDisplayname(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
|
|
|
deviceKeys[i].userId,
|
|
|
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
|
|
|
fontWeight: FontWeight.w300),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
PopupMenuButton(
|
|
|
|
},
|
|
|
|
onSelected: (action) => controller.onSelected(
|
|
|
|
PopupMenuButton(
|
|
|
|
context, action, deviceKeys[i]),
|
|
|
|
onSelected: (action) => controller.onSelected(
|
|
|
|
itemBuilder: (c) {
|
|
|
|
context, action, deviceKeys[i]),
|
|
|
|
final items = <PopupMenuEntry<String>>[];
|
|
|
|
itemBuilder: (c) {
|
|
|
|
if (deviceKeys[i].blocked ||
|
|
|
|
final items = <PopupMenuEntry<String>>[];
|
|
|
|
!deviceKeys[i].verified) {
|
|
|
|
if (deviceKeys[i].blocked ||
|
|
|
|
items.add(PopupMenuItem(
|
|
|
|
!deviceKeys[i].verified) {
|
|
|
|
value: deviceKeys[i].userId ==
|
|
|
|
items.add(PopupMenuItem(
|
|
|
|
room.client.userID
|
|
|
|
value:
|
|
|
|
|
|
|
|
deviceKeys[i].userId == room.client.userID
|
|
|
|
|
|
|
|
? 'verify'
|
|
|
|
? 'verify'
|
|
|
|
: 'verify_user',
|
|
|
|
: 'verify_user',
|
|
|
|
child: Text(L10n.of(context).verifyStart),
|
|
|
|
child: Text(L10n.of(context).verifyStart),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (deviceKeys[i].blocked) {
|
|
|
|
if (deviceKeys[i].blocked) {
|
|
|
|
items.add(PopupMenuItem(
|
|
|
|
items.add(PopupMenuItem(
|
|
|
|
value: 'unblock',
|
|
|
|
value: 'unblock',
|
|
|
|
child: Text(L10n.of(context).unblockDevice),
|
|
|
|
child: Text(L10n.of(context).unblockDevice),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!deviceKeys[i].blocked) {
|
|
|
|
if (!deviceKeys[i].blocked) {
|
|
|
|
items.add(PopupMenuItem(
|
|
|
|
items.add(PopupMenuItem(
|
|
|
|
value: 'block',
|
|
|
|
value: 'block',
|
|
|
|
child: Text(L10n.of(context).blockDevice),
|
|
|
|
child: Text(L10n.of(context).blockDevice),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return items;
|
|
|
|
return items;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: ListTile(
|
|
|
|
child: ListTile(
|
|
|
|
leading: CircleAvatar(
|
|
|
|
leading: CircleAvatar(
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
backgroundColor: deviceKeys[i].color,
|
|
|
|
backgroundColor: deviceKeys[i].color,
|
|
|
|
child: Icon(deviceKeys[i].icon),
|
|
|
|
child: Icon(deviceKeys[i].icon),
|
|
|
|
),
|
|
|
|
|
|
|
|
title: Text(
|
|
|
|
|
|
|
|
deviceKeys[i].displayname,
|
|
|
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
subtitle: Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
deviceKeys[i].deviceId,
|
|
|
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
|
|
|
fontWeight: FontWeight.w300),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
title: Text(
|
|
|
|
Text(
|
|
|
|
deviceKeys[i].displayname,
|
|
|
|
deviceKeys[i].blocked
|
|
|
|
maxLines: 1,
|
|
|
|
? L10n.of(context).blocked
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
: deviceKeys[i].verified
|
|
|
|
),
|
|
|
|
? L10n.of(context).verified
|
|
|
|
subtitle: Row(
|
|
|
|
: L10n.of(context).unverified,
|
|
|
|
children: [
|
|
|
|
style: TextStyle(
|
|
|
|
Text(
|
|
|
|
fontSize: 14,
|
|
|
|
deviceKeys[i].deviceId,
|
|
|
|
color: deviceKeys[i].color,
|
|
|
|
style: const TextStyle(
|
|
|
|
),
|
|
|
|
fontWeight: FontWeight.w300),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const Spacer(),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
deviceKeys[i].blocked
|
|
|
|
|
|
|
|
? L10n.of(context).blocked
|
|
|
|
|
|
|
|
: deviceKeys[i].verified
|
|
|
|
|
|
|
|
? L10n.of(context).verified
|
|
|
|
|
|
|
|
: L10n.of(context).unverified,
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
|
|
|
color: deviceKeys[i].color,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|