-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0800e8
commit 379e233
Showing
6 changed files
with
96 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"exclude": ["ManyStories"], | ||
"include": ["TestInfo"], | ||
"devices": [ | ||
{ | ||
"id": "pixel.7.pro", | ||
|
13 changes: 13 additions & 0 deletions
13
testing/expo-storybook-8/src/components/TestInfo/ExpoUpdateInfo.stories.tsx
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,13 @@ | ||
import { ExpoUpdateInfo, StoryDecorator } from '@sherlo/testing-components'; | ||
import type { Meta } from '@storybook/react'; | ||
|
||
/** | ||
* This is a test screen that we add to our tests | ||
* to display information about device and app configuration | ||
*/ | ||
export default { | ||
component: ExpoUpdateInfo, | ||
decorators: [StoryDecorator({ placement: 'center' })], | ||
} as Meta<typeof ExpoUpdateInfo>; | ||
|
||
export const Basic = {}; |
47 changes: 47 additions & 0 deletions
47
testing/testing-components/src/components/ExpoUpdateInfo.tsx
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,47 @@ | ||
import React from 'react'; | ||
import { View, StyleSheet } from 'react-native'; | ||
import * as Updates from 'expo-updates'; | ||
import InfoItem from './InfoItem'; | ||
|
||
const ExpoUpdateInfo = () => { | ||
return ( | ||
<View style={[styles.container]}> | ||
{Updates.updateId ? ( | ||
<> | ||
<InfoItem | ||
iconName="mobile-friendly" | ||
text={`Runtime Version: ${Updates.runtimeVersion}`} | ||
/> | ||
<InfoItem | ||
iconName="update" | ||
text={`Update (${Updates.createdAt?.toLocaleString('en-US', { | ||
month: '2-digit', | ||
day: '2-digit', | ||
year: 'numeric', | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
second: '2-digit', | ||
hour12: false, | ||
})}) with ID:`} | ||
/> | ||
<InfoItem text={Updates.updateId} /> | ||
</> | ||
) : ( | ||
<InfoItem text={'No update available'} /> | ||
)} | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
width: '100%', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
padding: 20, | ||
paddingHorizontal: 20, | ||
}, | ||
}); | ||
|
||
export default ExpoUpdateInfo; |
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,31 @@ | ||
import React from 'react'; | ||
import { Text, View, StyleSheet, useColorScheme } from 'react-native'; | ||
import { MaterialIcons } from '@expo/vector-icons'; | ||
|
||
export const InfoItem: React.FC<{ | ||
iconName?: React.ComponentProps<typeof MaterialIcons>['name']; | ||
text?: string; | ||
}> = ({ iconName, text }) => { | ||
const theme = useColorScheme(); | ||
const textColor = theme === 'dark' ? '#FFF' : '#333'; | ||
return ( | ||
<View style={styles.infoContainer}> | ||
{iconName ? <MaterialIcons name={iconName} size={24} color={textColor} /> : null} | ||
<Text style={[styles.text, { color: textColor }]}>{text}</Text> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
infoContainer: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
marginBottom: 20, | ||
}, | ||
text: { | ||
fontSize: 12, | ||
marginLeft: 10, | ||
}, | ||
}); | ||
|
||
export default InfoItem; |
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 +1,2 @@ | ||
export { default as TestInfo } from './TestInfo'; | ||
export { default as ExpoUpdateInfo } from './ExpoUpdateInfo'; |