-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for pixel based media queries ios
- Loading branch information
Showing
11 changed files
with
120 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react' | ||
import { Text, View } from 'react-native' | ||
import { createStyleSheet, useStyles, UnistylesRegistry, useInitialTheme, UnistylesRuntime } from 'react-native-unistyles' | ||
import { DemoScreen } from '../components' | ||
import { breakpoints, darkTheme, lightTheme, premiumTheme } from '../styles' | ||
import { useLazyRegistryForDemo } from '../hooks' | ||
|
||
export const MediaQueriesWidthHeight: React.FunctionComponent = () => { | ||
useLazyRegistryForDemo(() => { | ||
UnistylesRegistry | ||
.addThemes({ | ||
light: lightTheme, | ||
dark: darkTheme, | ||
premium: premiumTheme | ||
}) | ||
.addBreakpoints(breakpoints) | ||
}) | ||
|
||
useInitialTheme('light') | ||
|
||
const { styles, theme } = useStyles(stylesheet) | ||
|
||
return ( | ||
<DemoScreen> | ||
<View style={styles.container}> | ||
<Text style={styles.text}> | ||
This demo has media queries for width and height | ||
</Text> | ||
<Text style={styles.text}> | ||
Your window dimensions are: {UnistylesRuntime.screen.width}x{UnistylesRuntime.screen.height} | ||
</Text> | ||
<Text style={styles.text}> | ||
For width up to 500, and height up to 1000 the background is {theme.colors.backgroundColor} | ||
</Text> | ||
<Text style={styles.text}> | ||
For width above 900 the background is {theme.colors.aloes} | ||
</Text> | ||
<Text> | ||
Rotate or resize the window to see the changes | ||
</Text> | ||
</View> | ||
</DemoScreen> | ||
) | ||
} | ||
|
||
const stylesheet = createStyleSheet(theme => ({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
paddingHorizontal: 20, | ||
backgroundColor: { | ||
':w[, 500]:h[, 1000]': theme.colors.backgroundColor, | ||
':w[900]': theme.colors.aloes | ||
}, | ||
rowGap: 20 | ||
}, | ||
text: { | ||
textAlign: 'center', | ||
color: theme.colors.typography | ||
} | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters