-
Notifications
You must be signed in to change notification settings - Fork 783
refactor: Drop rn-app-intro in favor of react-native-swiper #493
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ import { | |
Modal, | ||
} from 'react-native'; | ||
import { Button, Icon } from 'react-native-elements'; | ||
import AppIntro from 'rn-app-intro'; | ||
import Swiper from 'react-native-swiper'; | ||
import queryString from 'query-string'; | ||
|
||
import { ViewContainer } from 'components'; | ||
|
@@ -99,6 +99,14 @@ const styles = StyleSheet.create({ | |
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
signInContainer: { | ||
position: 'absolute', | ||
right: 0, | ||
left: 0, | ||
bottom: 80, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
slide: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
|
@@ -219,6 +227,12 @@ class Login extends Component { | |
} | ||
}; | ||
|
||
shouldDisplayIntro() { | ||
const { isLoggingIn, isAuthenticated } = this.props; | ||
|
||
return !isAuthenticated && !isLoggingIn && this.state.asyncStorageChecked; | ||
} | ||
|
||
renderLoading() { | ||
return ( | ||
<View style={styles.browserLoader}> | ||
|
@@ -229,130 +243,120 @@ class Login extends Component { | |
} | ||
|
||
render() { | ||
const { locale, isLoggingIn, isAuthenticated } = this.props; | ||
const { locale, isLoggingIn } = this.props; | ||
|
||
return ( | ||
<ViewContainer barColor="light"> | ||
{!isAuthenticated && | ||
!isLoggingIn && | ||
this.state.asyncStorageChecked && ( | ||
<View style={styles.container}> | ||
<Modal | ||
animationType="slide" | ||
onRequestClose={() => null} | ||
visible={this.state.modalVisible} | ||
style={styles.container} | ||
> | ||
<View style={styles.modalContainer}> | ||
<View style={styles.browserSection}> | ||
<WebView | ||
source={{ | ||
uri: `https://github.com/login/oauth/authorize?response_type=token&client_id=${CLIENT_ID}&redirect_uri=gitpoint://welcome&scope=user%20repo&state=${stateRandom}`, | ||
}} | ||
onLoadStart={e => this.toggleCancelButton(e, true)} | ||
onLoadEnd={e => this.toggleCancelButton(e, false)} | ||
onNavigationStateChange={e => | ||
this.onNavigationStateChange(e)} | ||
renderLoading={() => this.renderLoading()} | ||
startInLoadingState | ||
/> | ||
</View> | ||
<View style={styles.miniSection}> | ||
<Button | ||
title={translate('auth.login.cancel', locale)} | ||
buttonStyle={styles.button} | ||
disabled={this.state.cancelDisabled} | ||
textStyle={styles.buttonText} | ||
onPress={() => | ||
this.setModalVisible(!this.state.modalVisible)} | ||
/> | ||
</View> | ||
</View> | ||
</Modal> | ||
<View style={styles.miniSection}> | ||
<Image | ||
style={styles.logo} | ||
source={require('../../assets/logo.png')} | ||
{this.shouldDisplayIntro() && ( | ||
<Swiper | ||
loop={false} | ||
dotColor="#FFFFFF55" | ||
activeDotColor={colors.white} | ||
> | ||
<View style={[styles.slide, styles.slide1]}> | ||
<Image | ||
style={styles.logo} | ||
source={require('../../assets/logo.png')} | ||
/> | ||
<Text style={styles.title}> | ||
{translate('auth.login.welcomeTitle', locale)} | ||
</Text> | ||
<Text style={styles.message}> | ||
{translate('auth.login.welcomeMessage', locale)} | ||
</Text> | ||
</View> | ||
<View style={[styles.slide, styles.slide2]}> | ||
<Icon | ||
style={styles.icon} | ||
color={colors.white} | ||
size={85} | ||
name="bell" | ||
type="octicon" | ||
/> | ||
<Text style={styles.title}> | ||
{translate('auth.login.notificationsTitle', locale)} | ||
</Text> | ||
<Text style={styles.message}> | ||
{translate('auth.login.notificationsMessage', locale)} | ||
</Text> | ||
</View> | ||
<View style={[styles.slide, styles.slide3]}> | ||
<Icon | ||
containerStyle={styles.iconMargin} | ||
style={styles.icon} | ||
color={colors.white} | ||
size={85} | ||
name="repo" | ||
type="octicon" | ||
/> | ||
<Text style={styles.title}> | ||
{translate('auth.login.reposTitle', locale)} | ||
</Text> | ||
<Text style={styles.message}> | ||
{translate('auth.login.reposMessage', locale)} | ||
</Text> | ||
</View> | ||
<View style={[styles.slide, styles.slide4]}> | ||
<Icon | ||
containerStyle={styles.iconMargin} | ||
style={styles.icon} | ||
color={colors.white} | ||
size={85} | ||
name="git-pull-request" | ||
type="octicon" | ||
/> | ||
<Text style={styles.title}> | ||
{translate('auth.login.issuesTitle', locale)} | ||
</Text> | ||
<Text style={styles.message}> | ||
{translate('auth.login.issuesMessage', locale)} | ||
</Text> | ||
</View> | ||
</Swiper> | ||
)} | ||
{this.shouldDisplayIntro() && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this check? Can we combine into one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We sadly cannot, |
||
<View style={styles.signInContainer}> | ||
<Button | ||
raised | ||
title={translate('auth.login.signInButton', locale)} | ||
buttonStyle={styles.button} | ||
textStyle={styles.buttonText} | ||
onPress={() => this.setModalVisible(true)} | ||
/> | ||
</View> | ||
)} | ||
{this.shouldDisplayIntro() && ( | ||
<Modal | ||
animationType="slide" | ||
onRequestClose={() => null} | ||
visible={this.state.modalVisible} | ||
style={styles.container} | ||
> | ||
<View style={styles.modalContainer}> | ||
<View style={styles.browserSection}> | ||
<WebView | ||
source={{ | ||
uri: `https://github.com/login/oauth/authorize?response_type=token&client_id=${CLIENT_ID}&redirect_uri=gitpoint://welcome&scope=user%20repo&state=${stateRandom}`, | ||
}} | ||
onLoadStart={e => this.toggleCancelButton(e, true)} | ||
onLoadEnd={e => this.toggleCancelButton(e, false)} | ||
onNavigationStateChange={e => this.onNavigationStateChange(e)} | ||
renderLoading={() => this.renderLoading()} | ||
startInLoadingState | ||
/> | ||
</View> | ||
<View style={styles.contentSection}> | ||
<AppIntro | ||
activeDotColor={colors.white} | ||
showSkipButton={false} | ||
showDoneButton={false} | ||
> | ||
<View style={[styles.slide, styles.slide1]}> | ||
<Image | ||
style={styles.logo} | ||
source={require('../../assets/logo.png')} | ||
/> | ||
<Text style={styles.title}> | ||
{translate('auth.login.welcomeTitle', locale)} | ||
</Text> | ||
<Text style={styles.message}> | ||
{translate('auth.login.welcomeMessage', locale)} | ||
</Text> | ||
</View> | ||
<View style={[styles.slide, styles.slide2]}> | ||
<Icon | ||
style={styles.icon} | ||
color={colors.white} | ||
size={85} | ||
name="bell" | ||
type="octicon" | ||
/> | ||
<Text style={styles.title}> | ||
{translate('auth.login.notificationsTitle', locale)} | ||
</Text> | ||
<Text style={styles.message}> | ||
{translate('auth.login.notificationsMessage', locale)} | ||
</Text> | ||
</View> | ||
<View style={[styles.slide, styles.slide3]}> | ||
<Icon | ||
containerStyle={styles.iconMargin} | ||
style={styles.icon} | ||
color={colors.white} | ||
size={85} | ||
name="repo" | ||
type="octicon" | ||
/> | ||
<Text style={styles.title}> | ||
{translate('auth.login.reposTitle', locale)} | ||
</Text> | ||
<Text style={styles.message}> | ||
{translate('auth.login.reposMessage', locale)} | ||
</Text> | ||
</View> | ||
<View style={[styles.slide, styles.slide4]}> | ||
<Icon | ||
containerStyle={styles.iconMargin} | ||
style={styles.icon} | ||
color={colors.white} | ||
size={85} | ||
name="git-pull-request" | ||
type="octicon" | ||
/> | ||
<Text style={styles.title}> | ||
{translate('auth.login.issuesTitle', locale)} | ||
</Text> | ||
<Text style={styles.message}> | ||
{translate('auth.login.issuesMessage', locale)} | ||
</Text> | ||
</View> | ||
</AppIntro> | ||
</View> | ||
<View style={styles.miniSection}> | ||
<Button | ||
raised | ||
title={translate('auth.login.signInButton', locale)} | ||
title={translate('auth.login.cancel', locale)} | ||
buttonStyle={styles.button} | ||
disabled={this.state.cancelDisabled} | ||
textStyle={styles.buttonText} | ||
onPress={() => this.setModalVisible(true)} | ||
onPress={() => this.setModalVisible(!this.state.modalVisible)} | ||
/> | ||
</View> | ||
</View> | ||
)} | ||
</Modal> | ||
)} | ||
{isLoggingIn && ( | ||
<View style={styles.browserLoader}> | ||
<Text style={styles.browserLoadingLabel}> | ||
|
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.
How about moving the code to a separate component, such as
Intro
?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.
I'm not sure about this, it would be used only for the login screen (+comment below)