xingwei.zhu
6 年前
当前提交
ec84eae5
共有 9 个文件被更改,包括 344 次插入 和 52 次删除
-
37Runtime/Plugins/platform/ios/DeviceScreen.mm
-
21Runtime/editor/editor_utils.cs
-
11Runtime/editor/editor_window.cs
-
95Runtime/engine/DisplayMetrics.cs
-
23Runtime/engine/UIWidgetsPanel.cs
-
34Runtime/Plugins/platform/ios/UIWidgetsViewController.h
-
26Runtime/Plugins/platform/ios/UIWidgetsViewController.h.meta
-
113Runtime/Plugins/platform/ios/UIWidgetsViewController.mm
-
36Runtime/Plugins/platform/ios/UIWidgetsViewController.mm.meta
|
|||
#import <UIKit/UIKit.h> |
|||
extern "C" |
|||
{ |
|||
int IOSDeviceScaleFactor() |
|||
{ |
|||
return [[UIScreen mainScreen] scale]; |
|||
} |
|||
|
|||
|
|||
struct viewPadding |
|||
{ |
|||
float top; |
|||
float bottom; |
|||
float left; |
|||
float right; |
|||
}; |
|||
|
|||
viewPadding IOSGetViewportPadding() |
|||
{ |
|||
viewPadding _viewPadding; |
|||
CGFloat scale = [[UIScreen mainScreen] scale]; |
|||
if (@available(iOS 11, *)) { |
|||
_viewPadding.bottom = [UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom * scale; |
|||
_viewPadding.top = [UIApplication sharedApplication].keyWindow.safeAreaInsets.top * scale; |
|||
_viewPadding.left = [UIApplication sharedApplication].keyWindow.safeAreaInsets.left * scale; |
|||
_viewPadding.right = [UIApplication sharedApplication].keyWindow.safeAreaInsets.right * scale; |
|||
} else { |
|||
CGRect statusFrame = [UIApplication sharedApplication].statusBarFrame; |
|||
_viewPadding.bottom = 0; |
|||
_viewPadding.top = statusFrame.size.height * scale; |
|||
_viewPadding.left = 0; |
|||
_viewPadding.right = 0; |
|||
} |
|||
|
|||
return _viewPadding; |
|||
} |
|||
int IOSDeviceScaleFactor() |
|||
{ |
|||
return [[UIScreen mainScreen] scale]; |
|||
} |
|||
} |
|
|||
#ifndef PLATFORM_IOS_FRAMEWORK_SOURCE_UIWIDGETSVIEWCONTROLLER_H_ |
|||
#define PLATFORM_IOS_FRAMEWORK_SOURCE_UIWIDGETSVIEWCONTROLLER_H_ |
|||
|
|||
#import <UIKit/UIKit.h> |
|||
#include "UIWidgetsTextInputDelegate.h" |
|||
|
|||
|
|||
struct viewPadding |
|||
{ |
|||
float top; |
|||
float bottom; |
|||
float left; |
|||
float right; |
|||
}; |
|||
|
|||
struct viewMetrics |
|||
{ |
|||
float insets_top; |
|||
float insets_bottom; |
|||
float insets_left; |
|||
float insets_right; |
|||
|
|||
float padding_top; |
|||
float padding_bottom; |
|||
float padding_left; |
|||
float padding_right; |
|||
}; |
|||
|
|||
@interface UIWidgetsViewController : NSObject |
|||
@property viewPadding padding; |
|||
@property viewPadding viewInsets; |
|||
@end |
|||
|
|||
#endif // PLATFORM_IOS_FRAMEWORK_SOURCE_UIWIDGETSVIEWCONTROLLER_H_ |
|
|||
fileFormatVersion: 2 |
|||
guid: a797fb0a2ddb84d4e8ac7f6da5d70819 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
platformData: |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#include "UIWidgetsViewController.h" |
|||
#include "UIWidgetsMessageManager.h" |
|||
#include <Foundation/Foundation.h> |
|||
#include <UIKit/UIKit.h> |
|||
|
|||
@implementation UIWidgetsViewController { |
|||
} |
|||
|
|||
@synthesize viewInsets; |
|||
@synthesize padding; |
|||
|
|||
- (instancetype)init { |
|||
self = [super init]; |
|||
if (self) { |
|||
viewInsets.bottom = 0; |
|||
viewInsets.top = 0; |
|||
viewInsets.left = 0; |
|||
viewInsets.right = 0; |
|||
|
|||
CGFloat scale = [[UIScreen mainScreen] scale]; |
|||
if (@available(iOS 11, *)) { |
|||
padding.bottom = [UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom * scale; |
|||
padding.top = [UIApplication sharedApplication].keyWindow.safeAreaInsets.top * scale; |
|||
padding.left = [UIApplication sharedApplication].keyWindow.safeAreaInsets.left * scale; |
|||
padding.right = [UIApplication sharedApplication].keyWindow.safeAreaInsets.right * scale; |
|||
} else { |
|||
CGRect statusFrame = [UIApplication sharedApplication].statusBarFrame; |
|||
padding.bottom = 0; |
|||
padding.top = statusFrame.size.height * scale; |
|||
padding.left = 0; |
|||
padding.right = 0; |
|||
} |
|||
|
|||
NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
|||
[center addObserver:self |
|||
selector:@selector(keyboardWillChangeFrame:) |
|||
name:UIKeyboardWillChangeFrameNotification |
|||
object:nil]; |
|||
[center addObserver:self |
|||
selector:@selector(keyboardWillBeHidden:) |
|||
name:UIKeyboardWillHideNotification |
|||
object:nil]; |
|||
} |
|||
|
|||
return self; |
|||
} |
|||
|
|||
-(void)keyboardWillBeHidden:(NSNotification*)notification { |
|||
viewInsets.bottom = 0; |
|||
CGFloat scale = [UIScreen mainScreen].scale; |
|||
if (@available(iOS 11, *)) { |
|||
CGFloat cur_padding = [UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom * scale; |
|||
padding.bottom = cur_padding; |
|||
} else { |
|||
CGRect statusFrame = [UIApplication sharedApplication].statusBarFrame; |
|||
CGFloat cur_padding = statusFrame.size.height * scale; |
|||
padding.top = cur_padding; |
|||
} |
|||
|
|||
UIWidgetsMethodMessage(@"ViewportMatricsChanged", @"UIWidgetViewController.keyboardHide", @[]); |
|||
} |
|||
|
|||
-(void)keyboardWillChangeFrame:(NSNotification*)notification { |
|||
NSDictionary* info = [notification userInfo]; |
|||
CGFloat bottom = CGRectGetHeight([[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]); |
|||
CGFloat scale = [UIScreen mainScreen].scale; |
|||
|
|||
viewInsets.bottom = bottom * scale; |
|||
padding.bottom = 0; |
|||
|
|||
UIWidgetsMethodMessage(@"ViewportMatricsChanged", @"UIWidgetViewController.keyboardHide", @[]); |
|||
} |
|||
|
|||
-(void)tryLaunch { |
|||
|
|||
} |
|||
|
|||
+ (instancetype)sharedInstance { |
|||
static UIWidgetsViewController *sharedInstance = nil; |
|||
static dispatch_once_t onceToken; |
|||
|
|||
dispatch_once(&onceToken, ^{ |
|||
sharedInstance = [[UIWidgetsViewController alloc] init]; |
|||
}); |
|||
return sharedInstance; |
|||
} |
|||
|
|||
@end |
|||
|
|||
extern "C" |
|||
{ |
|||
void IOSDeviceStartup() |
|||
{ |
|||
[[UIWidgetsViewController sharedInstance] tryLaunch]; |
|||
} |
|||
|
|||
viewMetrics IOSGetViewportPadding() |
|||
{ |
|||
viewMetrics metrics; |
|||
viewPadding insets = [[UIWidgetsViewController sharedInstance] viewInsets]; |
|||
viewPadding padding = [[UIWidgetsViewController sharedInstance] padding]; |
|||
metrics.insets_bottom = insets.bottom; |
|||
metrics.insets_top = insets.top; |
|||
metrics.insets_left = insets.left; |
|||
metrics.insets_right = insets.right; |
|||
metrics.padding_bottom = padding.bottom; |
|||
metrics.padding_top = padding.top; |
|||
metrics.padding_left = padding.left; |
|||
metrics.padding_right = padding.right; |
|||
|
|||
return metrics; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fc3d8a9d616f147929ae9b8898fa01bf |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
platformData: |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
tvOS: tvOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue