Skip to content

Commit 9ee2cb0

Browse files
authored
Merge branch 'master' into refactor-get-user
2 parents c28ac6c + 3ec1934 commit 9ee2cb0

24 files changed

+1123
-351
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,15 @@
384384
]
385385
},
386386
{
387+
"login": "brandly",
388+
"name": "Matthew Brandly",
389+
"avatar_url": "https://avatars3.githubusercontent.com/u/820696?v=4",
390+
"profile": "http://words.brandly.me/about/",
391+
"contributions": [
392+
"code"
393+
]
394+
},
395+
{
387396
"login": "Jpfonseca",
388397
"name": "João Fonseca",
389398
"avatar_url": "https://avatars2.githubusercontent.com/u/11836470?v=4",
File renamed without changes.

commitlint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
extends: ['./commitlint/'],
2+
extends: ['./.commitlint/'],
33
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"react-native": "0.48.1",
6262
"react-native-actionsheet": "^2.2.0",
6363
"react-native-code-push": "^5.0.0-beta",
64+
"react-native-collapsible": "^0.9.0",
6465
"react-native-communications": "^2.2.1",
6566
"react-native-config": "^0.6.0",
6667
"react-native-cookies": "^3.2.0",
@@ -73,6 +74,7 @@
7374
"react-native-photo-view": "^1.5.2",
7475
"react-native-safari-view": "^2.0.0",
7576
"react-native-search-bar": "^3.0.0",
77+
"react-native-swiper": "^1.5.13",
7678
"react-native-syntax-highlighter": "^1.2.1",
7779
"react-native-table-component": "^1.0.5",
7880
"react-native-vector-icons": "^4.4.0",
@@ -87,7 +89,6 @@
8789
"redux-persist-transform-encrypt": "^1.0.2",
8890
"redux-thunk": "^2.2.0",
8991
"reselect": "^3.0.1",
90-
"rn-app-intro": "^0.0.4",
9192
"styled-components": "^2.2.1"
9293
},
9394
"devDependencies": {

src/api/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,14 @@ export const fetchNotificationsCount = accessToken =>
379379

380380
export const fetchRepoNotificationsCount = (owner, repoName, accessToken) =>
381381
v3.count(`/repos/${owner}/${repoName}/notifications?per_page=1`, accessToken);
382+
383+
export const fetchIssueEvents = (
384+
owner: string,
385+
repoName: string,
386+
issueNum: number,
387+
accessToken: string
388+
) =>
389+
v3.getJson(
390+
`/repos/${owner}/${repoName}/issues/${issueNum}/events`,
391+
accessToken
392+
);

src/auth/screens/language-settings.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,9 @@ export default [
5454
emojiCode: ':flag-de:',
5555
name: 'Deutsch',
5656
},
57+
{
58+
code: 'es',
59+
emojiCode: ':flag-es:',
60+
name: 'Español',
61+
},
5762
];

src/auth/screens/login.screen.js

Lines changed: 126 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ import {
1414
Modal,
1515
} from 'react-native';
1616
import { Button, Icon } from 'react-native-elements';
17-
import AppIntro from 'rn-app-intro';
17+
import Swiper from 'react-native-swiper';
1818
import queryString from 'query-string';
19+
import CookieManager from 'react-native-cookies';
1920

2021
import { ViewContainer } from 'components';
2122
import { colors, fonts, normalize } from 'config';
2223
import { CLIENT_ID } from 'api';
2324
import { auth, getUser } from 'auth';
2425
import { translate, resetNavigationTo } from 'utils';
2526

26-
const stateRandom = Math.random().toString();
27+
let stateRandom = Math.random().toString();
2728

2829
const mapStateToProps = state => ({
2930
locale: state.auth.locale,
@@ -101,6 +102,14 @@ const styles = StyleSheet.create({
101102
justifyContent: 'center',
102103
alignItems: 'center',
103104
},
105+
signInContainer: {
106+
position: 'absolute',
107+
right: 0,
108+
left: 0,
109+
bottom: 80,
110+
justifyContent: 'center',
111+
alignItems: 'center',
112+
},
104113
slide: {
105114
flex: 1,
106115
justifyContent: 'center',
@@ -218,15 +227,25 @@ class Login extends Component {
218227
loaderText: translate('auth.login.preparingGitPoint', this.locale),
219228
});
220229

221-
auth(code, state).then(() => {
222-
getUser().then(() => {
223-
resetNavigationTo('Main', navigation);
230+
stateRandom = Math.random().toString();
231+
232+
CookieManager.clearAll().then(() => {
233+
auth(code, state).then(() => {
234+
getUser().then(() => {
235+
resetNavigationTo('Main', navigation);
236+
});
224237
});
225238
});
226239
}
227240
}
228241
};
229242

243+
shouldDisplayIntro() {
244+
const { isLoggingIn, isAuthenticated } = this.props;
245+
246+
return !isAuthenticated && !isLoggingIn && this.state.asyncStorageChecked;
247+
}
248+
230249
renderLoading() {
231250
return (
232251
<View style={styles.browserLoader}>
@@ -241,126 +260,116 @@ class Login extends Component {
241260

242261
return (
243262
<ViewContainer barColor="light">
244-
{!isAuthenticated &&
245-
!isLoggingIn &&
246-
this.state.asyncStorageChecked && (
247-
<View style={styles.container}>
248-
<Modal
249-
animationType="slide"
250-
onRequestClose={() => null}
251-
visible={this.state.modalVisible}
252-
style={styles.container}
253-
>
254-
<View style={styles.modalContainer}>
255-
<View style={styles.browserSection}>
256-
<WebView
257-
source={{
258-
uri: `https://github.com/login/oauth/authorize?response_type=token&client_id=${CLIENT_ID}&redirect_uri=gitpoint://welcome&scope=user%20repo&state=${stateRandom}`,
259-
}}
260-
onLoadStart={e => this.toggleCancelButton(e, true)}
261-
onLoadEnd={e => this.toggleCancelButton(e, false)}
262-
onNavigationStateChange={e =>
263-
this.onNavigationStateChange(e)}
264-
renderLoading={() => this.renderLoading()}
265-
startInLoadingState
266-
/>
267-
</View>
268-
<View style={styles.miniSection}>
269-
<Button
270-
title={translate('auth.login.cancel', locale)}
271-
buttonStyle={styles.button}
272-
disabled={this.state.cancelDisabled}
273-
textStyle={styles.buttonText}
274-
onPress={() =>
275-
this.setModalVisible(!this.state.modalVisible)}
276-
/>
277-
</View>
278-
</View>
279-
</Modal>
280-
<View style={styles.miniSection}>
281-
<Image
282-
style={styles.logo}
283-
source={require('../../assets/logo.png')}
263+
{this.shouldDisplayIntro() && (
264+
<Swiper
265+
loop={false}
266+
dotColor="#FFFFFF55"
267+
activeDotColor={colors.white}
268+
>
269+
<View style={[styles.slide, styles.slide1]}>
270+
<Image
271+
style={styles.logo}
272+
source={require('../../assets/logo.png')}
273+
/>
274+
<Text style={styles.title}>
275+
{translate('auth.login.welcomeTitle', locale)}
276+
</Text>
277+
<Text style={styles.message}>
278+
{translate('auth.login.welcomeMessage', locale)}
279+
</Text>
280+
</View>
281+
<View style={[styles.slide, styles.slide2]}>
282+
<Icon
283+
style={styles.icon}
284+
color={colors.white}
285+
size={85}
286+
name="bell"
287+
type="octicon"
288+
/>
289+
<Text style={styles.title}>
290+
{translate('auth.login.notificationsTitle', locale)}
291+
</Text>
292+
<Text style={styles.message}>
293+
{translate('auth.login.notificationsMessage', locale)}
294+
</Text>
295+
</View>
296+
<View style={[styles.slide, styles.slide3]}>
297+
<Icon
298+
containerStyle={styles.iconMargin}
299+
style={styles.icon}
300+
color={colors.white}
301+
size={85}
302+
name="repo"
303+
type="octicon"
304+
/>
305+
<Text style={styles.title}>
306+
{translate('auth.login.reposTitle', locale)}
307+
</Text>
308+
<Text style={styles.message}>
309+
{translate('auth.login.reposMessage', locale)}
310+
</Text>
311+
</View>
312+
<View style={[styles.slide, styles.slide4]}>
313+
<Icon
314+
containerStyle={styles.iconMargin}
315+
style={styles.icon}
316+
color={colors.white}
317+
size={85}
318+
name="git-pull-request"
319+
type="octicon"
320+
/>
321+
<Text style={styles.title}>
322+
{translate('auth.login.issuesTitle', locale)}
323+
</Text>
324+
<Text style={styles.message}>
325+
{translate('auth.login.issuesMessage', locale)}
326+
</Text>
327+
</View>
328+
</Swiper>
329+
)}
330+
{this.shouldDisplayIntro() && (
331+
<View style={styles.signInContainer}>
332+
<Button
333+
raised
334+
title={translate('auth.login.signInButton', locale)}
335+
buttonStyle={styles.button}
336+
textStyle={styles.buttonText}
337+
onPress={() => this.setModalVisible(true)}
338+
/>
339+
</View>
340+
)}
341+
{this.shouldDisplayIntro() && (
342+
<Modal
343+
animationType="slide"
344+
onRequestClose={() => null}
345+
visible={this.state.modalVisible}
346+
style={styles.container}
347+
>
348+
<View style={styles.modalContainer}>
349+
<View style={styles.browserSection}>
350+
<WebView
351+
source={{
352+
uri: `https://github.com/login/oauth/authorize?response_type=token&client_id=${CLIENT_ID}&redirect_uri=gitpoint://welcome&scope=user%20repo&state=${stateRandom}`,
353+
}}
354+
onLoadStart={e => this.toggleCancelButton(e, true)}
355+
onLoadEnd={e => this.toggleCancelButton(e, false)}
356+
onNavigationStateChange={e => this.onNavigationStateChange(e)}
357+
renderLoading={() => this.renderLoading()}
358+
startInLoadingState
284359
/>
285360
</View>
286-
<View style={styles.contentSection}>
287-
<AppIntro
288-
activeDotColor={colors.white}
289-
showSkipButton={false}
290-
showDoneButton={false}
291-
>
292-
<View style={[styles.slide, styles.slide1]}>
293-
<Image
294-
style={styles.logo}
295-
source={require('../../assets/logo.png')}
296-
/>
297-
<Text style={styles.title}>
298-
{translate('auth.login.welcomeTitle', locale)}
299-
</Text>
300-
<Text style={styles.message}>
301-
{translate('auth.login.welcomeMessage', locale)}
302-
</Text>
303-
</View>
304-
<View style={[styles.slide, styles.slide2]}>
305-
<Icon
306-
style={styles.icon}
307-
color={colors.white}
308-
size={85}
309-
name="bell"
310-
type="octicon"
311-
/>
312-
<Text style={styles.title}>
313-
{translate('auth.login.notificationsTitle', locale)}
314-
</Text>
315-
<Text style={styles.message}>
316-
{translate('auth.login.notificationsMessage', locale)}
317-
</Text>
318-
</View>
319-
<View style={[styles.slide, styles.slide3]}>
320-
<Icon
321-
containerStyle={styles.iconMargin}
322-
style={styles.icon}
323-
color={colors.white}
324-
size={85}
325-
name="repo"
326-
type="octicon"
327-
/>
328-
<Text style={styles.title}>
329-
{translate('auth.login.reposTitle', locale)}
330-
</Text>
331-
<Text style={styles.message}>
332-
{translate('auth.login.reposMessage', locale)}
333-
</Text>
334-
</View>
335-
<View style={[styles.slide, styles.slide4]}>
336-
<Icon
337-
containerStyle={styles.iconMargin}
338-
style={styles.icon}
339-
color={colors.white}
340-
size={85}
341-
name="git-pull-request"
342-
type="octicon"
343-
/>
344-
<Text style={styles.title}>
345-
{translate('auth.login.issuesTitle', locale)}
346-
</Text>
347-
<Text style={styles.message}>
348-
{translate('auth.login.issuesMessage', locale)}
349-
</Text>
350-
</View>
351-
</AppIntro>
352-
</View>
353361
<View style={styles.miniSection}>
354362
<Button
355-
raised
356-
title={translate('auth.login.signInButton', locale)}
363+
title={translate('auth.login.cancel', locale)}
357364
buttonStyle={styles.button}
365+
disabled={this.state.cancelDisabled}
358366
textStyle={styles.buttonText}
359-
onPress={() => this.setModalVisible(true)}
367+
onPress={() => this.setModalVisible(!this.state.modalVisible)}
360368
/>
361369
</View>
362370
</View>
363-
)}
371+
</Modal>
372+
)}
364373
{isLoggingIn &&
365374
!hasInitialUser && (
366375
<View style={styles.browserLoader}>
@@ -373,7 +382,7 @@ class Login extends Component {
373382
size="large"
374383
/>
375384
</View>
376-
)}
385+
)}
377386
</ViewContainer>
378387
);
379388
}

0 commit comments

Comments
 (0)