feat:add statusBarHeight in Environment

This commit is contained in:
pengfei.zhou 2020-01-21 15:31:26 +08:00 committed by osborn
parent 2e172a1cfd
commit 4363ef17eb
5 changed files with 7 additions and 1 deletions

View File

@ -101,7 +101,8 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
.put("appName", appName)
.put("appVersion", appVersion)
.put("screenWidth", DoricUtils.px2dp(DoricUtils.getScreenWidth()))
.put("screenHeight", DoricUtils.px2dp(DoricUtils.getScreenHeight()));
.put("screenHeight", DoricUtils.px2dp(DoricUtils.getScreenHeight()))
.put("statusBarHeight", DoricUtils.px2dp(DoricUtils.getStatusBarHeight(Doric.application())));
Map<String, Object> extend = mDoricRegistry.getEnvironmentVariables();
for (String key : extend.keySet()) {

View File

@ -62,6 +62,7 @@ - (void)initJSExecutor {
@"appVersion": infoDictionary[@"CFBundleShortVersionString"],
@"screenWidth": @([[UIScreen mainScreen] bounds].size.width),
@"screenHeight": @([[UIScreen mainScreen] bounds].size.height),
@"statusBarHeight": @([[UIApplication sharedApplication] statusBarFrame].size.height),
} mutableCopy];
[self.registry.environmentVariables enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) {

1
doric-js/index.d.ts vendored
View File

@ -50,6 +50,7 @@ declare module 'doric/lib/src/runtime/global' {
libVersion: string;
screenWidth: number;
screenHeight: number;
statusBarHeight: number;
[index: string]: number | string | boolean | object | undefined;
};
function Entry(constructor: {

View File

@ -36,6 +36,7 @@ declare global {
libVersion: string;
screenWidth: number;
screenHeight: number;
statusBarHeight: number;
[index: string]: number | string | boolean | object | undefined;
};
function Entry(constructor: {

View File

@ -60,6 +60,8 @@ declare global {
screenHeight: number,
statusBarHeight: number,
[index: string]: number | string | boolean | object | undefined
}
function Entry(constructor: { new(...args: any[]): {} }): any