-
Notifications
You must be signed in to change notification settings - Fork 34
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
BilalBudhani
merged 28 commits into
hummingbird-me:master
from
edencakir:new-registration-screen
Sep 22, 2017
Merged
Changes from 21 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
a3bb6c9
profile fix
edencakir 7d18246
Merge branch 'master' of https://github.com/hummingbird-me/kitsu-mobile
edencakir 8dd7bbb
Remove nativebase & use native modules & implement new design
edencakir a2bd1d8
logo alignment
edencakir bd64a31
remove unused imports
edencakir 115d235
Merge branch 'master' of https://github.com/hummingbird-me/kitsu-mobile
edencakir 1b0162f
code cleaned & onboarding rework & registration screen initial work
edencakir 901ed66
registration screen styles and routing
edencakir 77cf25f
font size fix
edencakir cf833cd
Button component and implementation
edencakir 0fa0e47
UI improvements
edencakir 62602df
Merge branch 'master' of https://github.com/hummingbird-me/kitsu-mobile
edencakir 05dd77b
Merge branch 'master' of https://github.com/hummingbird-me/kitsu-mobile
edencakir 43bcc25
merge conflicts resolved
edencakir 8681d3d
fb login implemented
edencakir 83d71af
animated gallery
edencakir 38f024f
placeholder image while loading
edencakir 1361647
fixes crash on fb login
edencakir 93229f1
Merge branch 'master' of https://github.com/edencakir/kitsu-mobile in…
edencakir 5c4e40f
resolved conflicts
edencakir 412c903
resolved conflicts
edencakir 661acca
fix resolving conflicts
edencakir e6ab2e4
handle fb cancel loading indicator status
edencakir 2f8245a
Merge branch 'master' into new-registration-screen
edencakir 3f047eb
resolved conflicts
edencakir 6e0f3eb
Merge branch 'new-registration-screen' of https://github.com/edencaki…
edencakir 7edd3b4
hide android bars
edencakir 3037815
updated code comment
edencakir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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, | ||
}; |
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 @@ | ||
export * from './component'; |
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,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, | ||
}, | ||
}); |
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 |
---|---|---|
@@ -1,99 +1,143 @@ | ||
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: use | ||
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'); | ||
} | ||
}, | ||
(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 ( | ||
<View 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} | ||
<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} | ||
/> | ||
<FlatList | ||
ref={ref => this.mangaList = ref} | ||
horizontal | ||
scrollEnabled={false} | ||
style={{ marginTop: 8 }} | ||
data={topManga} | ||
renderItem={this.renderItem} | ||
onEndReached={() => this.populateList('topManga')} | ||
onEndReachedThreshold={0.5} | ||
/> | ||
<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> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
export default connect(null, { loginUser })(RegistrationScreen); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edencakir you missed resolving a conflict here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thanks for the heads up. I'm not sure how I missed that.