Skip to content

Commit bbc3d57

Browse files
committed
First pass with react native
1 parent b7219ee commit bbc3d57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+30723
-5963
lines changed

.gitignore

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,79 @@ vendor
2727

2828
.spago
2929

30-
.parcel-cache
30+
.parcel-cache
31+
32+
# OSX
33+
#
34+
.DS_Store
35+
36+
# Xcode
37+
#
38+
build/
39+
*.pbxuser
40+
!default.pbxuser
41+
*.mode1v3
42+
!default.mode1v3
43+
*.mode2v3
44+
!default.mode2v3
45+
*.perspectivev3
46+
!default.perspectivev3
47+
xcuserdata
48+
*.xccheckout
49+
*.moved-aside
50+
DerivedData
51+
*.hmap
52+
*.ipa
53+
*.xcuserstate
54+
**/.xcode.env.local
55+
56+
# Android/IntelliJ
57+
#
58+
build/
59+
.idea
60+
.gradle
61+
local.properties
62+
*.iml
63+
*.hprof
64+
.cxx/
65+
*.keystore
66+
!debug.keystore
67+
68+
# node.js
69+
#
70+
node_modules/
71+
npm-debug.log
72+
yarn-error.log
73+
74+
# fastlane
75+
#
76+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
77+
# screenshots whenever they are needed.
78+
# For more information about the recommended setup visit:
79+
# https://docs.fastlane.tools/best-practices/source-control/
80+
81+
**/fastlane/report.xml
82+
**/fastlane/Preview.html
83+
**/fastlane/screenshots
84+
**/fastlane/test_output
85+
86+
# Bundle artifact
87+
*.jsbundle
88+
89+
# Ruby / CocoaPods
90+
**/Pods/
91+
/vendor/bundle/
92+
93+
# Temporary files created by Metro to check the health of the file watcher
94+
.metro-health-check*
95+
96+
# testing
97+
/coverage
98+
99+
# Yarn
100+
.yarn/*
101+
!.yarn/patches
102+
!.yarn/plugins
103+
!.yarn/releases
104+
!.yarn/sdks
105+
!.yarn/versions

.yarn/releases/yarn-3.6.4.cjs

Lines changed: 874 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
yarnPath: .yarn/releases/yarn-3.6.4.cjs

examples.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let conf = ./spago.dhall
22

33
in conf // {
4-
sources = conf.sources # [ "examples/**/*.purs" ],
4+
sources = conf.sources # [ "examples/App/*.purs" ],
55
dependencies = conf.dependencies # [ "httpure" , "affjax", "affjax-web", "node-fs-aff", "js-timers", "web-storage"]
66
}

examples/App/.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native',
4+
};

examples/App/.gitignore

Whitespace-only changes.

examples/App/.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
bracketSameLine: true,
4+
bracketSpacing: false,
5+
singleQuote: true,
6+
trailingComma: 'all',
7+
};

examples/App/.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

examples/App/App.purs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module Examples.App.Main where
2+
3+
import Prelude
4+
5+
import Data.Maybe (Maybe(..))
6+
import Data.Tuple (Tuple)
7+
import Effect (Effect)
8+
import Effect.Aff (Aff)
9+
import Effect.Class (liftEffect)
10+
import Effect.Random as ER
11+
import Flame (AppId(..), Html, (:>))
12+
import Flame.Application.Native as FAN
13+
import Flame.Native.Attribute as HA
14+
import Flame.Native.Element as HE
15+
16+
type Model = Maybe Int
17+
18+
init Model
19+
init = Nothing
20+
21+
data Message = Roll | Update Int
22+
23+
update Model Message Tuple Model (Array (Aff (Maybe Message)))
24+
update model = case _ of
25+
Roll → model :>
26+
[ Just <<< Update <$> liftEffect (ER.randomInt 1 6)
27+
]
28+
Update int → Just int :> []
29+
30+
view Model Html Message
31+
view model = HE.text (show model)
32+
33+
-- HE.div "main"
34+
-- [ HE.text (show model)
35+
-- -- , HE.button [ HA.onClick Roll ] "Roll"
36+
-- ]
37+
38+
main Effect Unit
39+
main = FAN.mount "App"
40+
{ init: init :> []
41+
, subscribe: []
42+
, update
43+
, view
44+
}
45+

examples/App/App.tsx

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
*/
7+
8+
import React from 'react';
9+
import type {PropsWithChildren} from 'react';
10+
import {
11+
SafeAreaView,
12+
ScrollView,
13+
StatusBar,
14+
StyleSheet,
15+
Text,
16+
useColorScheme,
17+
View,
18+
} from 'react-native';
19+
20+
import {
21+
Colors,
22+
DebugInstructions,
23+
Header,
24+
LearnMoreLinks,
25+
ReloadInstructions,
26+
} from 'react-native/Libraries/NewAppScreen';
27+
28+
type SectionProps = PropsWithChildren<{
29+
title: string;
30+
}>;
31+
32+
function Section({children, title}: SectionProps): React.JSX.Element {
33+
const isDarkMode = useColorScheme() === 'dark';
34+
return (
35+
<View style={styles.sectionContainer}>
36+
<Text
37+
style={[
38+
styles.sectionTitle,
39+
{
40+
color: isDarkMode ? Colors.white : Colors.black,
41+
},
42+
]}>
43+
{title}
44+
</Text>
45+
<Text
46+
style={[
47+
styles.sectionDescription,
48+
{
49+
color: isDarkMode ? Colors.light : Colors.dark,
50+
},
51+
]}>
52+
{children}
53+
</Text>
54+
</View>
55+
);
56+
}
57+
58+
function App(): React.JSX.Element {
59+
const isDarkMode = useColorScheme() === 'dark';
60+
61+
const backgroundStyle = {
62+
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
63+
};
64+
65+
return (
66+
<SafeAreaView style={backgroundStyle}>
67+
<StatusBar
68+
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
69+
backgroundColor={backgroundStyle.backgroundColor}
70+
/>
71+
<ScrollView
72+
contentInsetAdjustmentBehavior="automatic"
73+
style={backgroundStyle}>
74+
<Header />
75+
<View
76+
style={{
77+
backgroundColor: isDarkMode ? Colors.black : Colors.white,
78+
}}>
79+
<Section title="Step One">
80+
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
81+
screen and then come back to see your edits.
82+
</Section>
83+
<Section title="See Your Changes">
84+
<ReloadInstructions />
85+
</Section>
86+
<Section title="Debug">
87+
<DebugInstructions />
88+
</Section>
89+
<Section title="Learn More">
90+
Read the docs to discover what to do next:
91+
</Section>
92+
<LearnMoreLinks />
93+
</View>
94+
</ScrollView>
95+
</SafeAreaView>
96+
);
97+
}
98+
99+
const styles = StyleSheet.create({
100+
sectionContainer: {
101+
marginTop: 32,
102+
paddingHorizontal: 24,
103+
},
104+
sectionTitle: {
105+
fontSize: 24,
106+
fontWeight: '600',
107+
},
108+
sectionDescription: {
109+
marginTop: 8,
110+
fontSize: 18,
111+
fontWeight: '400',
112+
},
113+
highlight: {
114+
fontWeight: '700',
115+
},
116+
});
117+
118+
export default App;

examples/App/Gemfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby ">= 2.6.10"
5+
6+
# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
7+
# bound in the template on Cocoapods with next React Native release.
8+
gem 'cocoapods', '>= 1.13', '< 1.15'
9+
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'

examples/App/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
2+
3+
# Getting Started
4+
5+
>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
6+
7+
## Step 1: Start the Metro Server
8+
9+
First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
10+
11+
To start Metro, run the following command from the _root_ of your React Native project:
12+
13+
```bash
14+
# using npm
15+
npm start
16+
17+
# OR using Yarn
18+
yarn start
19+
```
20+
21+
## Step 2: Start your Application
22+
23+
Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
24+
25+
### For Android
26+
27+
```bash
28+
# using npm
29+
npm run android
30+
31+
# OR using Yarn
32+
yarn android
33+
```
34+
35+
### For iOS
36+
37+
```bash
38+
# using npm
39+
npm run ios
40+
41+
# OR using Yarn
42+
yarn ios
43+
```
44+
45+
If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
46+
47+
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
48+
49+
## Step 3: Modifying your App
50+
51+
Now that you have successfully run the app, let's modify it.
52+
53+
1. Open `App.tsx` in your text editor of choice and edit some lines.
54+
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!
55+
56+
For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!
57+
58+
## Congratulations! :tada:
59+
60+
You've successfully run and modified your React Native App. :partying_face:
61+
62+
### Now what?
63+
64+
- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
65+
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
66+
67+
# Troubleshooting
68+
69+
If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
70+
71+
# Learn More
72+
73+
To learn more about React Native, take a look at the following resources:
74+
75+
- [React Native Website](https://reactnative.dev) - learn more about React Native.
76+
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
77+
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
78+
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
79+
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.

examples/App/__tests__/App.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import App from '../App';
8+
9+
// Note: import explicitly to use the types shipped with jest.
10+
import {it} from '@jest/globals';
11+
12+
// Note: test renderer must be required after react-native.
13+
import renderer from 'react-test-renderer';
14+
15+
it('renders correctly', () => {
16+
renderer.create(<App />);
17+
});

0 commit comments

Comments
 (0)