Skip to content

Commit e23f535

Browse files
authored
refactor: cleanup react-native-apis evals (#375)
fix(react-native-apis): address PR feedback
1 parent 470d900 commit e23f535

13 files changed

Lines changed: 109 additions & 24 deletions

File tree

evals/react-native-apis/02-rn-stylesheet-absolute-fill-overlay-badge/requirements.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ inputs:
55
requirements:
66
- id: overlay-covers-thumbnail-with-stylesheet-helper
77
description: Must position the thumbnail overlay with `StyleSheet.absoluteFill`.
8+
- id: overlay-does-not-use-deprecated-absolute-fill-object
9+
description: Must NOT use deprecated `StyleSheet.absoluteFillObject`.
810
- id: overlay-background-color-rgba
911
description: Must have a background color of `rgba(0, 0, 0, 0.5)`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Render an image below "Story" text.
2+
Use built-in React Native APIs only. Do not add external image libraries or other dependencies.
23
Use `https://placehold.co/200x100.png` as the image URL. The image has dimensions of 200x100 pixels.
5.17 KB
Loading
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Add a background image to the header.
2-
Use the `assets/banner.png` as path to an image.
2+
Use the local `./banner.jpg` file as the image source.
33
The image should fill the entire header area without stretching, even if some edges are cropped.

evals/react-native-apis/05-rn-imagebackground-resize-mode/reference/App.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export default function App() {
1111
<View style={styles.screen}>
1212
<Text style={styles.title}>Overview</Text>
1313
<ImageBackground
14-
source={require('banner.png')}
14+
source={require('./banner.jpg')}
15+
imageStyle={styles.headerImage}
1516
style={styles.header}
1617
resizeMode='cover'
1718
>
@@ -26,7 +27,10 @@ export default function App() {
2627

2728
const styles = StyleSheet.create({
2829
header: {
29-
flex: 1,
30+
borderRadius: 20,
31+
height: 200,
32+
overflow: 'hidden',
33+
width: 300,
3034
},
3135
headerContent: {
3236
flex: 1,
5.17 KB
Loading
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
version: 1
22
inputs:
33
files:
4-
- app/banner.png
4+
- app/App.tsx
5+
- app/banner.jpg
56
requirements:
67
- id: implementation-render-imagebackground
78
description: Must import and render `ImageBackground` from `react-native`.
89
- id: imagebackground-uses-local-banner-asset
9-
description: Must provide the background image source with static `require(...)` for `assets/banner.png`.
10+
description: Must provide the background image source with static `require(...)` for `./banner.jpg`.
1011
- id: background-image-flex-style
11-
description: Must give the background image flex styles to fill the header area.
12+
description: Must size the background image to fill the existing header area.
1213
- id: background-image-resize-mode-cover
1314
description: Must set the background image `resizeMode` to `cover`.
Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,42 @@
11
import React from 'react'
2-
import { Text, View } from 'react-native'
2+
import {
3+
StyleSheet,
4+
Text,
5+
View,
6+
} from 'react-native'
37

48
export default function App() {
59
return (
6-
<View>
7-
<Text>Summary</Text>
10+
<View style={styles.screen}>
11+
<View style={styles.card}>
12+
<Text style={styles.title}>Summary</Text>
13+
<Text style={styles.description}>
14+
Crew updates for the current shift.
15+
</Text>
16+
</View>
817
</View>
918
)
1019
}
20+
21+
const styles = StyleSheet.create({
22+
card: {
23+
backgroundColor: '#fff',
24+
borderRadius: 16,
25+
padding: 16,
26+
},
27+
description: {
28+
color: '#475569',
29+
marginTop: 8,
30+
},
31+
screen: {
32+
backgroundColor: '#f8fafc',
33+
flex: 1,
34+
justifyContent: 'center',
35+
paddingHorizontal: 20,
36+
},
37+
title: {
38+
color: '#0f172a',
39+
fontSize: 18,
40+
fontWeight: '700',
41+
},
42+
})
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Add platform-specific font size for the Summary text.
2-
The font size should be `12` on Android, `10` on iOS, and `8` on all other platforms.
1+
Use `Platform.select` to apply platform-native depth styling to the summary card: iOS should use shadow props, Android should use elevation, and other platforms should use a border imitating shadow.
Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,62 @@
11
import React from 'react'
22
import {
33
Platform,
4+
StyleSheet,
45
Text,
56
View,
67
} from 'react-native'
78

8-
const subtitleFontSize = Platform.select({
9-
android: 12,
10-
default: 8,
11-
ios: 10,
9+
const cardChrome = Platform.select({
10+
android: {
11+
elevation: 6,
12+
},
13+
default: {
14+
borderColor: '#cbd5e1',
15+
borderWidth: 1,
16+
},
17+
ios: {
18+
shadowColor: '#0f172a',
19+
shadowOffset: {
20+
height: 6,
21+
width: 0,
22+
},
23+
shadowOpacity: 0.15,
24+
shadowRadius: 12,
25+
},
1226
})
1327

1428
export default function App() {
1529
return (
16-
<View>
17-
<Text style={{ fontSize: subtitleFontSize }}>Summary</Text>
30+
<View style={styles.screen}>
31+
<View style={[styles.card, cardChrome]}>
32+
<Text style={styles.title}>Summary</Text>
33+
<Text style={styles.description}>
34+
Crew updates for the current shift.
35+
</Text>
36+
</View>
1837
</View>
1938
)
2039
}
40+
41+
const styles = StyleSheet.create({
42+
card: {
43+
backgroundColor: '#fff',
44+
borderRadius: 16,
45+
padding: 16,
46+
},
47+
description: {
48+
color: '#475569',
49+
marginTop: 8,
50+
},
51+
screen: {
52+
backgroundColor: '#f8fafc',
53+
flex: 1,
54+
justifyContent: 'center',
55+
paddingHorizontal: 20,
56+
},
57+
title: {
58+
color: '#0f172a',
59+
fontSize: 18,
60+
fontWeight: '700',
61+
},
62+
})

0 commit comments

Comments
 (0)