Skip to content

Commit adc125c

Browse files
committed
Update Dimensions API types
1 parent dc9cbdc commit adc125c

2 files changed

Lines changed: 38 additions & 18 deletions

File tree

‎docs/dimensions.md‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,20 @@ static addEventListener(
104104
handler: ({
105105
window,
106106
screen,
107-
}: DimensionsValue) => void,
107+
}: DimensionsPayload) => void,
108108
): EventSubscription;
109109
```
110110

111111
Add an event handler. Supported events:
112112

113-
- `change`: Fires when a property within the `Dimensions` object changes. The argument to the event handler is a [`DimensionsValue`](#dimensionsvalue) type object.
113+
- `change`: Fires when a property within the `Dimensions` object changes. The argument to the event handler is a [`DimensionsPayload`](#dimensionspayload) object.
114114

115115
---
116116

117117
### `get()`
118118

119119
```tsx
120-
static get(dim: 'window' | 'screen'): ScaledSize;
120+
static get(dim: string): DisplayMetrics | DisplayMetricsAndroid;
121121
```
122122

123123
Initial dimensions are set before `runApplication` is called so they should be available before any other require's are run, but may be updated later.
@@ -136,16 +136,18 @@ For Android the `window` dimension will be reduced by the size of status bar (if
136136

137137
## Type Definitions
138138

139-
### DimensionsValue
139+
### DimensionsPayload
140140

141141
**Properties:**
142142

143-
| Name | Type | Description |
144-
| ------ | ----------------------------------- | --------------------------------------- |
145-
| window | [ScaledSize](dimensions#scaledsize) | Size of the visible Application window. |
146-
| screen | [ScaledSize](dimensions#scaledsize) | Size of the device's screen. |
143+
| Name | Type | Description |
144+
| -------------------- | --------------------------------------------------------- | --------------------------------------- |
145+
| window | [DisplayMetrics](dimensions#displaymetrics) | Size of the visible application window. |
146+
| screen | [DisplayMetrics](dimensions#displaymetrics) | Size of the device's screen. |
147+
| windowPhysicalPixels | [DisplayMetricsAndroid](dimensions#displaymetricsandroid) | Physical pixels for the Android window. |
148+
| screenPhysicalPixels | [DisplayMetricsAndroid](dimensions#displaymetricsandroid) | Physical pixels for the Android screen. |
147149

148-
### ScaledSize
150+
### DisplayMetrics
149151

150152
| Type |
151153
| ------ |
@@ -159,3 +161,11 @@ For Android the `window` dimension will be reduced by the size of status bar (if
159161
| height | number |
160162
| scale | number |
161163
| fontScale | number |
164+
165+
### DisplayMetricsAndroid
166+
167+
`DisplayMetricsAndroid` includes all [`DisplayMetrics`](dimensions#displaymetrics) properties and the following property:
168+
169+
| Name | Type |
170+
| ---------- | ------ |
171+
| densityDpi | number |

‎website/versioned_docs/version-0.87/dimensions.md‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,20 @@ static addEventListener(
104104
handler: ({
105105
window,
106106
screen,
107-
}: DimensionsValue) => void,
107+
}: DimensionsPayload) => void,
108108
): EventSubscription;
109109
```
110110

111111
Add an event handler. Supported events:
112112

113-
- `change`: Fires when a property within the `Dimensions` object changes. The argument to the event handler is a [`DimensionsValue`](#dimensionsvalue) type object.
113+
- `change`: Fires when a property within the `Dimensions` object changes. The argument to the event handler is a [`DimensionsPayload`](#dimensionspayload) object.
114114

115115
---
116116

117117
### `get()`
118118

119119
```tsx
120-
static get(dim: 'window' | 'screen'): ScaledSize;
120+
static get(dim: string): DisplayMetrics | DisplayMetricsAndroid;
121121
```
122122

123123
Initial dimensions are set before `runApplication` is called so they should be available before any other require's are run, but may be updated later.
@@ -136,16 +136,18 @@ For Android the `window` dimension will be reduced by the size of status bar (if
136136

137137
## Type Definitions
138138

139-
### DimensionsValue
139+
### DimensionsPayload
140140

141141
**Properties:**
142142

143-
| Name | Type | Description |
144-
| ------ | ----------------------------------- | --------------------------------------- |
145-
| window | [ScaledSize](dimensions#scaledsize) | Size of the visible Application window. |
146-
| screen | [ScaledSize](dimensions#scaledsize) | Size of the device's screen. |
143+
| Name | Type | Description |
144+
| -------------------- | --------------------------------------------------------- | --------------------------------------- |
145+
| window | [DisplayMetrics](dimensions#displaymetrics) | Size of the visible application window. |
146+
| screen | [DisplayMetrics](dimensions#displaymetrics) | Size of the device's screen. |
147+
| windowPhysicalPixels | [DisplayMetricsAndroid](dimensions#displaymetricsandroid) | Physical pixels for the Android window. |
148+
| screenPhysicalPixels | [DisplayMetricsAndroid](dimensions#displaymetricsandroid) | Physical pixels for the Android screen. |
147149

148-
### ScaledSize
150+
### DisplayMetrics
149151

150152
| Type |
151153
| ------ |
@@ -159,3 +161,11 @@ For Android the `window` dimension will be reduced by the size of status bar (if
159161
| height | number |
160162
| scale | number |
161163
| fontScale | number |
164+
165+
### DisplayMetricsAndroid
166+
167+
`DisplayMetricsAndroid` includes all [`DisplayMetrics`](dimensions#displaymetrics) properties and the following property:
168+
169+
| Name | Type |
170+
| ---------- | ------ |
171+
| densityDpi | number |

0 commit comments

Comments
 (0)