2021-08-07 16:35:38 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
|
2021-08-07 16:35:38 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
import 'package:matrix/matrix.dart';
|
2021-08-07 16:35:38 +02:00
|
|
|
|
2021-11-09 21:32:16 +01:00
|
|
|
import '../../../config/app_config.dart';
|
2021-08-07 16:35:38 +02:00
|
|
|
|
|
|
|
class VerificationRequestContent extends StatelessWidget {
|
|
|
|
final Event event;
|
|
|
|
final Timeline timeline;
|
|
|
|
|
2022-01-29 12:35:03 +01:00
|
|
|
const VerificationRequestContent(
|
|
|
|
{required this.event, required this.timeline, Key? key})
|
2021-10-14 18:09:30 +02:00
|
|
|
: super(key: key);
|
2021-08-07 16:35:38 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final events = event.aggregatedEvents(timeline, 'm.reference');
|
|
|
|
final done = events.where((e) => e.type == EventTypes.KeyVerificationDone);
|
|
|
|
final start =
|
|
|
|
events.where((e) => e.type == EventTypes.KeyVerificationStart);
|
|
|
|
final cancel =
|
|
|
|
events.where((e) => e.type == EventTypes.KeyVerificationCancel);
|
|
|
|
final fullyDone = done.length >= 2;
|
|
|
|
final started = start.isNotEmpty;
|
|
|
|
final canceled = cancel.isNotEmpty;
|
|
|
|
return Padding(
|
2021-10-14 18:09:30 +02:00
|
|
|
padding: const EdgeInsets.symmetric(
|
2021-08-07 16:35:38 +02:00
|
|
|
horizontal: 8.0,
|
|
|
|
vertical: 4.0,
|
|
|
|
),
|
|
|
|
child: Center(
|
|
|
|
child: Container(
|
2021-10-14 18:09:30 +02:00
|
|
|
padding: const EdgeInsets.all(8),
|
2021-08-07 16:35:38 +02:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
),
|
|
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
|
|
|
color: Theme.of(context).backgroundColor,
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(Icons.lock_outlined,
|
|
|
|
color: canceled
|
|
|
|
? Colors.red
|
|
|
|
: (fullyDone ? Colors.green : Colors.grey)),
|
2021-10-14 18:09:30 +02:00
|
|
|
const SizedBox(width: 8),
|
2021-08-07 16:35:38 +02:00
|
|
|
Text(canceled
|
|
|
|
? 'Error ${cancel.first.content.tryGet<String>('code')}: ${cancel.first.content.tryGet<String>('reason')}'
|
|
|
|
: (fullyDone
|
2022-01-29 12:35:03 +01:00
|
|
|
? L10n.of(context)!.verifySuccess
|
2021-08-07 16:35:38 +02:00
|
|
|
: (started
|
2022-01-29 12:35:03 +01:00
|
|
|
? L10n.of(context)!.loadingPleaseWait
|
|
|
|
: L10n.of(context)!.newVerificationRequest)))
|
2021-08-07 16:35:38 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|