Skip to content

Commit

Permalink
Merge pull request #23 from sarthakpranesh/develop
Browse files Browse the repository at this point in the history
Release v3.0.0
  • Loading branch information
Sarthak Pranesh authored Mar 16, 2021
2 parents 5e438a3 + e022d09 commit 4a1df34
Show file tree
Hide file tree
Showing 90 changed files with 8,702 additions and 3,181 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/web-build
.expo
3 changes: 1 addition & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
inexact-spread=warn
unnecessary-invariant=warn
signature-verification-failure=warn
deprecated-utility=error
Expand All @@ -71,4 +70,4 @@ untyped-import
untyped-type-import

[version]
^0.113.0
^0.122.0
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,9 @@ buck-out/
/ios/Pods/

.env

# Expo used for web and web builds
/.expo
/web-build

.vercel
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ android:
components:
- build-tools-28.0.3
- android-28
- build-tools-29.0.2
- android-29
script:
- yarn lint
- yarn build-android
Expand Down
Binary file removed App Store Assets/Main.png
Binary file not shown.
Binary file removed App Store Assets/icon.png
Binary file not shown.
Binary file removed App Store Assets/screens/1.png
Binary file not shown.
Binary file removed App Store Assets/screens/2.png
Binary file not shown.
Binary file removed App Store Assets/screens/3.png
Binary file not shown.
Binary file removed App Store Assets/screens/4.png
Binary file not shown.
Binary file removed App Store Assets/screens/5.png
Binary file not shown.
Binary file removed App Store Assets/screens/6.png
Binary file not shown.
243 changes: 136 additions & 107 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,127 +1,156 @@
import React, { useEffect, useState } from 'react'
import React, { useEffect } from 'react'
import { bindActionCreators } from 'redux'
import { Provider as ReduxProvider, connect } from 'react-redux'
import { PersistGate } from 'redux-persist/integration/react'
import { PermissionsAndroid, Platform } from 'react-native'
import Geolocation from 'react-native-geolocation-service'
import LinearGradient from 'react-native-linear-gradient'
import { NavigationContainer } from '@react-navigation/native'
import { createAppContainer, createSwitchNavigator } from 'react-navigation'
import { createDrawerNavigator } from '@react-navigation/drawer'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { preventAutoHideAsync, hideAsync } from 'expo-splash-screen'

import Animated from 'react-native-reanimated'
// importing redux persist stores
import { store, persister } from './src/stores/stores'

import { DrawerContent, Screens } from './src/components/navigation/Drawer'
// Importing reducer functions
import { setCountry, updateData } from './src/reducers/DataReducer'

import getLocationHook from './src/hooks/getLocationHook'
// Importing API functions
import getCountry from './src/API/functions/getCountry'
import getCovidData from './src/API/functions/getCovidData'

const Drawer = createDrawerNavigator()
// Importing splash screen
import WebSplashScreen from './src/screens/SplashScreen'
import HomeScreen from './src/screens/HomeScreen'

const MainApp = () => {
const [getLocation, country] = getLocationHook()
const [progress, setProgress] = useState<Animated.Node<number>>(
new Animated.Value(0)
const mapStateToProps = (state: any) => {
const data = state.dataReducer.data
return data
}

const mapDispatchToProps = (dispatch: any) =>
bindActionCreators(
{
setCountry,
updateData
},
dispatch
)
const scale = Animated.interpolate(progress, {
inputRange: [0, 1],
outputRange: [1, 0.8]
})
const borderRadius = Animated.interpolate(progress, {
inputRange: [0, 1],
outputRange: [0, 16]
})

const animatedStyle = { borderRadius, transform: [{ scale }] }
const MainApp = connect(mapStateToProps, mapDispatchToProps)((props: any) => {
const fetchAndSetCountry = async (coords: any) => {
const country = await getCountry({
long: coords.longitude,
lat: coords.latitude
})
props.setCountry(country)
}

useEffect(() => {
// some bug in react native
setTimeout(() => {
if (Platform.OS === 'ios') {
Geolocation.requestAuthorization('whenInUse')
.then((result) => {
console.log('IOS permission:', result)
Geolocation.getCurrentPosition(
async (pos) => {
await getLocation({
long: pos.coords.longitude,
lat: pos.coords.latitude
})
},
(err) => {
console.log(err.message)
getLocation({ lat: '28.644800', long: '77.216721' })
},
{ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
)
})
.catch((err) => console.log(err.message))
} else {
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
title: 'Covid-19 App',
message:
"App needs to access your phone's location to work correctly. " +
'You can cancel this step but then app will default to Indian Stats',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK'
}
)
.then(() => {
Geolocation.getCurrentPosition(
async (pos) => {
await getLocation({
long: pos.coords.longitude,
lat: pos.coords.latitude
})
},
(err) => {
console.log(err.message)
getLocation({ lat: '28.644800', long: '77.216721' })
},
{ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
)
})
.catch((err) => console.log(err.message))
switch (Platform.OS) {
case 'web':
Geolocation.getCurrentPosition(
(pos) => fetchAndSetCountry(pos.coords),
(err) => {
console.log(err.message)
fetchAndSetCountry({ latitude: '28.644800', longitude: '77.216721' })
},
{ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
)
return
case 'ios':
Geolocation.requestAuthorization('whenInUse')
.then((result) => {
console.log('IOS permission:', result)
Geolocation.getCurrentPosition(
(pos) => fetchAndSetCountry(pos.coords),
(err) => {
console.log(err.message)
fetchAndSetCountry({ latitude: '28.644800', longitude: '77.216721' })
},
{ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
)
})
.catch((err) => console.log(err.message))
return
case 'android':
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
title: 'Covid-19 App',
message:
"App needs to access your phone's location to work correctly. " +
'You can cancel this step but then app will default to Indian Stats',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK'
}
)
.then(() => {
Geolocation.getCurrentPosition(
(pos) => fetchAndSetCountry(pos.coords),
(err) => {
console.log('Geolocation Error:', err.message)
fetchAndSetCountry({ latitude: '28.644800', longitude: '77.216721' })
},
{ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
)
})
.catch((err) => console.log(err.message))
return
default:
console.log('No platform matched')
}
}, 100)
}, [])

return country !== '' ? (
<NavigationContainer>
<LinearGradient
colors={['#DEF7FF', '#B1ECFF']}
style={{ flex: 1, backgroundColor: 'white' }}>
<Drawer.Navigator
edgeWidth={100}
initialRouteName="Screens"
drawerType="slide"
overlayColor="transparent"
drawerStyle={{ flex: 1, width: '50%', backgroundColor: 'transparent' }}
drawerContentOptions={{
activeBackgroundColor: 'transparent',
activeTintColor: 'black',
inactiveTintColor: 'black'
}}
sceneContainerStyle={{ backgroundColor: 'transparent' }}
drawerContent={(p) => {
setProgress(p.progress)
return <DrawerContent {...p} country={country} />
}}>
<Drawer.Screen name="Screens">
{(p) => <Screens {...p} style={animatedStyle} country={country} />}
</Drawer.Screen>
</Drawer.Navigator>
</LinearGradient>
</NavigationContainer>
) : null
}
useEffect(() => {
if (props.country !== null) {
getCovidData(props.country)
.then((data) => {
props.updateData(data)
})
.catch((err) => {
console.log(err)
})
}
}, [props.country])

// this useEffect should hide all implementation of splash screen from native and web
useEffect(() => {
if (props.data?.global !== undefined) {
hideAsync()
}
}, [props.data?.global])

const UserStartingSwitch = createSwitchNavigator(
{
MainApp
},
{
initialRouteName: 'MainApp'
// expo-splash-screen not supported on web
// therefore using a extra stack with react native component for splash on web
if (Platform.OS === 'web') {
if (props.data?.global === undefined) {
return <WebSplashScreen />
}
}
)

export default createAppContainer(UserStartingSwitch)
if (props.country === null || props.data?.global === undefined) {
return null
}

return <HomeScreen />
})

const App = () => {
useEffect(() => {
preventAutoHideAsync()
}, [])
return (
<ReduxProvider store={store}>
<PersistGate loading={false} persistor={persister}>
<SafeAreaProvider>
<MainApp />
</SafeAreaProvider>
</PersistGate>
</ReduxProvider>
)
}

export default App
25 changes: 7 additions & 18 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
apply plugin: "com.android.application"

project.ext.vectoricons = [
iconFontNames: [ 'Feather.ttf' ]
]

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply from: '../../node_modules/react-native-unimodules/gradle.groovy'

import com.android.build.OutputFile

Expand All @@ -26,7 +21,7 @@ import com.android.build.OutputFile
* // default. Can be overridden with ENTRY_FILE environment variable.
* entryFile: "index.android.js",
*
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
* // https://reactnative.dev/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
*
* // whether to bundle JS and assets in debug mode
Expand Down Expand Up @@ -143,7 +138,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 2
versionName "2.3.6"
versionName "3.0.0"
}
splits {
abi {
Expand Down Expand Up @@ -174,20 +169,13 @@ android {
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}

packagingOptions {
pickFirst "lib/armeabi-v7a/libc++_shared.so"
pickFirst "lib/arm64-v8a/libc++_shared.so"
pickFirst "lib/x86/libc++_shared.so"
pickFirst "lib/x86_64/libc++_shared.so"
}

// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand All @@ -211,12 +199,15 @@ dependencies {

implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

addUnimodulesDependencies()

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}

debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
Expand All @@ -230,8 +221,6 @@ dependencies {
} else {
implementation jscFlavor
}

implementation project(':react-native-splash-screen')
}

// Run this once to be able to run the application with BUCK
Expand Down
2 changes: 2 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
# Add any project specific keep options here:
-keep class com.facebook.hermes.unicode.** { *; }
-keep class com.facebook.jni.** { *; }
-keep class com.facebook.react.turbomodule.** { *; }
-keep public class com.horcrux.svg.** {*;}
Loading

0 comments on commit 4a1df34

Please sign in to comment.