Skip to content

Commit

Permalink
Merge pull request #774 from sfroment/dev/sfroment/splash-screen
Browse files Browse the repository at this point in the history
feat(client): add berty splash screen
  • Loading branch information
sfroment committed Dec 18, 2018
2 parents 5b92f69 + 4fc990b commit 0705711
Show file tree
Hide file tree
Showing 26 changed files with 464 additions and 63 deletions.
34 changes: 17 additions & 17 deletions .circleci/config.yml
Expand Up @@ -301,9 +301,9 @@ jobs:
- attach_workspace:
at: ~/go/src/berty.tech/

# if build breaks, increment vX in both restore_cache and save_cache
- restore_cache:
key: v2-ios-golang-{{ .Environment.GOVERSION }}-2
# # if build breaks, increment vX in both restore_cache and save_cache
# - restore_cache:
# key: v2-ios-golang-{{ .Environment.GOVERSION }}-2

- run:
name: install-go
Expand All @@ -327,12 +327,12 @@ jobs:
gomobile init
fi
- save_cache:
key: v2-ios-golang-{{ .Environment.GOVERSION }}-2
paths:
- ~/go/pkg
- ~/go/src/github.com
- ~/go-install
# - save_cache:
# key: v2-ios-golang-{{ .Environment.GOVERSION }}-2
# paths:
# - ~/go/pkg
# - ~/go/src/github.com
# - ~/go-install

- run:
name: install core
Expand Down Expand Up @@ -400,8 +400,8 @@ jobs:
at: ~/go/src/berty.tech/

# if build breaks, increment vX in both restore_cache and save_cache
- restore_cache:
key: v2-ios-golang-{{ .Environment.GOVERSION }}-3
# - restore_cache:
# key: v2-ios-golang-{{ .Environment.GOVERSION }}-3

- run:
name: install-go
Expand All @@ -425,12 +425,12 @@ jobs:
gomobile init
fi
- save_cache:
key: v2-ios-golang-{{ .Environment.GOVERSION }}-3
paths:
- ~/go/pkg
- ~/go/src/github.com
- ~/go-install
# - save_cache:
# key: v2-ios-golang-{{ .Environment.GOVERSION }}-3
# paths:
# - ~/go/pkg
# - ~/go/src/github.com
# - ~/go-install

- run:
name: install core
Expand Down
3 changes: 2 additions & 1 deletion client/react-native/android/app/build.gradle
Expand Up @@ -98,7 +98,7 @@ android {
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
applicationId "chat.berty"
applicationId "chat.berty.main"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
Expand Down Expand Up @@ -166,6 +166,7 @@ android {
}

dependencies {
compile project(':lottie-react-native')
compile project(':react-native-vector-icons')
compile project(':react-native-svg')
compile project(':react-native-restart')
Expand Down
19 changes: 14 additions & 5 deletions client/react-native/android/app/src/main/AndroidManifest.xml
Expand Up @@ -14,16 +14,25 @@
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/AppTheme">

<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
android:name=".SplashActivity"
android:theme="@style/SplashTheme"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
Expand Down
Expand Up @@ -3,6 +3,7 @@
import android.app.Application;

import com.facebook.react.ReactApplication;
import com.airbnb.android.react.lottie.LottiePackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.horcrux.svg.SvgPackage;
import com.avishayil.rnrestart.ReactNativeRestartPackage;
Expand Down Expand Up @@ -43,6 +44,7 @@ protected List<ReactPackage> getPackages() {
new CorePackage(),
new ImagePickerPackage(),
new MainReactPackage(),
new LottiePackage(),
new RNCameraPackage(),
new RNNetworkInfoPackage(),
new ReactNativeExceptionHandlerPackage(),
Expand Down
@@ -0,0 +1,18 @@
package chat.berty.main;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import chat.berty.main.MainActivity;

public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:drawable="@color/white"/>

<item
android:width="200dp"
android:height="200dp"
android:drawable="@mipmap/berty_square"
android:gravity="center" />


</layer-list>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions client/react-native/android/app/src/main/res/values/styles.xml
Expand Up @@ -2,7 +2,17 @@

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>

<!-- Customize your theme here. -->
</style>

<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>

<!-- Customize your theme here. -->
</style>

<color name="white">#FFFFFF</color>

</resources>
2 changes: 2 additions & 0 deletions client/react-native/android/settings.gradle
@@ -1,4 +1,6 @@
rootProject.name = 'Berty'
include ':lottie-react-native'
project(':lottie-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/lottie-react-native/src/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-svg'
Expand Down
61 changes: 46 additions & 15 deletions client/react-native/common/components/App.js
@@ -1,15 +1,19 @@
import { Linking, Platform } from 'react-native'
import { Linking, Platform, Animated, Easing } from 'react-native'
import { SafeAreaView } from 'react-navigation'
import KeyboardSpacer from 'react-native-keyboard-spacer'
import React, { PureComponent } from 'react'
import { parse as parseUrl } from '../helpers/url'

import { Loader } from './Library'
import LottieView from 'lottie-react-native'
import { Flex } from './Library'
import Accounts from './Screens/Accounts'
import { colors } from './../constants'

export default class App extends PureComponent {
state = {
loading: true,
hide: true,
duration: 4000,
progress: new Animated.Value(0),
deepLink: {
routeName: 'main',
params: {},
Expand All @@ -30,6 +34,7 @@ export default class App extends PureComponent {
}

Linking.addEventListener('url', this._handleOpenURL)
this.startAnimation()
this.setState({ loading: false })
}

Expand Down Expand Up @@ -60,21 +65,47 @@ export default class App extends PureComponent {
}
}

startAnimation () {
Animated.timing(this.state.progress, {
toValue: 1,
duration: this.state.duration,
easing: Easing.linear,
}).start(({ finished }) => {
if (finished) {
this.setState({ hide: false })
}
})
}

render () {
const { loading, deepLink } = this.state
if (loading) {
return <Loader />
}
console.log(this.onAnimationFinished)
const { loading, deepLink, hide, progress } = this.state
return (
<SafeAreaView style={{ flex: 1 }} forceInset={{ bottom: 'never' }}>
<Accounts
ref={nav => {
this.navigation = nav
}}
screenProps={{
deepLink,
}}
/>
{ hide && Platform.OS !== 'web'
? <Flex.Rows
align='center'
justify='center'
style={{ 'width': '100%', height: '100%', zIndex: 1000, position: 'absolute', backgroundColor: colors.white }}
>
<LottieView
source={require('./../static/animation/BertyAnimation.json')}
progress={progress}
loop={false}
style={{ 'width': 320 }}
autoSize
/>
</Flex.Rows>
: null }
{ !loading
? <Accounts
ref={nav => {
this.navigation = nav
}}
screenProps={{
deepLink,
}}
/> : null }
{Platform.OS === 'ios' && <KeyboardSpacer />}
</SafeAreaView>
)
Expand Down
82 changes: 82 additions & 0 deletions client/react-native/common/components/App.web.js
@@ -0,0 +1,82 @@
import { Linking, Platform } from 'react-native'
import { SafeAreaView } from 'react-navigation'
import KeyboardSpacer from 'react-native-keyboard-spacer'
import React, { PureComponent } from 'react'
import { parse as parseUrl } from '../helpers/url'

import { Loader } from './Library'
import Accounts from './Screens/Accounts'

export default class App extends PureComponent {
state = {
loading: true,
deepLink: {
routeName: 'main',
params: {},
},
}

componentDidMount () {
Linking.getInitialURL()
.then(url => {
if (url !== null) {
this.handleOpenURL({ url })
}
})
.catch(() => {})

if (this._handleOpenURL === undefined) {
this._handleOpenURL = this.handleOpenURL.bind(this)
}

Linking.addEventListener('url', this._handleOpenURL)
this.setState({ loading: false })
}

componentWillUnmount () {
if (this._handleOpenURL !== undefined) {
Linking.removeEventListener('url', this._handleOpenURL)
}
}

handleOpenURL (event) {
let url = parseUrl(event.url.replace('berty://', 'https://berty.tech/'))

switch (url.pathname) {
case '/add-contact':
this.setState({
deepLink: {
routeName: 'modal/contacts/add/by-public-key',
params: {
initialKey: url.hashParts['public-key'] || '',
initialName: url.hashParts['display-name'] || '',
},
},
})
break
default:
console.warn(`Unhandled deep link, URL: ${event.url}`)
break
}
}

render () {
const { loading, deepLink } = this.state
if (loading) {
return <Loader />
}
return (
<SafeAreaView style={{ flex: 1 }} forceInset={{ bottom: 'never' }}>
<Accounts
ref={nav => {
this.navigation = nav
}}
screenProps={{
deepLink,
}}
/>
{Platform.OS === 'ios' && <KeyboardSpacer />}
</SafeAreaView>
)
}
}

Large diffs are not rendered by default.

0 comments on commit 0705711

Please sign in to comment.