Skip to content

Commit b277eaf

Browse files
committed
chore: HomeScreen Animations and Reestructured App Folders
1 parent cb558e7 commit b277eaf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+339
-221
lines changed

App.js

+20-200
Original file line numberDiff line numberDiff line change
@@ -1,210 +1,30 @@
11
import React from 'react';
2-
import { ScrollView, SafeAreaView } from 'react-native';
3-
import styled from 'styled-components/native';
4-
import * as Icon from '@expo/vector-icons';
2+
import { createStore } from 'redux';
3+
import { Provider } from 'react-redux';
54

6-
import Card from './src/components/Card';
7-
import Logo from './src/components/Logo';
8-
import Course from './src/components/Course';
9-
import Menu from './src/components/Menu';
5+
import HomeScreen from '~/screens/HomeScreen';
106

11-
const logos = [
12-
{
13-
image: require('./assets/logo-framerx.png'),
14-
text: 'Framer X',
15-
},
16-
{
17-
image: require('./assets/logo-figma.png'),
18-
text: 'Figma',
19-
},
20-
{
21-
image: require('./assets/logo-studio.png'),
22-
text: 'Studio',
23-
},
24-
{
25-
image: require('./assets/logo-react.png'),
26-
text: 'React',
27-
},
28-
{
29-
image: require('./assets/logo-swift.png'),
30-
text: 'Swift',
31-
},
32-
{
33-
image: require('./assets/logo-sketch.png'),
34-
text: 'Sketch',
35-
},
36-
];
7+
const INITIAL_STATE = {
8+
action: 'openMenu',
9+
};
3710

38-
const cards = [
39-
{
40-
title: 'React Native for Designers',
41-
image: require('./assets/background11.jpg'),
42-
subtitle: 'React Native',
43-
caption: '1 of 12 sections',
44-
logo: require('./assets/logo-react.png'),
45-
},
46-
{
47-
title: 'Styled Components',
48-
image: require('./assets/background12.jpg'),
49-
subtitle: 'React Native',
50-
caption: '2 of 12 sections',
51-
logo: require('./assets/logo-react.png'),
52-
},
53-
{
54-
title: 'Props and Icons',
55-
image: require('./assets/background13.jpg'),
56-
subtitle: 'React Native',
57-
caption: '3 of 12 sections',
58-
logo: require('./assets/logo-react.png'),
59-
},
60-
{
61-
title: 'Static Data and Loop',
62-
image: require('./assets/background14.jpg'),
63-
subtitle: 'React Native',
64-
caption: '4 of 12 sections',
65-
logo: require('./assets/logo-react.png'),
66-
},
67-
];
11+
const reducer = (state = INITIAL_STATE, action) => {
12+
switch (action.type) {
13+
case 'OPEN_MENU':
14+
return { action: 'openMenu' };
15+
case 'CLOSE_MENU':
16+
return { action: 'closeMenu' };
17+
default:
18+
return state;
19+
}
20+
};
6821

69-
const courses = [
70-
{
71-
title: 'Prototype in InVision Studio',
72-
subtitle: '10 sections',
73-
image: require('./assets/background13.jpg'),
74-
logo: require('./assets/logo-studio.png'),
75-
author: 'Meng To',
76-
avatar: require('./assets/avatar.jpg'),
77-
caption: 'Design an interactive prototype',
78-
},
79-
{
80-
title: 'React for Designers',
81-
subtitle: '12 sections',
82-
image: require('./assets/background11.jpg'),
83-
logo: require('./assets/logo-react.png'),
84-
author: 'Meng To',
85-
avatar: require('./assets/avatar.jpg'),
86-
caption: 'Learn to design and code a React site',
87-
},
88-
{
89-
title: 'Design and Code with Framer X',
90-
subtitle: '10 sections',
91-
image: require('./assets/background14.jpg'),
92-
logo: require('./assets/logo-framerx.png'),
93-
author: 'Meng To',
94-
avatar: require('./assets/avatar.jpg'),
95-
caption: 'Create powerful design and code components for your app',
96-
},
97-
{
98-
title: 'Design System in Figma',
99-
subtitle: '10 sections',
100-
image: require('./assets/background6.jpg'),
101-
logo: require('./assets/logo-figma.png'),
102-
author: 'Meng To',
103-
avatar: require('./assets/avatar.jpg'),
104-
caption: 'Complete guide to designing a site using a collaborative design tool',
105-
},
106-
];
22+
const store = createStore(reducer);
10723

10824
export default function App() {
10925
return (
110-
<Container>
111-
<Menu />
112-
<SafeAreaView>
113-
<ScrollView style={{ height: '100%' }}>
114-
<TitleBar>
115-
<Avatar source={{ uri: 'https://avatars3.githubusercontent.com/u/14251143?v=4' }} />
116-
<Title>Welcome Back, </Title>
117-
<Name>Luke</Name>
118-
<Icon.Ionicons
119-
name="ios-notifications"
120-
size={32}
121-
color="#4775f2"
122-
style={{ position: 'absolute', top: 5, right: 20 }}
123-
/>
124-
</TitleBar>
125-
<ScrollView
126-
horizontal
127-
showsHorizontalScrollIndicator={false}
128-
contentContainerStyle={{ paddingRight: 20, paddingBottom: 20, paddingTop: 30, paddingLeft: 12 }}
129-
>
130-
{logos.map(logo => (
131-
<Logo key={logo.text} image={logo.image} text={logo.text} />
132-
))}
133-
</ScrollView>
134-
<Subtitle>Continue Learning</Subtitle>
135-
<ScrollView
136-
horizontal
137-
showsHorizontalScrollIndicator={false}
138-
contentContainerStyle={{ paddingRight: 20, paddingBottom: 30, paddingTop: 30 }}
139-
>
140-
{cards.map(card => (
141-
<Card
142-
key={card.title}
143-
title={card.title}
144-
hero={card.image}
145-
logo={card.logo}
146-
caption={card.caption}
147-
subtitle={card.subtitle}
148-
/>
149-
))}
150-
</ScrollView>
151-
<Subtitle>Popular Courses</Subtitle>
152-
{courses.map(course => (
153-
<Course
154-
key={course.title}
155-
hero={course.image}
156-
logo={course.logo}
157-
subtitle={course.subtitle}
158-
title={course.title}
159-
avatar={course.avatar}
160-
caption={course.caption}
161-
author={course.author}
162-
/>
163-
))}
164-
</ScrollView>
165-
</SafeAreaView>
166-
</Container>
26+
<Provider store={store}>
27+
<HomeScreen />
28+
</Provider>
16729
);
16830
}
169-
170-
const Container = styled.View`
171-
flex: 1;
172-
background: #f0f3f5;
173-
`;
174-
175-
const TitleBar = styled.View`
176-
width: 100%;
177-
margin: 50px 0 0;
178-
padding: 0 0 0 80px;
179-
`;
180-
181-
const Avatar = styled.Image`
182-
width: 44px;
183-
height: 44px;
184-
background: #3c4560;
185-
border-radius: 22px;
186-
margin: 0 0 0 20px;
187-
position: absolute;
188-
top: 0;
189-
left: 0;
190-
`;
191-
192-
const Title = styled.Text`
193-
font-size: 16px;
194-
color: #b8bece;
195-
font-weight: 500;
196-
`;
197-
198-
const Name = styled.Text`
199-
font-size: 20px;
200-
color: #3c4560;
201-
font-weight: bold;
202-
`;
203-
204-
const Subtitle = styled.Text`
205-
color: #b8bece;
206-
font-weight: 600;
207-
font-size: 15px;
208-
margin: 20px 0 0 20px;
209-
text-transform: uppercase;
210-
`;

app.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"platforms": ["ios", "android", "web"],
88
"version": "1.0.0",
99
"orientation": "portrait",
10-
"icon": "./assets/icon.png",
10+
"icon": "src/assets/icon.png",
1111
"splash": {
12-
"image": "./assets/splash.png",
12+
"image": "src/assets/splash.png",
1313
"resizeMode": "contain",
1414
"backgroundColor": "#f0f3f5"
1515
},
@@ -19,9 +19,6 @@
1919
"assetBundlePatterns": ["**/*"],
2020
"ios": {
2121
"supportsTablet": true
22-
},
23-
"androidStatusBar": {
24-
"barStyle": "dark-content"
2522
}
2623
}
2724
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/components/Menu/Menu.js

+38-16
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, { useState, useEffect, useCallback } from 'react';
2+
import { connect } from 'react-redux';
23
import styled from 'styled-components/native';
34
import { Animated, TouchableOpacity, Dimensions } from 'react-native';
45
import * as Icon from '@expo/vector-icons';
56

67
import MenuOption from '../MenuOption';
78

8-
const screenHeight = Dimensions.get('window').height;
9+
const screenHeight = Dimensions.get('window').height + 100;
910

1011
const items = [
1112
{
@@ -30,30 +31,36 @@ const items = [
3031
},
3132
];
3233

33-
export default function Menu() {
34-
const [top, setTop] = useState(new Animated.Value(screenHeight));
34+
function Menu({ action, closeMenu }) {
35+
const [top] = useState(new Animated.Value(screenHeight));
3536

36-
useEffect(() => {
37-
Animated.spring(top, {
38-
toValue: 0,
39-
}).start();
40-
}, [top]);
37+
const toggleMenu = useCallback(() => {
38+
if (action === 'openMenu') {
39+
Animated.spring(top, {
40+
toValue: 68,
41+
}).start();
42+
}
43+
44+
if (action == 'closeMenu') {
45+
Animated.spring(top, {
46+
toValue: screenHeight,
47+
}).start();
48+
}
49+
}, [action, top]);
4150

42-
function toggleMenu() {
43-
Animated.spring(top, {
44-
toValue: screenHeight + 100,
45-
}).start();
46-
}
51+
useEffect(() => {
52+
toggleMenu();
53+
}, [action, toggleMenu]);
4754

4855
return (
4956
<AnimatedContainer style={{ top }}>
5057
<Cover>
51-
<Image source={require('../../../assets/background2.jpg')} />
58+
<Image source={require('~/assets/background2.jpg')} />
5259
<Title>Luke Morales</Title>
5360
<Subtitle>Your Next React Native Developer</Subtitle>
5461
</Cover>
5562
<TouchableOpacity
56-
onPress={() => toggleMenu()}
63+
onPress={closeMenu}
5764
style={{
5865
position: 'absolute',
5966
top: 120,
@@ -75,12 +82,27 @@ export default function Menu() {
7582
);
7683
}
7784

85+
const mapStateToProps = state => ({ action: state.action });
86+
87+
const mapDispatchToProps = dispatch => ({
88+
closeMenu: () =>
89+
dispatch({
90+
type: 'CLOSE_MENU',
91+
}),
92+
});
93+
export default connect(
94+
mapStateToProps,
95+
mapDispatchToProps
96+
)(Menu);
97+
7898
const Container = styled.View`
7999
position: absolute;
80100
background: white;
81101
width: 100%;
82102
height: 100%;
83103
z-index: 100;
104+
border-radius: 10px;
105+
overflow: hidden;
84106
`;
85107

86108
const AnimatedContainer = Animated.createAnimatedComponent(Container);

0 commit comments

Comments
 (0)