Skip to content

Commit

Permalink
Added typed interface for all known constants (#4452)
Browse files Browse the repository at this point in the history
  • Loading branch information
pie6k authored and guyca committed Dec 16, 2018
1 parent c27fa5c commit a71e731
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/src/adapters/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { NativeModules } from 'react-native';

export interface NavigationConstants {
statusBarHeight: number;
backButtonId: string;
topBarHeight: number;
bottomTabsHeight: number;
}

export class Constants {
static async get(): Promise<any> {
static async get(): Promise<NavigationConstants> {
if (!this.instance) {
const constants = await NativeModules.RNNBridgeModule.getConstants();
const constants: NavigationConstants = await NativeModules.RNNBridgeModule.getConstants();
this.instance = new Constants(constants);
}
return this.instance;
Expand All @@ -16,7 +23,7 @@ export class Constants {
public readonly topBarHeight: number;
public readonly bottomTabsHeight: number;

private constructor(constants) {
private constructor(constants: NavigationConstants) {
this.statusBarHeight = constants.statusBarHeight;
this.topBarHeight = constants.topBarHeight;
this.backButtonId = constants.backButtonId;
Expand Down

0 comments on commit a71e731

Please sign in to comment.