Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Registration Screen #53

Merged
merged 28 commits into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a3bb6c9
profile fix
edencakir Sep 3, 2017
7d18246
Merge branch 'master' of https://github.com/hummingbird-me/kitsu-mobile
edencakir Sep 5, 2017
8dd7bbb
Remove nativebase & use native modules & implement new design
edencakir Sep 6, 2017
a2bd1d8
logo alignment
edencakir Sep 6, 2017
bd64a31
remove unused imports
edencakir Sep 6, 2017
115d235
Merge branch 'master' of https://github.com/hummingbird-me/kitsu-mobile
edencakir Sep 9, 2017
1b0162f
code cleaned & onboarding rework & registration screen initial work
edencakir Sep 9, 2017
901ed66
registration screen styles and routing
edencakir Sep 9, 2017
77cf25f
font size fix
edencakir Sep 9, 2017
cf833cd
Button component and implementation
edencakir Sep 10, 2017
0fa0e47
UI improvements
edencakir Sep 10, 2017
62602df
Merge branch 'master' of https://github.com/hummingbird-me/kitsu-mobile
edencakir Sep 10, 2017
05dd77b
Merge branch 'master' of https://github.com/hummingbird-me/kitsu-mobile
edencakir Sep 12, 2017
43bcc25
merge conflicts resolved
edencakir Sep 13, 2017
8681d3d
fb login implemented
edencakir Sep 13, 2017
83d71af
animated gallery
edencakir Sep 14, 2017
38f024f
placeholder image while loading
edencakir Sep 14, 2017
1361647
fixes crash on fb login
edencakir Sep 14, 2017
93229f1
Merge branch 'master' of https://github.com/edencakir/kitsu-mobile in…
edencakir Sep 15, 2017
5c4e40f
resolved conflicts
edencakir Sep 15, 2017
412c903
resolved conflicts
edencakir Sep 15, 2017
661acca
fix resolving conflicts
edencakir Sep 20, 2017
e6ab2e4
handle fb cancel loading indicator status
edencakir Sep 20, 2017
2f8245a
Merge branch 'master' into new-registration-screen
edencakir Sep 21, 2017
3f047eb
resolved conflicts
edencakir Sep 21, 2017
6e0f3eb
Merge branch 'new-registration-screen' of https://github.com/edencaki…
edencakir Sep 21, 2017
7edd3b4
hide android bars
edencakir Sep 21, 2017
3037815
updated code comment
edencakir Sep 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ios/kitsu_mobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
};
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
Expand Down
2 changes: 2 additions & 0 deletions src/assets/img/onboarding/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import intro1 from './intro1.png';
import intro2 from './intro2.png';
import intro3 from './intro3.png';
import intro4 from './intro4.png';
import placeholderImage from './placeholderImage.png';

export {
intro1,
intro2,
intro3,
intro4,
placeholderImage,
};
Binary file added src/assets/img/onboarding/placeholderImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions src/components/Button/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react';
import { View, TouchableOpacity, Text, ActivityIndicator, ViewPropTypes } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import { PropTypes } from 'prop-types';
import { styles } from './styles';

const LoadingComponent = () => (
<View style={styles.contentWrapper}>
<ActivityIndicator color={'rgba(255,255,255,0.6)'} />
</View>
);

export const Button = ({
style,
title,
titleStyle,
icon,
iconStyle,
onPress,
loading,
disabled,
}) => (
<TouchableOpacity
disabled={disabled || loading}
onPress={onPress}
style={[styles.button, disabled ? styles.buttonDisabled : null, style]}
>
{loading ? <LoadingComponent />
: <View style={styles.contentWrapper}>
{icon ? <Icon name={icon} style={[styles.icon, iconStyle]} /> : null}
<Text style={[styles.title, titleStyle]}>
{title}
</Text>
</View>
}
</TouchableOpacity>
);

Button.propTypes = {
...TouchableOpacity.propTypes,
style: ViewPropTypes.style,
title: PropTypes.string.isRequired,
titleStyle: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
icon: PropTypes.string,
iconStyle: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
onPress: PropTypes.func.isRequired,
loading: PropTypes.bool,
disabled: PropTypes.bool,
};
Button.defaultProps = {
style: null,
title: 'Save',
titleStyle: null,
icon: null,
iconStyle: null,
loading: false,
disabled: false,
};
1 change: 1 addition & 0 deletions src/components/Button/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './component';
33 changes: 33 additions & 0 deletions src/components/Button/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { StyleSheet } from 'react-native';
import * as colors from 'kitsu/constants/colors';

export const styles = StyleSheet.create({
button: {
marginVertical: 4,
marginHorizontal: 16,
backgroundColor: colors.green,
height: 47,
borderRadius: 4,
},
buttonDisabled: {
backgroundColor: colors.buttonDisabledColor,
},
contentWrapper: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
title: {
color: colors.white,
fontFamily: 'OpenSans',
lineHeight: 25,
fontSize: 15,
},
icon: {
fontSize: 20,
color: colors.white,
paddingRight: 8,
paddingLeft: 8,
},
});
1 change: 1 addition & 0 deletions src/constants/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const offBlack = '#2B212B';
export const softBlack = '#333';

/* misc */
export const transparent = 'transparent';
export const buttonDisabledColor = '#878787';
export const imageBackColor = 'rgb(153, 130, 153)';
export const listSeparatorColor = '#261C25';
Expand Down
44 changes: 23 additions & 21 deletions src/screens/Onboarding/OnboardingScreen.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { View, Text, TouchableOpacity, ScrollView, Dimensions } from 'react-native';
import { View, ScrollView, Dimensions } from 'react-native';
import { intro1, intro2, intro3, intro4 } from 'kitsu/assets/img/onboarding/';
import { Button } from 'kitsu/components/Button';
import { OnboardingHeader } from './common/';
import styles from './styles';
import Step from './Step';
Expand Down Expand Up @@ -66,31 +67,32 @@ export default class OnboardingScreen extends React.Component {

return (
<View style={styles.container}>
<View style={styles.contentWrapper}>
<OnboardingHeader />
<View style={styles.pageWrapper}>
<View style={styles.page}>
<ScrollView
pagingEnabled
horizontal
showsHorizontalScrollIndicator={false}
alwaysBounceHorizontal={false}
onScroll={this.handleScroll}
scrollEventThrottle={300} // decrease for precision, lower values trigger onScroll more.
>
{this.renderStep()}
</ScrollView>
</View>
<OnboardingHeader style={styles.header} />
<View style={{ flex: 8 }}>
<View style={styles.page}>
<ScrollView
pagingEnabled
horizontal
showsHorizontalScrollIndicator={false}
alwaysBounceHorizontal={false}
onScroll={this.handleScroll}
scrollEventThrottle={300} // decrease for precision, lower values trigger onScroll more.
>
{this.renderStep()}
</ScrollView>
</View>
<View style={{ flex: 1, justifyContent: 'center' }}>
<View style={styles.dotContainer}>
{this.renderDots()}
</View>
<Button
style={styles.getStartedButton}
title={'Get Started'}
titleStyle={styles.getStartedText}
onPress={() => navigate('Registration')}
/>
</View>
</View>
<TouchableOpacity onPress={() => navigate('Registration')} style={styles.button}>
<Text style={styles.getStartedText}>
Get Started
</Text>
</TouchableOpacity>
</View>
);
}
Expand Down
174 changes: 111 additions & 63 deletions src/screens/Onboarding/RegistrationScreen.js
Original file line number Diff line number Diff line change
@@ -1,99 +1,147 @@
import React from 'react';
import { View, Text, Image, TouchableOpacity, ScrollView, Dimensions } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import { View, Image, FlatList } from 'react-native';
import { LoginManager } from 'react-native-fbsdk';
import { connect } from 'react-redux';
import { Button } from 'kitsu/components/Button';
import { loginUser } from 'kitsu/store/auth/actions';
import * as colors from 'kitsu/constants/colors';
import { placeholderImage } from 'kitsu/assets/img/onboarding';
import { OnboardingHeader } from './common/';
import styles from './styles';

const TEMP_IMG_URL = 'https://goo.gl/7XKV53';

const GalleryRow = () => (
<View style={{ marginVertical: 8, flexDirection: 'row', justifyContent: 'center' }}>
<Image source={{ uri: TEMP_IMG_URL }} style={styles.squareImage} />
<Image source={{ uri: TEMP_IMG_URL }} style={styles.squareImage} />
<Image source={{ uri: TEMP_IMG_URL }} style={styles.squareImage} />
<Image source={{ uri: TEMP_IMG_URL }} style={styles.squareImage} />
</View>
);

export default class RegistrationScreen extends React.Component {
class RegistrationScreen extends React.Component {
static navigationOptions = {
header: null,
};

state = {
loggingUser: false,
topAnime: Array(10).fill({}),
topManga: Array(10).fill({}),
};

onSucess = () => {
// TODO: implement this function.
componentDidMount() {
this.fetchTopMedia();
}

componentWillUnmount() {
clearInterval(this.animation);
}

animation = 0;

fetchTopMedia = async () => {
// TODO: handle network error.
try {
const topAnime = await fetch('https://kitsu.io/api/edge/trending/anime?limit=10').then(res => res.json());
const topManga = await fetch('https://kitsu.io/api/edge/trending/manga?limit=10').then(res => res.json());
this.setState({
topAnime: topAnime.data,
topManga: topManga.data,
}, this.animateLists);
} catch (e) {
console.log(e);
}
}

animateLists = () => {
let offset = 4;
this.animation = setInterval(() => {
this.animeList.scrollToOffset({ offset, animated: true });
this.mangaList.scrollToOffset({ offset, animated: true });
offset += 4;
}, 120);
}

loginFacebook = () => {
this.setState({ loggingUser: true });
LoginManager.logInWithReadPermissions(['public_profile']).then(
(result) => {
if (!result.isCancelled) {
onSuccess(true);
this.props.loginUser(null, navigation, 'signup');
} else {
this.setState({ loggingUser: false });
}
},
(error) => {
this.setState({ loggingUser: false });
console.log(`Login fail with error: ${error}`);
},
);
};

populateList = (topList) => {
const list = this.state[topList];
this.setState({
[topList]: list.concat(list),
});
}

renderItem = ({ item }) => (
<Image source={(item.attributes && { uri: item.attributes.posterImage.large }) || placeholderImage} style={styles.squareImage} />
);

render() {
const { navigate } = this.props.navigation;
const { loggingUser, topAnime, topManga } = this.state;
// TODO: make this screen responsive.
return (
<ScrollView style={styles.container}>
<OnboardingHeader />
<View style={{ marginVertical: 24, justifyContent: 'center', }}>
<GalleryRow />
<GalleryRow />
</View>
<View style={{ height: 200, justifyContent: 'center' }}>
<TouchableOpacity
onPress={this.loginFacebook}
style={[styles.button, {
backgroundColor: colors.fbBlueDark,
}]}
disabled={false}
>
<Icon
size={20}
name="facebook-official"
style={styles.fbIcon}
<View style={styles.container}>
<OnboardingHeader style={styles.header} />
<View style={{ flex: 8 }}>
<View>
<FlatList
ref={ref => this.animeList = ref}
style={{ marginBottom: 8 }}
horizontal
inverted
scrollEnabled={false}
data={topAnime}
renderItem={this.renderItem}
onEndReached={() => this.populateList('topAnime')}
onEndReachedThreshold={0.5}
showsHorizontalScrollIndicator={false}
/>
<FlatList
ref={ref => this.mangaList = ref}
horizontal
scrollEnabled={false}
style={{ marginTop: 8 }}
data={topManga}
renderItem={this.renderItem}
onEndReached={() => this.populateList('topManga')}
onEndReachedThreshold={0.5}
showsHorizontalScrollIndicator={false}
/>
<Text style={styles.buttonText}>
Sign up with Facebook
</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => navigate('Signup')}
style={[styles.button, {
backgroundColor: 'transparent',
borderWidth: 1.5,
borderColor: colors.darkGrey,
}]}
>
<Text style={styles.buttonText}>Create an Account</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => navigate('Login')}
style={[styles.button, {
backgroundColor: 'transparent',
}]}
>
<Text style={[styles.buttonText, {
color: colors.lightGrey,
}]}
>
Already have an account?
</Text>
</TouchableOpacity>
</View>
<View style={styles.buttonsWrapper}>
<Button
style={{ backgroundColor: colors.fbBlueDark }}
title={'Sign up with Facebook'}
icon={'facebook-official'}
loading={loggingUser}
onPress={this.loginFacebook}
/>
<Button
style={{
backgroundColor: colors.transparent,
borderWidth: 1.5,
borderColor: colors.darkGrey,
}}
title={'Create an Account'}
onPress={() => navigate('Signup')}
/>
<Button
style={{ backgroundColor: colors.transparent }}
title={'Already have an account?'}
titleStyle={{ fontSize: 12, color: colors.lightGrey }}
onPress={() => navigate('Login')}
/>
</View>
</View>
</ScrollView>
</View>
);
}
}

export default connect(null, { loginUser })(RegistrationScreen);
Loading