-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c777c09
commit 5b4acdf
Showing
28 changed files
with
3,283 additions
and
1,841 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,82 @@ | ||
import React from "react"; | ||
import { Main, Onboarding, Register } from "./screens"; | ||
import { View, Platform, Button } from "react-native"; | ||
import { Buffer } from "buffer"; | ||
import * as SplashScreen from 'expo-splash-screen'; | ||
import * as WebBrowser from 'expo-web-browser'; | ||
import { NavigationContainer } from "@react-navigation/native"; | ||
import * as Linking from 'expo-linking'; | ||
import * as Global from "./Global"; | ||
import * as URL from "./URL"; | ||
import { createStackNavigator } from "@react-navigation/stack"; | ||
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"; | ||
import { Home, Matches, Messages, Profile } from "./screens"; | ||
import { PRIMARY_COLOR, DARK_GRAY, BLACK, WHITE } from "./assets/styles"; | ||
import TabBarIcon from "./components/TabBarIcon"; | ||
import * as I18N from "./i18n/i18n"; | ||
|
||
const i18n = I18N.getI18n() | ||
const TWO_WEEKS_MS = 1209600000; | ||
const APP_URL = Linking.createURL(""); | ||
|
||
SplashScreen.preventAutoHideAsync(); | ||
setTimeout(SplashScreen.hideAsync, 1000); | ||
WebBrowser.maybeCompleteAuthSession(); | ||
|
||
const Stack = createStackNavigator(); | ||
const Tab = createBottomTabNavigator(); | ||
|
||
const App = () => ( | ||
<NavigationContainer> | ||
<Stack.Navigator> | ||
<Stack.Screen | ||
name="Tab" | ||
options={{ headerShown: false, animationEnabled: false }} | ||
> | ||
{() => ( | ||
<Tab.Navigator | ||
tabBarOptions={{ | ||
showLabel: false, | ||
activeTintColor: PRIMARY_COLOR, | ||
inactiveTintColor: DARK_GRAY, | ||
labelStyle: { | ||
fontSize: 14, | ||
textTransform: "uppercase", | ||
paddingTop: 10, | ||
}, | ||
style: { | ||
backgroundColor: WHITE, | ||
borderTopWidth: 0, | ||
marginBottom: 0, | ||
shadowOpacity: 0.05, | ||
shadowRadius: 10, | ||
shadowColor: BLACK, | ||
shadowOffset: { height: 0, width: 0 }, | ||
}, | ||
}} | ||
> | ||
<Tab.Screen | ||
name="Explore" | ||
component={Home} | ||
options={{ | ||
tabBarIcon: ({ focused }) => ( | ||
<TabBarIcon | ||
focused={focused} | ||
iconName="search" | ||
text="Explore" | ||
/> | ||
), | ||
}} | ||
/> | ||
//TODO remove auth cookie just before it expires | ||
|
||
|
||
export default function App() { | ||
|
||
const _handleRedirect = async (event: { url: string; }) => { | ||
|
||
if (Platform.OS === 'ios') { | ||
WebBrowser.dismissBrowser(); | ||
} | ||
|
||
let data = Linking.parse(event.url); | ||
if (data.queryParams != null) { | ||
//let firstName: string = String(data.queryParams["firstName"]); | ||
let page = Number(data.queryParams["page"]); | ||
let rememberMe = String(data.queryParams["remember-me"]); | ||
let rememberMeExpire: Number = Number(data.queryParams["remember-me-expire"]); | ||
let expireDate = Number(rememberMeExpire); | ||
let expireDateIso = new Date(expireDate).toISOString(); | ||
await Global.SetStorage("remember-me", rememberMe); | ||
await Global.SetStorage("remember-me-expire", expireDateIso); | ||
await Global.SetStorage("page", String(page)); | ||
|
||
//TODO move to next screen | ||
|
||
<Tab.Screen | ||
name="Matches" | ||
component={Matches} | ||
options={{ | ||
tabBarIcon: ({ focused }) => ( | ||
<TabBarIcon | ||
focused={focused} | ||
iconName="heart" | ||
text="Matches" | ||
/> | ||
), | ||
}} | ||
/> | ||
} | ||
}; | ||
|
||
<Tab.Screen | ||
name="Chat" | ||
component={Messages} | ||
options={{ | ||
tabBarIcon: ({ focused }) => ( | ||
<TabBarIcon | ||
focused={focused} | ||
iconName="chatbubble" | ||
text="Chat" | ||
/> | ||
), | ||
}} | ||
/> | ||
const loginGoogle = async () => { | ||
let e = Linking.addEventListener('url', _handleRedirect); | ||
await WebBrowser.openAuthSessionAsync(URL.AUTH_GOOGLE + "/" + Buffer.from(APP_URL).toString('base64'), ''); | ||
e.remove(); | ||
}; | ||
|
||
<Tab.Screen | ||
name="Profile" | ||
component={Profile} | ||
options={{ | ||
tabBarIcon: ({ focused }) => ( | ||
<TabBarIcon | ||
focused={focused} | ||
iconName="person" | ||
text="Profile" | ||
/> | ||
), | ||
}} | ||
/> | ||
</Tab.Navigator> | ||
)} | ||
</Stack.Screen> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
); | ||
const loginFacebook = async () => { | ||
let e = Linking.addEventListener('url', _handleRedirect); | ||
await WebBrowser.openAuthSessionAsync(URL.AUTH_FACEBOOK + "/" + Buffer.from(APP_URL).toString('base64'), ''); | ||
e.remove(); | ||
}; | ||
|
||
export default App; | ||
return ( | ||
<View style={{ flex: 1 }}> | ||
<NavigationContainer> | ||
<Button | ||
title={i18n.t('auth.google')} | ||
onPress={() => { | ||
loginGoogle(); | ||
}} | ||
/> | ||
<Button | ||
title={i18n.t('auth.facebook')} | ||
onPress={() => { | ||
loginGoogle(); | ||
}} | ||
/> | ||
</NavigationContainer> | ||
</View> | ||
); | ||
} |
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,34 @@ | ||
import React from "react"; | ||
import { Platform } from 'react-native'; | ||
import axios, { AxiosResponse } from 'axios'; | ||
import * as SecureStore from 'expo-secure-store'; | ||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
|
||
export async function Fetch(url : string = '', method : string = 'get', data : any = {}) : Promise<AxiosResponse<any, any>> { | ||
let cookie = await GetStorage("remember-me"); | ||
let headers = { Cookie: "remember-me=" + cookie }; | ||
|
||
return await axios({ | ||
method: method, | ||
url: url, | ||
data: data, | ||
headers: headers | ||
}) | ||
|
||
} | ||
|
||
export async function GetStorage(key : string) : Promise<string | null> { | ||
if (Platform.OS === 'web') { | ||
return await AsyncStorage.getItem(key); | ||
} else { | ||
return await SecureStore.getItemAsync(key); | ||
} | ||
} | ||
|
||
export async function SetStorage(key : string, value : string) { | ||
if (Platform.OS === 'web') { | ||
await AsyncStorage.setItem(key, value); | ||
} else { | ||
await SecureStore.setItemAsync(key, value); | ||
} | ||
} |
Oops, something went wrong.