Skip to content

Commit

Permalink
Add expo template to create-app (#1021)
Browse files Browse the repository at this point in the history
* initial copy

* fix mrl

* convert to hbs

* more templating

* rename expo package

* fix expo package.json

* fix expo template

* add chngeset

* remove example

* add override to expo template

* fix cspell

* fix lint issues

* fix web mode

* fix readme

* Fix cli test

* Add deps needed for build command

* fix expo example

* remove widget example

* remove lint from expo

* generate examples

* fix tests

* fix mrl

* Fix gitignore

* fix gitignore

* fix mrl again

* resolve conflict

* fix override

---------

Co-authored-by: Eric Anderson <[email protected]>
  • Loading branch information
ewitkon and ericanderson authored Dec 6, 2024
1 parent 9472692 commit ef09e2d
Show file tree
Hide file tree
Showing 102 changed files with 20,750 additions and 8,981 deletions.
6 changes: 6 additions & 0 deletions .changeset/empty-dots-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@osdk/create-app.template.expo.v2": patch
"@osdk/create-app": patch
---

Add Expo template to create-app
5 changes: 4 additions & 1 deletion .lintstagedrc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export default {
], {});

const mrlCommands = mrlFiles.length > 0
? ["monorepolint check --verbose", `dprint fmt ${mrlFiles.join(" ")}`]
? [
"monorepolint check --verbose",
`dprint fmt ${mrlFiles.join(" ")} --allow-no-files`,
]
: [];

return [...mrlCommands];
Expand Down
3 changes: 3 additions & 0 deletions examples/example-expo-sdk-2.x/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EXPO_PUBLIC_FOUNDRY_API_URL=https://fake.palantirfoundry.com
EXPO_PUBLIC_FOUNDRY_REDIRECT_URL=http://localhost:8080/auth/callback
EXPO_PUBLIC_FOUNDRY_CLIENT_ID=123
3 changes: 3 additions & 0 deletions examples/example-expo-sdk-2.x/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EXPO_PUBLIC_FOUNDRY_API_URL=https://fake.palantirfoundry.com
EXPO_PUBLIC_FOUNDRY_REDIRECT_URL=https://example.com/auth/callback
EXPO_PUBLIC_FOUNDRY_CLIENT_ID=123
23 changes: 23 additions & 0 deletions examples/example-expo-sdk-2.x/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
node_modules
.expo/
dist
npm-debug.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision
*.orig.*
web-build/

# macOS
.DS_Store

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

expo-env.d.ts
# @end expo-cli

.env
env.ts
11 changes: 11 additions & 0 deletions examples/example-expo-sdk-2.x/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# example-expo

This project was generated with [`@osdk/create-app`](https://www.npmjs.com/package/@osdk/create-app) from the `expo` template. It is built against a locally generated SDK and a non-existent Foundry stack, so it is intended for reference purposes only.

To quickly create your own version of this template run the following command and answer the prompts based on your Developer Console application:

```
npm create @osdk/app@latest -- --template expo --sdkVersion 2.x
```

Alternatively check out the Developer Console docs for a full guide on creating and deploying frontend applications with the Ontology SDK.
41 changes: 41 additions & 0 deletions examples/example-expo-sdk-2.x/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"expo": {
"name": "example-expo-sdk-2.x",
"slug": "example-expo-sdk-2.x",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "my-app",
"userInterfaceStyle": "automatic",
"newArchEnabled": true,
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/images/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"web": {
"bundler": "metro",
"output": "static",
"favicon": "./assets/images/favicon.png"
},
"plugins": [
"expo-router",
[
"expo-splash-screen",
{
"image": "./assets/images/splash-icon.png",
"imageWidth": 200,
"resizeMode": "contain",
"backgroundColor": "#ffffff"
}
]
],
"experiments": {
"typedRoutes": true
}
}
}
60 changes: 60 additions & 0 deletions examples/example-expo-sdk-2.x/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Tabs } from "expo-router";
import React from "react";
import { Platform } from "react-native";

import { HapticTab } from "@/components/HapticTab";
import { IconSymbol } from "@/components/ui/IconSymbol";
import TabBarBackground from "@/components/ui/TabBarBackground";
import { Colors } from "@/constants/Colors";
import { useColorScheme } from "@/hooks/useColorScheme";

export default function TabLayout() {
const colorScheme = useColorScheme();

return (
<Tabs
initialRouteName="login"
screenOptions={{
tabBarActiveTintColor: Colors[colorScheme ?? "light"].tint,
headerShown: false,
tabBarButton: HapticTab,
tabBarBackground: TabBarBackground,
tabBarStyle: Platform.select({
ios: {
// Use a transparent background on iOS to show the blur effect
position: "absolute",
},
default: {},
}),
}}
>
<Tabs.Screen
name="login"
options={{
title: "Login",
tabBarIcon: ({ color }) => (
<IconSymbol size={28} name="lock.shield.fill" color={color} />
),
}}
/>
<Tabs.Screen
name="index"
options={{
title: "Home",
tabBarIcon: ({ color }) => (
<IconSymbol size={28} name="house.fill" color={color} />
),
}}
/>
<Tabs.Screen
name="explore"
options={{
title: "Explore",
tabBarIcon: ({ color }) => (
<IconSymbol size={28} name="paperplane.fill" color={color} />
),
}}
/>
</Tabs>
);
}
159 changes: 159 additions & 0 deletions examples/example-expo-sdk-2.x/app/(tabs)/explore.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import { StyleSheet, Image, Platform } from 'react-native';

import { Collapsible } from '@/components/Collapsible';
import { ExternalLink } from '@/components/ExternalLink';
import ParallaxScrollView from '@/components/ParallaxScrollView';
import { ThemedText } from '@/components/ThemedText';
import { ThemedView } from '@/components/ThemedView';
import { IconSymbol } from '@/components/ui/IconSymbol';
import { $Actions, $Objects, $Queries } from "@osdk/e2e.generated.catchall";

export default function TabTwoScreen() {
const objectApiNames = Object.keys($Objects);
const actionApiNames = Object.keys($Actions);
const queryApiNames = Object.keys($Queries);
const colors = { light: '#D0D0D0', dark: '#353636' };
return (
<ParallaxScrollView
headerBackgroundColor={colors}
headerImage={
<IconSymbol
size={310}
color="#808080"
name="chevron.left.forwardslash.chevron.right"
style={styles.headerImage}
/>
}>
<ThemedView style={styles.titleContainer}>
<ThemedText type="title">Explore</ThemedText>
</ThemedView>
<ThemedText>This app includes example code to help you get started.</ThemedText>
<Collapsible title="Ontology SDK" open={true}>
<ThemedText>
This app is based on the default Expo template, enriched with the Ontology SDK.
<ThemedText type="defaultSemiBold">app/(tabs)/login.tsx</ThemedText> demonstrate how to use `PublicClientAuth` to login to your Foundry stack, and {' '}
<ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> shows how to list objects in your SDK.
</ThemedText>
<ThemedView style={styles.osdkContainer}>
<ThemedText type="title">Objects ({objectApiNames.length})</ThemedText>
{objectApiNames.map((objectApiName) => (
<ThemedText type='defaultSemiBold' key={objectApiName}>
client.ontology.objects.{objectApiName}
</ThemedText>
))}
</ThemedView>
<ThemedView style={styles.osdkContainer}>
<ThemedText type="title">Actions ({actionApiNames.length})</ThemedText>
{actionApiNames.map((actionApiName) => (
<ThemedText type='defaultSemiBold' key={actionApiName}>
client.ontology.actions.{actionApiName}
</ThemedText>
))}
</ThemedView>
<ThemedView style={styles.osdkContainer}>
<ThemedText type="title">Queries ({queryApiNames.length})</ThemedText>
{queryApiNames.map((queryApiName) => (
<ThemedText type='defaultSemiBold' key={queryApiName}>
client.ontology.queries.{queryApiName}
</ThemedText>
))}
</ThemedView>
</Collapsible>
<Collapsible title="Expo default examples">
<Collapsible title="File-based routing">
<ThemedText>
This app has two screens:{' '}
<ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> and{' '}
<ThemedText type="defaultSemiBold">app/(tabs)/explore.tsx</ThemedText>
</ThemedText>
<ThemedText>
The layout file in <ThemedText type="defaultSemiBold">app/(tabs)/_layout.tsx</ThemedText>{' '}
sets up the tab navigator.
</ThemedText>
<ExternalLink href="https://docs.expo.dev/router/introduction">
<ThemedText type="link">Learn more</ThemedText>
</ExternalLink>
</Collapsible>
<Collapsible title="Android, iOS, and web support">
<ThemedText>
You can open this project on Android, iOS, and the web. To open the web version, press{' '}
<ThemedText type="defaultSemiBold">w</ThemedText> in the terminal running this project.
</ThemedText>
</Collapsible>
<Collapsible title="Images">
<ThemedText>
For static images, you can use the <ThemedText type="defaultSemiBold">@2x</ThemedText> and{' '}
<ThemedText type="defaultSemiBold">@3x</ThemedText> suffixes to provide files for
different screen densities
</ThemedText>
<Image source={require('@/assets/images/react-logo.png')} style={styles.alignToCenter} />
<ExternalLink href="https://reactnative.dev/docs/images">
<ThemedText type="link">Learn more</ThemedText>
</ExternalLink>
</Collapsible>
<Collapsible title="Custom fonts">
<ThemedText>
Open <ThemedText type="defaultSemiBold">app/_layout.tsx</ThemedText> to see how to load{' '}
<ThemedText style={styles.font}>
custom fonts such as this one.
</ThemedText>
</ThemedText>
<ExternalLink href="https://docs.expo.dev/versions/latest/sdk/font">
<ThemedText type="link">Learn more</ThemedText>
</ExternalLink>
</Collapsible>
<Collapsible title="Light and dark mode components">
<ThemedText>
This template has light and dark mode support. The{' '}
<ThemedText type="defaultSemiBold">useColorScheme()</ThemedText> hook lets you inspect
what the user's current color scheme is, and so you can adjust UI colors accordingly.
</ThemedText>
<ExternalLink href="https://docs.expo.dev/develop/user-interface/color-themes/">
<ThemedText type="link">Learn more</ThemedText>
</ExternalLink>
</Collapsible>
<Collapsible title="Animations">
<ThemedText>
This template includes an example of an animated component. The{' '}
<ThemedText type="defaultSemiBold">components/HelloWave.tsx</ThemedText> component uses
the powerful <ThemedText type="defaultSemiBold">react-native-reanimated</ThemedText>{' '}
library to create a waving hand animation.
</ThemedText>
{Platform.select({
ios: (
<ThemedText>
The <ThemedText type="defaultSemiBold">components/ParallaxScrollView.tsx</ThemedText>{' '}
component provides a parallax effect for the header image.
</ThemedText>
),
})}
</Collapsible>
</Collapsible>
</ParallaxScrollView>
);
}

const styles = StyleSheet.create({
headerImage: {
color: '#808080',
bottom: -90,
left: -35,
position: 'absolute',
},
titleContainer: {
flexDirection: 'row',
gap: 8,
},
osdkContainer: {
display: 'flex',
paddingTop: 10,
paddingBottom: 10,
gap: 8,
},
alignToCenter: {
alignSelf: 'center',
},
font: {
fontFamily: 'space-mono',
},
});
Loading

0 comments on commit ef09e2d

Please sign in to comment.