Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/rn-tester/js/examples/PixelRatio/PixelRatioExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
'use strict';

import RNTesterText from '../../components/RNTesterText';
import {RNTesterThemeContext} from '../../components/RNTesterTheme';
import React, {useState} from 'react';
import {Button, PixelRatio, StyleSheet, TextInput, View} from 'react-native';

function LayoutSizeToPixel() {
const theme = React.useContext(RNTesterThemeContext);
const [layoutDPSize, setLayoutDPSize] = useState<number>(0);
const pixelSize = PixelRatio.getPixelSizeForLayoutSize(
layoutDPSize ? layoutDPSize : 0,
Expand All @@ -33,7 +35,10 @@ function LayoutSizeToPixel() {
Layout Size(dp):{' '}
</RNTesterText>
<TextInput
style={styles.input}
style={[
styles.input,
{color: theme.LabelColor, borderColor: theme.SeparatorColor},
]}
value={layoutDPSize ? layoutDPSize.toString() : ''}
keyboardType={'numeric'}
onChangeText={handleDPInputChange}
Expand All @@ -49,6 +54,7 @@ function LayoutSizeToPixel() {
}

function RoundToNearestPixel() {
const theme = React.useContext(RNTesterThemeContext);
const [layoutDPSizeText, setLayoutDPSizeText] = useState('');
const layoutDPSize = parseFloat(layoutDPSizeText);

Expand All @@ -68,7 +74,10 @@ function RoundToNearestPixel() {
Layout Size(dp):{' '}
</RNTesterText>
<TextInput
style={styles.input}
style={[
styles.input,
{color: theme.LabelColor, borderColor: theme.SeparatorColor},
]}
value={layoutDPSizeText ? layoutDPSizeText.toString() : ''}
keyboardType={'numeric'}
onChangeText={handleDPInputChange}
Expand Down
Loading