-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from shoutem/release/2.3.0
Release/2.3.0
- Loading branch information
Showing
289 changed files
with
3,390 additions
and
2,292 deletions.
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
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,4 +1,4 @@ | ||
{ | ||
"name": "shoutem.about", | ||
"version": "2.2.2" | ||
"version": "2.3.0" | ||
} |
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,6 +1,6 @@ | ||
{ | ||
"name": "shoutem.analytics", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"private": true, | ||
"main": "index.js" | ||
} |
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,6 +1,6 @@ | ||
{ | ||
"name": "shoutem.analytics", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"private": true, | ||
"main": "index.js" | ||
} |
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,12 +1,13 @@ | ||
import React from 'react'; | ||
|
||
import { I18n } from 'shoutem.i18n'; | ||
|
||
import { EmptyStateView } from '@shoutem/ui'; | ||
|
||
const NO_SUBSCRIPTION_MESSAGE = 'This app is currently inactive. Please contact its developer for support!'; | ||
import { ext } from '../const'; | ||
|
||
export default function SubscriptionMissingScreen() { | ||
return ( | ||
<EmptyStateView icon="error" message={NO_SUBSCRIPTION_MESSAGE} styleName="wide-subtitle" /> | ||
<EmptyStateView icon="error" message={I18n.t(ext("noSubscriptionMessage"))} styleName="wide-subtitle" /> | ||
); | ||
} | ||
|
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
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,6 +1,6 @@ | ||
{ | ||
"name": "shoutem.application", | ||
"version": "2.2.4", | ||
"version": "2.3.0", | ||
"private": true, | ||
"main": "index.js" | ||
} |
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,9 +1,9 @@ | ||
{ | ||
"name": "audio", | ||
"title": "Audio", | ||
"version": "2.2.6", | ||
"version": "2.3.0", | ||
"description": "Track player components for other extensions to utilize. NOTE: Lock screen controls will not be visible in the preview.", | ||
"platform": "~2.2.2", | ||
"platform": "2.3.*", | ||
"icon": "server/assets/add-audio-image.png", | ||
"type": "system" | ||
} |
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,5 +1,5 @@ | ||
{ | ||
"name": "shoutem.audio", | ||
"version": "2.2.6", | ||
"version": "2.3.0", | ||
"description": "Track player components for other extensions to utilize." | ||
} |
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,191 @@ | ||
import React, { PureComponent } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { Alert } from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import _ from 'lodash'; | ||
import autoBind from 'auto-bind'; | ||
import appleAuth, { | ||
AppleButton, | ||
AppleAuthRequestOperation, | ||
AppleAuthRequestScope, | ||
AppleAuthCredentialState, | ||
} from '@invertase/react-native-apple-authentication'; | ||
import { connectStyle } from '@shoutem/theme'; | ||
import { View, Spinner } from '@shoutem/ui'; | ||
import { getExtensionSettings, getAppId } from 'shoutem.application'; | ||
import { I18n } from 'shoutem.i18n'; | ||
import { getUser, loginWithApple, registerWithApple } from '../redux'; | ||
import * as Storage from '../services/storage'; | ||
import { resolveAppleErrorMessage } from '../services/apple'; | ||
import { getErrorCode, resolveErrorMessage } from '../errorMessages'; | ||
import { ext } from '../const'; | ||
|
||
const APPLE_AUTH_OPTIONS = { | ||
requestedOperation: AppleAuthRequestOperation.LOGIN, | ||
requestedScopes: [ | ||
AppleAuthRequestScope.EMAIL, | ||
AppleAuthRequestScope.FULL_NAME, | ||
], | ||
}; | ||
const LOGIN_ERROR_TITLE = () => I18n.t(ext('loginFailedErrorTitle')); | ||
const UNEXPECTED_ERROR = () => | ||
I18n.t('shoutem.application.unexpectedErrorMessage'); | ||
|
||
function firstNameStorageKey() { | ||
return `app-${getAppId()}:${ext()}.firstName`; | ||
} | ||
|
||
function lastNameStorageKey() { | ||
return `app-${getAppId()}:${ext()}.lastName`; | ||
} | ||
|
||
class AppleSignInButton extends PureComponent { | ||
constructor(props) { | ||
super(props); | ||
|
||
autoBind(this); | ||
|
||
this.state = { | ||
idToken: null, | ||
inProgress: false, | ||
}; | ||
} | ||
|
||
handleAppleButtonPress() { | ||
this.setState({ inProgress: true }); | ||
|
||
return appleAuth | ||
.performRequest(APPLE_AUTH_OPTIONS) | ||
.then(this.handleAppleAuthRequest) | ||
.catch(this.handleAppleAuthError); | ||
} | ||
|
||
handleAppleAuthRequest(results) { | ||
const { user, identityToken, fullName } = results; | ||
|
||
this.setState({ idToken: identityToken }); | ||
|
||
const firstName = _.get(fullName, 'givenName'); | ||
const lastName = _.get(fullName, 'familyName'); | ||
|
||
Storage.saveItem(firstNameStorageKey(), firstName); | ||
Storage.saveItem(lastNameStorageKey(), lastName); | ||
|
||
appleAuth | ||
.getCredentialStateForUser(user) | ||
.then(this.handleAppleLoginRequest) | ||
.catch(this.handleAppleAuthError); | ||
} | ||
|
||
handleAppleLoginRequest(results) { | ||
const { loginWithApple, onLoginSuccess } = this.props; | ||
const { idToken } = this.state; | ||
|
||
if (results === AppleAuthCredentialState.AUTHORIZED) { | ||
return loginWithApple(idToken) | ||
.then(onLoginSuccess) | ||
.catch(this.handleAppleLoginFailed); | ||
} | ||
|
||
return Alert.alert(LOGIN_ERROR_TITLE(), UNEXPECTED_ERROR()); | ||
} | ||
|
||
handleAppleAuthError(error) { | ||
this.setState({ inProgress: false }); | ||
|
||
const errorCode = _.get(error, 'code'); | ||
const resolvedMessage = resolveAppleErrorMessage(errorCode); | ||
|
||
Alert.alert(LOGIN_ERROR_TITLE(), resolvedMessage); | ||
} | ||
|
||
handleAppleLoginFailed({ payload }) { | ||
const errorStatus = _.get(payload, 'status'); | ||
|
||
if (errorStatus === 401) { | ||
return this.performAppleRegistration(); | ||
} | ||
return this.resolveError({ payload }); | ||
} | ||
|
||
performAppleRegistration() { | ||
const { onLoginSuccess, registerWithApple } = this.props; | ||
const { idToken } = this.state; | ||
|
||
Promise.all([ | ||
Storage.getItem(firstNameStorageKey()), | ||
Storage.getItem(lastNameStorageKey()), | ||
]) | ||
.then(([storageFirstName, storageLastName]) => | ||
registerWithApple(idToken, storageFirstName, storageLastName), | ||
) | ||
.then(onLoginSuccess) | ||
.catch(this.resolveError); | ||
} | ||
|
||
resolveError({ payload }) { | ||
this.setState({ inProgress: false }); | ||
|
||
const { response } = payload; | ||
|
||
const payloadErrorCode = _.get(response, 'errors[0].code'); | ||
const resolvedErrorCode = getErrorCode(payloadErrorCode); | ||
const errorMessage = resolveErrorMessage(resolvedErrorCode); | ||
|
||
Alert.alert(LOGIN_ERROR_TITLE(), errorMessage); | ||
} | ||
|
||
render() { | ||
const { inProgress } = this.state; | ||
const { settings, style } = this.props; | ||
|
||
const darkModeEnabled = _.get( | ||
settings, | ||
'providers.apple.buttonDarkModeStyle', | ||
true, | ||
); | ||
const buttonStyle = darkModeEnabled | ||
? AppleButton.Style.BLACK | ||
: AppleButton.Style.WHITE; | ||
|
||
if (inProgress) { | ||
return ( | ||
<View> | ||
<Spinner styleName="xl-gutter-top" /> | ||
</View> | ||
); | ||
} | ||
|
||
return ( | ||
<AppleButton | ||
buttonStyle={buttonStyle} | ||
buttonType={AppleButton.Type.SIGN_IN} | ||
onPress={this.handleAppleButtonPress} | ||
style={style.appleButton} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
AppleSignInButton.propTypes = { | ||
onLoginSuccess: PropTypes.func, | ||
settings: PropTypes.object, | ||
style: PropTypes.object, | ||
}; | ||
|
||
const mapDispatchToProps = { | ||
registerWithApple, | ||
loginWithApple, | ||
}; | ||
|
||
function mapStateToProps(state) { | ||
return { | ||
user: getUser(state), | ||
settings: getExtensionSettings(state, ext()), | ||
}; | ||
} | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
)(connectStyle(ext('AppleSignInButton'))(AppleSignInButton)); |
Oops, something went wrong.