mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 11:34:23 +00:00
Add KeyboardAvoidingView
This commit is contained in:
parent
36444a65c7
commit
e092c61bac
@ -62,7 +62,7 @@ IMPLEMENT_KEYBOARD_HANDLER(keyboardDidChangeFrame)
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static NSDictionary *RCTRectDictionaryValue(CGRect rect)
|
NS_INLINE NSDictionary *RCTRectDictionaryValue(CGRect rect)
|
||||||
{
|
{
|
||||||
return @{
|
return @{
|
||||||
@"screenX": @(rect.origin.x),
|
@"screenX": @(rect.origin.x),
|
||||||
@ -72,16 +72,34 @@ static NSDictionary *RCTRectDictionaryValue(CGRect rect)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NSString *RCTAnimationNameForCurve(UIViewAnimationCurve curve)
|
||||||
|
{
|
||||||
|
switch (curve) {
|
||||||
|
case UIViewAnimationCurveEaseIn:
|
||||||
|
return @"easeIn";
|
||||||
|
case UIViewAnimationCurveEaseInOut:
|
||||||
|
return @"easeInEaseOut";
|
||||||
|
case UIViewAnimationCurveEaseOut:
|
||||||
|
return @"easeOut";
|
||||||
|
case UIViewAnimationCurveLinear:
|
||||||
|
return @"linear";
|
||||||
|
default:
|
||||||
|
return @"keyboard";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static NSDictionary *RCTParseKeyboardNotification(NSNotification *notification)
|
static NSDictionary *RCTParseKeyboardNotification(NSNotification *notification)
|
||||||
{
|
{
|
||||||
NSDictionary *userInfo = notification.userInfo;
|
NSDictionary *userInfo = notification.userInfo;
|
||||||
CGRect beginFrame = [userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
|
CGRect beginFrame = [userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
|
||||||
CGRect endFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
CGRect endFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||||
NSTimeInterval duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
NSTimeInterval duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
||||||
|
UIViewAnimationCurve curve = [userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];
|
||||||
|
|
||||||
return @{
|
return @{
|
||||||
@"startCoordinates": RCTRectDictionaryValue(beginFrame),
|
@"startCoordinates": RCTRectDictionaryValue(beginFrame),
|
||||||
@"endCoordinates": RCTRectDictionaryValue(endFrame),
|
@"endCoordinates": RCTRectDictionaryValue(endFrame),
|
||||||
@"duration": @(duration * 1000.0), // ms
|
@"duration": @(duration * 1000.0), // ms
|
||||||
|
@"easing": RCTAnimationNameForCurve(curve),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user