Skip to content

Commit 6c0fe56

Browse files
ghenry22mlynch
authored andcommitted
Add option for Dark keyboard appearance (#44)
* add darkkeyboard option * Remove unnecessary value
1 parent 99b60cf commit 6c0fe56

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/ios/CDVWKWebViewEngine.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ - (void)pluginInitialize
348348
[self keyboardDisplayDoesNotRequireUserAction];
349349
//}
350350

351+
if ([settings cordovaBoolSettingForKey:@"KeyboardAppearanceDark" defaultValue:NO]) {
352+
[self setKeyboardAppearanceDark];
353+
}
354+
351355
[self updateSettings:settings];
352356

353357
// check if content thread has died on resume
@@ -420,6 +424,22 @@ - (NSString*)generateRandomString:(int)num {
420424
return string;
421425
}
422426

427+
- (void)setKeyboardAppearanceDark
428+
{
429+
IMP darkImp = imp_implementationWithBlock(^(id _s) {
430+
return UIKeyboardAppearanceDark;
431+
});
432+
for (NSString* classString in @[@"WKContentView", @"UITextInputTraits"]) {
433+
Class c = NSClassFromString(classString);
434+
Method m = class_getInstanceMethod(c, @selector(keyboardAppearance));
435+
if (m != NULL) {
436+
method_setImplementation(m, darkImp);
437+
} else {
438+
class_addMethod(c, @selector(keyboardAppearance), darkImp, "l@:");
439+
}
440+
}
441+
}
442+
423443
- (void)onReset
424444
{
425445
[self addURLObserver];

0 commit comments

Comments
 (0)