Skip to content

Commit

Permalink
Remove separate Menu file on the client
Browse files Browse the repository at this point in the history
  • Loading branch information
wokalski committed Feb 13, 2020
1 parent 51fb89f commit 1811b94
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 39 deletions.
40 changes: 36 additions & 4 deletions RestaurantMenu/client/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,49 @@
* @format
*/

import React from 'react';
import {StatusBar} from 'react-native';
import {Menu} from './Menu';
import * as React from 'react';
import {
Alert,
Text,
SafeAreaView,
StyleSheet,
View,
StatusBar,
} from 'react-native';
import {config} from 'RestaurantMenu-config';
import * as Nars from 'nars-client';

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

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

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

const App = () => {
return (
<>
<StatusBar barStyle="light-content" />
<Menu />
<SafeAreaView>
<View style={styles.headerContainer}>
<Text style={styles.header}>{'Menu'}</Text>
</View>
<Menu
onMenuItemSelected={(_, title) => {
Alert.alert(`Tapped "${title}"`);
}}
/>
</SafeAreaView>
</>
);
};
Expand Down
35 changes: 0 additions & 35 deletions RestaurantMenu/client/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +0,0 @@
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>
);
1 change: 1 addition & 0 deletions RestaurantMenu/config/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { InputProp, localCallback } from "nars-common";
* Define Routes and the props
*/
const title = InputProp.string;

export const config = {
Menu: {
onMenuItemSelected: localCallback(InputProp.void, title)
Expand Down

0 comments on commit 1811b94

Please sign in to comment.