Add ReCaptcha screen (#6135)

Support dark mode in MXKAuthenticationRecaptchaWebView.
Begin implementing the ReCaptcha coordinator.
This commit is contained in:
Doug
2022-05-11 09:57:37 +01:00
committed by GitHub
parent 46ee4e416a
commit f9fbc6f599
20 changed files with 626 additions and 7 deletions
@@ -16,10 +16,12 @@
*/
#import "MXKAuthenticationRecaptchaWebView.h"
#import "ThemeService.h"
NSString *kMXKRecaptchaHTMLString = @"<html> \
<head> \
<meta name='viewport' content='initial-scale=1.0' /> \
<style>@media (prefers-color-scheme: dark) { body { background-color: #15191E; } }</style> \
<script type=\"text/javascript\"> \
var verifyCallback = function(response) { \
/* Generic method to make a bridge between JS and the WKWebView*/ \
@@ -33,7 +35,8 @@ var verifyCallback = function(response) { \
var onloadCallback = function() { \
grecaptcha.render('recaptcha_widget', { \
'sitekey' : '%@', \
'callback': verifyCallback \
'callback': verifyCallback, \
'theme': '%@' \
}); \
}; \
</script> \
@@ -78,7 +81,9 @@ var onloadCallback = function() { \
[self addSubview:activityIndicator];
[activityIndicator startAnimating];
NSString *htmlString = [NSString stringWithFormat:kMXKRecaptchaHTMLString, siteKey];
NSString *theme = ThemeService.shared.isCurrentThemeDark ? @"dark" : @"light";
NSString *htmlString = [NSString stringWithFormat:kMXKRecaptchaHTMLString, siteKey, theme];
[self loadHTMLString:htmlString baseURL:[NSURL URLWithString:homeServer]];
}