Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: react native #6

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions examples/expo-react-native/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/

# Native
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo
155 changes: 155 additions & 0 deletions examples/expo-react-native/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import {
StyleSheet,
View,
Modal,
Pressable,
Text,
ScrollView,
} from "react-native";
import React, { useState } from "react";

import "./global.css";
import { Creation } from "./src/creation";
import { Cast } from "./src/cast";

export default function App() {
return (
<View style={styles.container}>
<RenderCreation />
<RenderCasts />
</View>
);
}

function RenderCreation() {
const [modalVisible, setModalVisible] = useState(false);
return (
<View className="px-4 pt-4">
<Modal
animationType="slide"
transparent={true}
visible={modalVisible}
onRequestClose={() => {}}
>
<View style={styles.centeredView}>
<View style={styles.modalView}>
<Creation onClose={() => setModalVisible(false)} />
</View>
</View>
</Modal>
<Pressable
style={[styles.button, styles.buttonOpen]}
onPress={() => setModalVisible(true)}
>
<Text style={styles.textStyle}>New Post</Text>
</Pressable>
</View>
);
}

function RenderCasts() {
return (
<ScrollView className="py-4 border-b border-slate-200">
<Cast
cast={{
avatar_url:
"https://res.cloudinary.com/merkle-manufactory/image/fetch/c_fill,f_png,w_144/https%3A%2F%2Flh3.googleusercontent.com%2F-S5cdhOpZtJ_Qzg9iPWELEsRTkIsZ7qGYmVlwEORgFB00WWAtZGefRnS4Bjcz5ah40WVOOWeYfU5pP9Eekikb3cLMW2mZQOMQHlWhg",
display_name: "David Furlong",
username: "df",
timestamp: "2023-08-17 09:16:52.293739",
text: "[Automated] @df just starred the repo 0xOlias/ponder on Github",
embeds: [
{
type: "url",
openGraph: {
url: "https://www.github.com/0xOlias/ponder",
image:
"https://opengraph.githubassets.com/dc3ad0a62f7156e3e055d38d5fe752540c446797089d9cc82467304244c028f3/0xOlias/ponder",
title:
"0xOlias/ponder: A framework for blockchain application backends",
domain: "github.com",
},
},
],
}}
/>
<Cast
cast={{
avatar_url:
"https://res.cloudinary.com/merkle-manufactory/image/fetch/c_fill,f_png,w_144/https%3A%2F%2Flh3.googleusercontent.com%2F-S5cdhOpZtJ_Qzg9iPWELEsRTkIsZ7qGYmVlwEORgFB00WWAtZGefRnS4Bjcz5ah40WVOOWeYfU5pP9Eekikb3cLMW2mZQOMQHlWhg",
display_name: "David Furlong",
username: "df",
timestamp: "2023-08-17 09:16:52.293739",
text: "[Automated] @df just starred the repo 0xOlias/ponder on Github",
embeds: [
{
type: "image",
url: "https://opengraph.githubassets.com/dc3ad0a62f7156e3e055d38d5fe752540c446797089d9cc82467304244c028f3/0xOlias/ponder",
sourceUrl:
"https://opengraph.githubassets.com/dc3ad0a62f7156e3e055d38d5fe752540c446797089d9cc82467304244c028f3/0xOlias/ponder",
alt: "Github",
},
],
}}
/>
</ScrollView>
);
}

const styles = StyleSheet.create({
centeredView: {
// flex: 1,
// flexGrow: 1,
// flexDirection: "column",
backgroundColor: "white",
alignItems: "center",
// alignSelf: "stretch",
},
modalView: {
marginHorizontal: 40,
backgroundColor: "white",
borderRadius: 20,
padding: 0,
width: "100%",
height: "100%",
alignItems: "center",
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,
},
button: {
borderRadius: 20,
padding: 10,
elevation: 2,
},
buttonOpen: {
backgroundColor: "#F194FF",
},
buttonClose: {
backgroundColor: "#2196F3",
},
textStyle: {
color: "white",
fontWeight: "bold",
textAlign: "center",
},
modalText: {
marginBottom: 15,
textAlign: "center",
},
container: {
flex: 1,
marginTop: 50,
flexGrow: 1,
flexDirection: "column",
backgroundColor: "white",
alignItems: "stretch",
alignSelf: "stretch",
// justifyContent: "stretch",
},
});
30 changes: 30 additions & 0 deletions examples/expo-react-native/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"expo": {
"name": "expo-react-native",
"slug": "expo-react-native",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/expo-react-native/assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/expo-react-native/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/expo-react-native/assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions examples/expo-react-native/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// babel.config.js
module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
plugins: ["nativewind/babel"],
};
};
4 changes: 4 additions & 0 deletions examples/expo-react-native/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// global.css
@tailwind base;
@tailwind components;
@tailwind utilities;
8 changes: 8 additions & 0 deletions examples/expo-react-native/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { registerRootComponent } from "expo";

import App from "./App";

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App);
22 changes: 22 additions & 0 deletions examples/expo-react-native/metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { getDefaultConfig } = require("expo/metro-config");
const path = require("path");

// Find the project and workspace directories
const projectRoot = __dirname;
// This can be replaced with `find-yarn-workspace-root`
const workspaceRoot = path.resolve(projectRoot, "../..");

const config = getDefaultConfig(projectRoot, { isCSSEnabled: true });

// 1. Watch all files within the monorepo
config.watchFolders = [workspaceRoot];
// 2. Let Metro know where to resolve packages and in what order
config.resolver.nodeModulesPaths = [
path.resolve(projectRoot, "node_modules"),
path.resolve(workspaceRoot, "node_modules"),
path.resolve(workspaceRoot, "packages"),
];
// 3. Force Metro to resolve (sub)dependencies only from the `nodeModulesPaths`
config.resolver.disableHierarchicalLookup = true;

module.exports = config;
33 changes: 33 additions & 0 deletions examples/expo-react-native/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "expo-react-native",
"version": "1.0.0",
"main": "./index.js",
"private": true,
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"expo": "~49.0.7",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"expo-image": "^1.3.2",
"react-native": "0.72.3",
"nativewind": "^2.0.11",
"@packages/creation-react-native-headless": "*"
},
"devDependencies": {
"tailwindcss": "3.3.2",
"@babel/core": "^7.20.0",
"@types/node": "^20.4.10",
"@types/react": "^18.2.20",
"typescript": "^5.1.3"
},
"workspaces": [
"configs/*",
"packages/*",
"examples/*"
]
}
6 changes: 6 additions & 0 deletions examples/expo-react-native/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// postcss.config.js
module.exports = {
plugins: {
tailwindcss: {},
},
};
17 changes: 17 additions & 0 deletions examples/expo-react-native/src/bottom-bar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";
import { Pressable, StyleSheet, Text, View } from "react-native";

export function BottomBar(props: { onOpenMiniAppsModal: () => void }) {
return (
<View className="border-t-2 border-t-slate-300 flex flex-col bg-white px-2">
<Pressable
className="p-2"
onPress={() => {
props.onOpenMiniAppsModal();
}}
>
<Text className="text-xl">+</Text>
</Pressable>
</View>
);
}
52 changes: 52 additions & 0 deletions examples/expo-react-native/src/bottom-modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from "react";

import {
Modal,
SafeAreaView,
View,
StyleSheet,
TouchableOpacity,
Text,
} from "react-native";

export const BottomModal = ({
open,
setModalOpen,
onRequestClose,
modalBackgroundStyle,
modalOptionsContainerStyle,
modalProps,
children,
}: any) => {
if (!open) return null;
return (
<TouchableOpacity
onPress={() => setModalOpen?.(false)}
style={[
styles.modalContainer,
styles.modalOptionsContainer,
modalBackgroundStyle,
]}
>
<SafeAreaView style={[modalOptionsContainerStyle]}>
{children}
</SafeAreaView>
</TouchableOpacity>
);
};

const styles = StyleSheet.create({
modalContainer: {
flex: 1,
},
// modalBackgroundStyle: { backgroundColor: "rgba(0, 0, 0, 0.5)" },
modalOptionsContainer: {
maxHeight: "50%",
borderColor: "#ccc",
borderWidth: 1,
borderBottomWidth: 0,
backgroundColor: "#fff",
borderTopLeftRadius: 16,
borderTopRightRadius: 16,
},
});
Loading