-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1690 from matthiasn/feat/incoming_verification_re…
…quest feat: incoming verification request
- Loading branch information
Showing
10 changed files
with
518 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
import 'package:matrix/encryption/utils/key_verification.dart'; | ||
import 'package:matrix/matrix.dart'; | ||
|
||
class KeyVerificationRunner { | ||
KeyVerificationRunner( | ||
this.keyVerification, { | ||
required this.controller, | ||
}) { | ||
lastStep = keyVerification.lastStep ?? ''; | ||
startedVerification = keyVerification.startedVerification; | ||
lastStepHistory.add(lastStep); | ||
publishState(); | ||
|
||
_timer = Timer.periodic( | ||
const Duration(milliseconds: 100), | ||
(timer) { | ||
final newLastStep = keyVerification.lastStep; | ||
// debugPrint('KeyVerificationRunner newLastStep: $newLastStep '); | ||
if (newLastStep != null && newLastStep != lastStep) { | ||
lastStep = newLastStep; | ||
lastStepHistory.add(newLastStep); | ||
debugPrint('KeyVerificationRunner newLastStep: $newLastStep '); | ||
publishState(); | ||
|
||
if (lastStep == 'm.key.verification.key') { | ||
//acceptEmojiVerification(); | ||
readEmojis(); | ||
} | ||
|
||
if (lastStep == EventTypes.KeyVerificationDone) { | ||
stopTimer(); | ||
} | ||
|
||
if (lastStep == 'm.key.verification.mac') { | ||
//keyVerification.acceptVerification(); | ||
} | ||
|
||
if (lastStep == 'm.key.verification.cancel') { | ||
stopTimer(); | ||
} | ||
} | ||
}, | ||
); | ||
} | ||
|
||
String lastStep = ''; | ||
bool? startedVerification; | ||
List<String> lastStepHistory = []; | ||
List<KeyVerificationEmoji>? emojis; | ||
KeyVerification keyVerification; | ||
StreamController<KeyVerificationRunner> controller; | ||
Timer? _timer; | ||
|
||
void stopTimer() { | ||
_timer?.cancel(); | ||
} | ||
|
||
Future<void> acceptVerification() async { | ||
await keyVerification.acceptVerification(); | ||
} | ||
|
||
Future<List<KeyVerificationEmoji>?> acceptEmojiVerification() async { | ||
await keyVerification.acceptSas(); | ||
emojis = keyVerification.sasEmojis; | ||
publishState(); | ||
return emojis; | ||
} | ||
|
||
Future<List<KeyVerificationEmoji>?> readEmojis() async { | ||
emojis = keyVerification.sasEmojis; | ||
publishState(); | ||
return emojis; | ||
} | ||
|
||
void publishState() { | ||
controller.add(this); | ||
} | ||
|
||
Future<void> cancelVerification() async { | ||
await keyVerification.cancel(); | ||
stopTimer(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class RoundedFilledButton extends StatelessWidget { | ||
const RoundedFilledButton({ | ||
required this.onPressed, | ||
required this.labelText, | ||
this.backgroundColor = Colors.greenAccent, | ||
this.foregroundColor = Colors.black87, | ||
this.semanticsLabel, | ||
super.key, | ||
}); | ||
|
||
final Color backgroundColor; | ||
final Color foregroundColor; | ||
final VoidCallback? onPressed; | ||
final String labelText; | ||
final String? semanticsLabel; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return FilledButton( | ||
onPressed: onPressed, | ||
style: FilledButton.styleFrom( | ||
backgroundColor: backgroundColor, | ||
foregroundColor: foregroundColor, | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(8), | ||
), | ||
), | ||
child: Text( | ||
labelText, | ||
semanticsLabel: semanticsLabel, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.