Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 1f92441

Browse files
committed
Merge branches 'kgdev' and 'master' of github.com:UnityTech/UIWidgets into kgdev
2 parents 23761d1 + 459df12 commit 1f92441

File tree

10 files changed

+910
-159
lines changed

10 files changed

+910
-159
lines changed

Runtime/Plugins/platform/ios/UIWidgetsViewController.mm

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ -(void)keyboardWillChangeFrame:(NSNotification*)notification {
6565
CGFloat bottom = CGRectGetHeight([[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]);
6666
CGFloat scale = [UIScreen mainScreen].scale;
6767

68-
// scale == 3 => screen is 1242 * 2208 => we have to perform down-sampling to obtain the real length
69-
// 0.8696 = 1920 / 2208, the vertical down-sampling ratio
70-
if (scale == 3) {
71-
bottom = bottom * 0.8696;
72-
}
73-
7468
viewInsets.bottom = bottom * scale;
7569
padding.bottom = 0;
7670

@@ -100,14 +94,18 @@ viewMetrics IOSGetViewportPadding()
10094
viewMetrics metrics;
10195
viewPadding insets = [[UIWidgetsViewController sharedInstance] viewInsets];
10296
viewPadding padding = [[UIWidgetsViewController sharedInstance] padding];
103-
metrics.insets_bottom = insets.bottom;
104-
metrics.insets_top = insets.top;
105-
metrics.insets_left = insets.left;
106-
metrics.insets_right = insets.right;
107-
metrics.padding_bottom = padding.bottom;
108-
metrics.padding_top = padding.top;
109-
metrics.padding_left = padding.left;
110-
metrics.padding_right = padding.right;
97+
98+
CGFloat scale = [UIScreen mainScreen].scale;
99+
BOOL needDownsample = scale == 3;
100+
101+
metrics.insets_bottom = needDownsample ? insets.bottom * 0.8696 : insets.bottom;
102+
metrics.insets_top = needDownsample ? insets.top * 0.8696 : insets.top;
103+
metrics.insets_left = needDownsample ? insets.left * 0.8696 : insets.left;
104+
metrics.insets_right = needDownsample ? insets.right * 0.8696 : insets.right;
105+
metrics.padding_bottom = needDownsample ? padding.bottom * 0.8696 : padding.bottom;
106+
metrics.padding_top = needDownsample ? padding.top * 0.8696 : padding.top;
107+
metrics.padding_left = needDownsample ? padding.left * 0.8696 : padding.left;
108+
metrics.padding_right = needDownsample ? padding.right * 0.8696 : padding.right;
111109

112110
return metrics;
113111
}

Runtime/gestures/constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public static class Constants {
1010

1111
public const float kPanSlop = kTouchSlop * 2.0f;
1212

13+
public const float kScaleSlop = kTouchSlop;
14+
1315
public static readonly TimeSpan kPressTimeout = new TimeSpan(0, 0, 0, 0, 100);
1416

1517
public static readonly TimeSpan kDoubleTapTimeout = new TimeSpan(0, 0, 0, 0, 300);

0 commit comments

Comments
 (0)