mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 08:24:55 +00:00
- Implementation of a google authentication with a react-native library
This commit is contained in:
@ -6,6 +6,7 @@ import { colorMap } from "@/contexts/SettingsContext";
|
|||||||
import { TouchableOpacity } from "react-native-gesture-handler";
|
import { TouchableOpacity } from "react-native-gesture-handler";
|
||||||
import { fetchGoogleCalendarEvents } from "@/calendar-integration/google-calendar-utils";
|
import { fetchGoogleCalendarEvents } from "@/calendar-integration/google-calendar-utils";
|
||||||
import { useCreateEvent } from "@/hooks/firebase/useCreateEvent";
|
import { useCreateEvent } from "@/hooks/firebase/useCreateEvent";
|
||||||
|
import { GoogleSignin } from "@react-native-google-signin/google-signin";
|
||||||
|
|
||||||
const CalendarSettingsPage = (props: {
|
const CalendarSettingsPage = (props: {
|
||||||
setSelectedPage: (page: number) => void;
|
setSelectedPage: (page: number) => void;
|
||||||
@ -28,6 +29,14 @@ const CalendarSettingsPage = (props: {
|
|||||||
await createEvent(item);
|
await createEvent(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: Right key
|
||||||
|
GoogleSignin.configure({
|
||||||
|
webClientId:
|
||||||
|
"406146460310-81gld1b58ujsoe6a2t3ht0haprv5pa69.apps.googleusercontent.com",
|
||||||
|
scopes: ["profile", "email", "calendar"],
|
||||||
|
offlineAccess: true,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View marginH-30>
|
<View marginH-30>
|
||||||
<TouchableOpacity onPress={() => props.setSelectedPage(0)}>
|
<TouchableOpacity onPress={() => props.setSelectedPage(0)}>
|
||||||
@ -110,6 +119,32 @@ const CalendarSettingsPage = (props: {
|
|||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
<View style={styles.card}>
|
||||||
|
<Text text70>Add Calendar</Text>
|
||||||
|
<View style={{ marginTop: 20 }}>
|
||||||
|
<Button
|
||||||
|
label={"Connect Google"}
|
||||||
|
iconSource={() => (
|
||||||
|
<View
|
||||||
|
backgroundColor="#ededed"
|
||||||
|
width={40}
|
||||||
|
height={40}
|
||||||
|
style={{ borderRadius: 50 }}
|
||||||
|
marginR-10
|
||||||
|
centerV
|
||||||
|
centerH
|
||||||
|
>
|
||||||
|
<AntDesign name="google" size={30} color="#6c645b" />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
icon={<AntDesign name="checkcircleo" size={30} color="#8005eb" />}
|
||||||
|
backgroundColor="white"
|
||||||
|
color="#464039"
|
||||||
|
borderRadius={15}
|
||||||
|
onPress={signInGoogle}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
<View style={styles.card}>
|
<View style={styles.card}>
|
||||||
<Text text70>Calendars</Text>
|
<Text text70>Calendars</Text>
|
||||||
{/** Note: Should check for the user if it has connected calendars **/}
|
{/** Note: Should check for the user if it has connected calendars **/}
|
||||||
@ -141,6 +176,17 @@ const CalendarSettingsPage = (props: {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const signInGoogle = async () => {
|
||||||
|
try {
|
||||||
|
await GoogleSignin.hasPlayServices();
|
||||||
|
let userInfo = await GoogleSignin.signIn();
|
||||||
|
console.log(userInfo);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
console.log(error.code);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
backBtn: {
|
backBtn: {
|
||||||
backgroundColor: "red",
|
backgroundColor: "red",
|
||||||
|
|||||||
20
package-lock.json
generated
20
package-lock.json
generated
@ -16,6 +16,7 @@
|
|||||||
"@react-native-firebase/crashlytics": "^20.3.0",
|
"@react-native-firebase/crashlytics": "^20.3.0",
|
||||||
"@react-native-firebase/firestore": "^20.4.0",
|
"@react-native-firebase/firestore": "^20.4.0",
|
||||||
"@react-native-firebase/functions": "^20.4.0",
|
"@react-native-firebase/functions": "^20.4.0",
|
||||||
|
"@react-native-google-signin/google-signin": "^13.1.0",
|
||||||
"@react-navigation/drawer": "^6.7.2",
|
"@react-navigation/drawer": "^6.7.2",
|
||||||
"@react-navigation/native": "^6.0.2",
|
"@react-navigation/native": "^6.0.2",
|
||||||
"date-fns": "^3.6.0",
|
"date-fns": "^3.6.0",
|
||||||
@ -7233,6 +7234,25 @@
|
|||||||
"@react-native-firebase/app": "20.4.0"
|
"@react-native-firebase/app": "20.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@react-native-google-signin/google-signin": {
|
||||||
|
"version": "13.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@react-native-google-signin/google-signin/-/google-signin-13.1.0.tgz",
|
||||||
|
"integrity": "sha512-C2/sqb0/s0c+Dwc/mykASZsRuHxGqn7SFrCxCY9D8p8IOQO05haInhCc7lzraJshRixGva5c/4usQZ71HMYSEQ==",
|
||||||
|
"peerDependencies": {
|
||||||
|
"expo": ">=50.0.0",
|
||||||
|
"react": "*",
|
||||||
|
"react-dom": "*",
|
||||||
|
"react-native": "*"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"expo": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"react-dom": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@react-native/assets-registry": {
|
"node_modules/@react-native/assets-registry": {
|
||||||
"version": "0.74.85",
|
"version": "0.74.85",
|
||||||
"resolved": "https://registry.npmjs.org/@react-native/assets-registry/-/assets-registry-0.74.85.tgz",
|
"resolved": "https://registry.npmjs.org/@react-native/assets-registry/-/assets-registry-0.74.85.tgz",
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
"@react-native-firebase/crashlytics": "^20.3.0",
|
"@react-native-firebase/crashlytics": "^20.3.0",
|
||||||
"@react-native-firebase/firestore": "^20.4.0",
|
"@react-native-firebase/firestore": "^20.4.0",
|
||||||
"@react-native-firebase/functions": "^20.4.0",
|
"@react-native-firebase/functions": "^20.4.0",
|
||||||
|
"@react-native-google-signin/google-signin": "^13.1.0",
|
||||||
"@react-navigation/drawer": "^6.7.2",
|
"@react-navigation/drawer": "^6.7.2",
|
||||||
"@react-navigation/native": "^6.0.2",
|
"@react-navigation/native": "^6.0.2",
|
||||||
"date-fns": "^3.6.0",
|
"date-fns": "^3.6.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user