-
Notifications
You must be signed in to change notification settings - Fork 0
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
75b5e79
commit af41481
Showing
4 changed files
with
168 additions
and
77 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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { StyleSheet } from 'react-native' | ||
|
||
import { PageView } from '@/components/PageView' | ||
import { ThemedText } from '@/components/ThemedText' | ||
import { ThemedView } from '@/components/ThemedView' | ||
import { useQuery, gql } from '@quiltt/react-native' | ||
import { useEffect } from 'react' | ||
import { Colors } from '@/constants/Colors' | ||
|
||
const SAMPLE_QUERY = gql` | ||
query SampleQuery { | ||
profile { | ||
id | ||
name | ||
} | ||
connections(filter: { status: [INITIALIZING, SYNCING, SYNCED] }) { | ||
id | ||
institution { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
` | ||
|
||
export default function HomeScreen() { | ||
const { data, error, loading } = useQuery<{ | ||
profile: { id: string; name: string; email: string } | ||
connections: { id: string; institution: { id: string; name: string } }[] | ||
}>(SAMPLE_QUERY as any) // TODO: Fix type error | ||
|
||
useEffect(() => { | ||
if (error) { | ||
console.error(error) | ||
} | ||
}, [error]) | ||
|
||
return ( | ||
<PageView title={<ThemedText type="title">Your Data</ThemedText>}> | ||
{loading ? ( | ||
<ThemedText>Loading...</ThemedText> | ||
) : ( | ||
<ThemedView style={styles.container}> | ||
<ThemedView style={styles.container}> | ||
<ThemedText style={styles.title}>Profile</ThemedText> | ||
<ThemedText>ID: {data?.profile?.id}</ThemedText> | ||
<ThemedText>Name: {data?.profile?.name}</ThemedText> | ||
<ThemedText>Email: {data?.profile?.email}</ThemedText> | ||
</ThemedView> | ||
{data?.connections && data?.connections?.length >= 1 ? ( | ||
<ThemedView style={styles.container}> | ||
<ThemedText style={styles.title}>Connections</ThemedText> | ||
{data.connections.map((item, index) => ( | ||
<ThemedView | ||
key={`${item.id}-${item.institution.id}`} | ||
style={ | ||
index === data.connections.length - 1 ? styles.listItemLast : styles.listItem | ||
} | ||
> | ||
<ThemedText>ID: {item.institution.id}</ThemedText> | ||
<ThemedText>Name: {item.institution.name}</ThemedText> | ||
</ThemedView> | ||
))} | ||
</ThemedView> | ||
) : null} | ||
</ThemedView> | ||
)} | ||
</PageView> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
gap: 4, | ||
marginBottom: 16, | ||
}, | ||
title: { | ||
fontSize: 24, | ||
fontWeight: 'bold', | ||
marginTop: 8, | ||
}, | ||
listItem: { | ||
gap: 2, | ||
borderBottomColor: Colors.light.muted, | ||
borderBottomWidth: 1, | ||
paddingVertical: 8, | ||
}, | ||
listItemLast: { | ||
gap: 2, | ||
borderBottomColor: Colors.light.muted, | ||
borderBottomWidth: 0, | ||
paddingVertical: 8, | ||
}, | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// TODO: Not currently in use, but would be great if we could just link local packages | ||
|
||
/** | ||
* Link local packages in React Native, metro doesn't like symlink. | ||
* This is only for using the example app, you shouldn't need this in your app. | ||
* Adding `@quiltt/react-native` in `package.json` should work just fine. | ||
* | ||
* @see https://medium.com/@alielmajdaoui/linking-local-packages-in-react-native-the-right-way-2ac6587dcfa2 | ||
* | ||
* @see https://docs.expo.io/guides/customizing-metro | ||
*/ | ||
|
||
const path = require('path') | ||
const { getDefaultConfig } = require('@expo/metro-config') | ||
|
||
const root = path.resolve(__dirname, '..', '..') | ||
const packages = path.resolve(root, 'packages') | ||
|
||
const defaultConfig = getDefaultConfig(__dirname) | ||
|
||
const siblings = { | ||
// Enable this to import local package | ||
'@quiltt/react-native': path.resolve(packages, 'react-native', 'dist'), | ||
} | ||
|
||
module.exports = { | ||
...defaultConfig, | ||
projectRoot: __dirname, | ||
transformer: { | ||
...defaultConfig.transformer, | ||
getTransformOptions: async () => ({ | ||
...defaultConfig.transformer.getTransformOptions(), | ||
transform: { | ||
experimentalImportSupport: false, | ||
inlineRequires: false, | ||
}, | ||
}), | ||
}, | ||
resolver: { | ||
...defaultConfig.resolver, | ||
extraNodeModules: new Proxy( | ||
{}, | ||
{ | ||
get: (_target, name) => | ||
name in siblings ? siblings[name] : path.resolve(process.cwd(), 'node_modules', name), | ||
} | ||
), | ||
}, | ||
server: { | ||
...defaultConfig.server, | ||
enhanceMiddleware: (middleware) => { | ||
return (req, res, next) => { | ||
// When an asset is imported outside the project root, it has wrong path on Android | ||
// So we fix the path to correct one | ||
if (/\/packages\/.+\.png\?.+$/.test(req.url)) { | ||
req.url = `/assets/../${req.url}` | ||
} | ||
|
||
return middleware(req, res, next) | ||
} | ||
}, | ||
}, | ||
watchFolders: [...defaultConfig.watchFolders, root, ...Object.values(siblings)], | ||
} |