-
-
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: implement orientations for mobile, add demo
- Loading branch information
Showing
9 changed files
with
111 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React from 'react' | ||
import { Text, View } from 'react-native' | ||
import { createStyleSheet, useStyles, UnistylesRegistry, UnistylesRuntime, ScreenOrientation } from 'react-native-unistyles' | ||
import { DemoScreen } from '../components' | ||
import { darkTheme, lightTheme, premiumTheme } from '../styles' | ||
import { useLazyRegistryForDemo } from '../hooks' | ||
|
||
export const OrientationBreakpoints: React.FunctionComponent = () => { | ||
useLazyRegistryForDemo(() => { | ||
UnistylesRegistry | ||
.addThemes({ | ||
light: lightTheme, | ||
dark: darkTheme, | ||
premium: premiumTheme | ||
}) | ||
.addConfig({ | ||
adaptiveThemes: true | ||
}) | ||
}) | ||
|
||
const { styles } = useStyles(stylesheet) | ||
|
||
return ( | ||
<DemoScreen> | ||
<View style={styles.container}> | ||
<Text style={styles.text}> | ||
This demo has no registered breakpoints. On mobile Unistyles will provide you two breakpoints: | ||
</Text> | ||
<Text> | ||
landscape and portrait | ||
</Text> | ||
<Text style={styles.text}> | ||
The current orientation is: {UnistylesRuntime.orientation === ScreenOrientation.Portrait ? 'portrait' : 'landscape'} | ||
</Text> | ||
<Text style={styles.text}> | ||
You should see circles on portrait and rectangles on landscape | ||
</Text> | ||
<View style={styles.objectContainer}> | ||
{Array.from(new Array(10)).map((_, index) => ( | ||
<View | ||
key={index} | ||
style={styles.object} | ||
/> | ||
))} | ||
</View> | ||
</View> | ||
</DemoScreen> | ||
) | ||
} | ||
|
||
const stylesheet = createStyleSheet(theme => ({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
paddingHorizontal: 20, | ||
backgroundColor: theme.colors.backgroundColor, | ||
rowGap: 20 | ||
}, | ||
text: { | ||
textAlign: 'center', | ||
color: theme.colors.typography | ||
}, | ||
objectContainer: { | ||
flexDirection: 'row', | ||
columnGap: 10 | ||
}, | ||
object: { | ||
width: 40, | ||
height: 40, | ||
backgroundColor: theme.colors.accent, | ||
borderRadius: { | ||
portrait: undefined, | ||
landscape: 20 | ||
} | ||
} | ||
})) |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export interface UnistylesThemes {} | ||
export interface UnistylesBreakpoints { | ||
default?: 0 | ||
landscape?: number, | ||
portrait?: number, | ||
} |
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