Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nonononoki committed Sep 18, 2022
1 parent c777c09 commit 5b4acdf
Show file tree
Hide file tree
Showing 28 changed files with 3,283 additions and 1,841 deletions.
64 changes: 64 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,71 @@ npm-debug.*
*.key
*.mobileprovision
*.orig.*
*.env*
web-build/
android
ios

# macOS
.DS_Store

# @generated expo-cli sync-e7dcf75f4e856f7b6f3239b3f3a7dd614ee755a8
# The following patterns were generated by expo-cli

# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# Bundle artifacts
*.jsbundle

# CocoaPods
/ios/Pods/

# Expo
.expo/
web-build/
dist/

# @end expo-cli
165 changes: 72 additions & 93 deletions App.tsx
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>
);
}
34 changes: 34 additions & 0 deletions Global.tsx
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);
}
}
Loading

0 comments on commit 5b4acdf

Please sign in to comment.