Skip to content

Commit

Permalink
Add RestaurantMenu example
Browse files Browse the repository at this point in the history
  • Loading branch information
wokalski committed Feb 12, 2020
0 parents commit 51fb89f
Show file tree
Hide file tree
Showing 84 changed files with 13,135 additions and 0 deletions.
1 change: 1 addition & 0 deletions RestaurantMenu/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
6 changes: 6 additions & 0 deletions RestaurantMenu/client/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
6 changes: 6 additions & 0 deletions RestaurantMenu/client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
root: true,
extends: '@react-native-community',
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
};
1 change: 1 addition & 0 deletions RestaurantMenu/client/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
64 changes: 64 additions & 0 deletions RestaurantMenu/client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# Visual Studio Code
#
.vscode/

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/
6 changes: 6 additions & 0 deletions RestaurantMenu/client/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
};
1 change: 1 addition & 0 deletions RestaurantMenu/client/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
26 changes: 26 additions & 0 deletions RestaurantMenu/client/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* Generated with the TypeScript template
* https://github.com/react-native-community/react-native-template-typescript
*
* @format
*/

import React from 'react';
import {StatusBar} from 'react-native';
import {Menu} from './Menu';

declare var global: {HermesInternal: null | {}};

const App = () => {
return (
<>
<StatusBar barStyle="light-content" />
<Menu />
</>
);
};

export default App;
35 changes: 35 additions & 0 deletions RestaurantMenu/client/Menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from 'react';
import {Alert, Text, SafeAreaView, StyleSheet, View} from 'react-native';
import {config} from 'RestaurantMenu-config';
import * as Nars from 'nars-client';

const styles = StyleSheet.create({
headerContainer: {
paddingVertical: 10,
borderBottomWidth: 1,
borderBottomColor: '#EEE',
},
header: {
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
},
});

const {Menu: RemoteMenuComponent} = Nars.createRemoteComponentWithUrl(
'ws://localhost:9000',
config,
);

export const Menu = () => (
<SafeAreaView>
<View style={styles.headerContainer}>
<Text style={styles.header}>{'Menu'}</Text>
</View>
<RemoteMenuComponent
onMenuItemSelected={(_, title) => {
Alert.alert(`Tapped "${title}"`);
}}
/>
</SafeAreaView>
);
14 changes: 14 additions & 0 deletions RestaurantMenu/client/__tests__/App-test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @format
*/

import 'react-native';
import React from 'react';
import App from '../App';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
renderer.create(<App />);
});
55 changes: 55 additions & 0 deletions RestaurantMenu/client/android/app/_BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
# - `npm start` - to start the packager
# - `cd android`
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application
#

load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")

lib_deps = []

create_aar_targets(glob(["libs/*.aar"]))

create_jar_targets(glob(["libs/*.jar"]))

android_library(
name = "all-libs",
exported_deps = lib_deps,
)

android_library(
name = "app-code",
srcs = glob([
"src/main/java/**/*.java",
]),
deps = [
":all-libs",
":build_config",
":res",
],
)

android_build_config(
name = "build_config",
package = "com.restaurantmenu",
)

android_resource(
name = "res",
package = "com.restaurantmenu",
res = "src/main/res",
)

android_binary(
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
":app-code",
],
)
Loading

0 comments on commit 51fb89f

Please sign in to comment.