Skip to content

Commit 5bffe9f

Browse files
converted to expo router, example app now navigates back to the app after a successful connection, added an e2e test
1 parent 0e43203 commit 5bffe9f

File tree

11 files changed

+294
-172
lines changed

11 files changed

+294
-172
lines changed

example/app/App.tsx

Lines changed: 0 additions & 166 deletions
This file was deleted.

example/app/_layout.tsx

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,60 @@
1-
import { Stack } from "expo-router";
1+
import { Stack } from "expo-router"
22

33
export default function RootLayout() {
4-
return <Stack />;
4+
return (
5+
<Stack
6+
screenOptions={{
7+
headerShown: true,
8+
}}>
9+
<Stack.Screen
10+
name="index"
11+
options={{
12+
title: "Widgets",
13+
headerShown: false,
14+
}}
15+
/>
16+
<Stack.Screen
17+
name="connect"
18+
options={{
19+
title: "Connect Widget",
20+
headerBackTitle: "Back",
21+
}}
22+
/>
23+
<Stack.Screen
24+
name="budgets"
25+
options={{
26+
title: "Budgets Widget",
27+
headerBackTitle: "Back",
28+
}}
29+
/>
30+
<Stack.Screen
31+
name="goals"
32+
options={{
33+
title: "Goals Widget",
34+
headerBackTitle: "Back",
35+
}}
36+
/>
37+
<Stack.Screen
38+
name="pulse"
39+
options={{
40+
title: "Pulse Widget",
41+
headerBackTitle: "Back",
42+
}}
43+
/>
44+
<Stack.Screen
45+
name="spending"
46+
options={{
47+
title: "Spending Widget",
48+
headerBackTitle: "Back",
49+
}}
50+
/>
51+
<Stack.Screen
52+
name="transactions"
53+
options={{
54+
title: "Transactions Widget",
55+
headerBackTitle: "Back",
56+
}}
57+
/>
58+
</Stack>
59+
)
560
}

example/app/budgets.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from "react"
2+
import { SafeAreaView, StyleSheet, Platform } from "react-native"
3+
4+
import { BudgetsWidget } from "@mxenabled/react-native-widget-sdk"
5+
6+
const baseUrl = Platform.OS === "android" ? "http://10.0.2.2:8089" : "http://localhost:8089"
7+
const proxy = `${baseUrl}/user/widget_urls`
8+
9+
const styles = StyleSheet.create({
10+
page: {
11+
backgroundColor: "#ffffff",
12+
paddingTop: 10,
13+
},
14+
})
15+
16+
export default function Budgets() {
17+
return (
18+
<SafeAreaView style={styles.page}>
19+
<BudgetsWidget proxy={proxy} />
20+
</SafeAreaView>
21+
)
22+
}

example/app/connect.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React from "react"
2+
import { SafeAreaView, StyleSheet, Platform } from "react-native"
3+
import * as Linking from "expo-linking"
4+
5+
import { ConnectWidget } from "@mxenabled/react-native-widget-sdk"
6+
7+
const baseUrl = Platform.OS === "android" ? "http://10.0.2.2:8089" : "http://localhost:8089"
8+
const proxy = `${baseUrl}/user/widget_urls`
9+
10+
const styles = StyleSheet.create({
11+
page: {
12+
backgroundColor: "#ffffff",
13+
paddingTop: 10,
14+
},
15+
})
16+
17+
export default function Connect() {
18+
const clientRedirectUrl = Linking.createURL("connect")
19+
20+
return (
21+
<SafeAreaView style={styles.page}>
22+
<ConnectWidget
23+
proxy={proxy}
24+
clientRedirectUrl={clientRedirectUrl}
25+
onSsoUrlLoadError={(error) => {
26+
console.error(`SSO URL load error: ${error}`)
27+
}}
28+
onMessage={(url) => {
29+
console.log(`Got a message: ${url}`)
30+
}}
31+
onInvalidMessageError={(url, _error) => {
32+
console.log(`Got an unknown message: ${url}`)
33+
}}
34+
onLoad={(_payload) => {
35+
console.log("Widget is loading")
36+
}}
37+
onLoaded={(_payload) => {
38+
console.log("Widget has loaded")
39+
}}
40+
onStepChange={(payload) => {
41+
console.log(`Moving from ${payload.previous} to ${payload.current}`)
42+
}}
43+
onSelectedInstitution={(payload) => {
44+
console.log(`Selecting ${payload.name}`)
45+
}}
46+
/>
47+
</SafeAreaView>
48+
)
49+
}

example/app/goals.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from "react"
2+
import { SafeAreaView, StyleSheet, Platform } from "react-native"
3+
4+
import { GoalsWidget } from "@mxenabled/react-native-widget-sdk"
5+
6+
const baseUrl = Platform.OS === "android" ? "http://10.0.2.2:8089" : "http://localhost:8089"
7+
const proxy = `${baseUrl}/user/widget_urls`
8+
9+
const styles = StyleSheet.create({
10+
page: {
11+
backgroundColor: "#ffffff",
12+
paddingTop: 10,
13+
},
14+
})
15+
16+
export default function Goals() {
17+
return (
18+
<SafeAreaView style={styles.page}>
19+
<GoalsWidget proxy={proxy} />
20+
</SafeAreaView>
21+
)
22+
}

example/app/index.tsx

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
1-
import App from "./App"
1+
import React, { FC, PropsWithChildren } from "react"
2+
import { SafeAreaView, Text, View, StyleSheet } from "react-native"
3+
import { Link } from "expo-router"
24

3-
export default function Index() {
4-
return <App />
5+
const styles = StyleSheet.create({
6+
page: {
7+
backgroundColor: "#ffffff",
8+
paddingTop: 10,
9+
},
10+
navigation: {
11+
display: "flex",
12+
height: "100%",
13+
gap: 10,
14+
margin: 50,
15+
},
16+
navigationButton: {
17+
alignItems: "center",
18+
backgroundColor: "rgb(144, 202, 249)",
19+
padding: 20,
20+
},
21+
navItemNormalText: {
22+
color: "rgba(0, 0, 0, 0.87)",
23+
fontSize: 20,
24+
},
25+
})
26+
27+
export default function Home() {
28+
return (
29+
<SafeAreaView style={styles.page}>
30+
<View style={styles.navigation}>
31+
<NavigationButton href="/connect">Connect</NavigationButton>
32+
<NavigationButton href="/budgets">Budgets</NavigationButton>
33+
<NavigationButton href="/goals">Goals</NavigationButton>
34+
<NavigationButton href="/pulse">Pulse</NavigationButton>
35+
<NavigationButton href="/spending">Spending</NavigationButton>
36+
<NavigationButton href="/transactions">Transactions</NavigationButton>
37+
</View>
38+
</SafeAreaView>
39+
)
540
}
41+
42+
const NavigationButton: FC<PropsWithChildren<{ href: string }>> = ({ href, children }) => (
43+
<Link href={href} style={styles.navigationButton} asChild>
44+
<Text style={styles.navItemNormalText}>{children}</Text>
45+
</Link>
46+
)

example/app/oauth_complete.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { useEffect } from "react"
2+
import { useLocalSearchParams } from "expo-router"
3+
4+
export default function OAuthComplete() {
5+
const params = useLocalSearchParams()
6+
7+
useEffect(() => {
8+
// Handle the OAuth redirect
9+
console.log("OAuth redirect received", params)
10+
}, [params])
11+
12+
return null
13+
}

0 commit comments

Comments
 (0)