|
@@ -2,11 +2,51 @@ import React from 'react';
|
|
import {StyleSheet, View, Text , Button } from 'react-native';
|
|
import {StyleSheet, View, Text , Button } from 'react-native';
|
|
import { Icon } from 'react-native-elements'
|
|
import { Icon } from 'react-native-elements'
|
|
import { TextInput } from 'react-native';
|
|
import { TextInput } from 'react-native';
|
|
|
|
+import BaseSystem from './System'
|
|
|
|
|
|
|
|
+class Menu extends BaseSystem {
|
|
|
|
+ constructor() {
|
|
|
|
+ super();
|
|
|
|
+ this.items = [];
|
|
|
|
+ }
|
|
|
|
+ addItem(item) {
|
|
|
|
+ this.items.push(item);
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+ show() { this.visible = true; this.forceUpdate() }
|
|
|
|
+ hide() { this.visible = false; this.forceUpdate() }
|
|
|
|
+ toggle() { this.visible = !this.visible; this.forceUpdate() }
|
|
|
|
+ render() {
|
|
|
|
+ return this.visible ? <div style={{position:'absolute', left: 0, top: 50}}
|
|
|
|
+ onMouseLeave={() => this.hide()}>
|
|
|
|
+ <View style={styles.menu}>
|
|
|
|
+ {this.items.map((item) => {
|
|
|
|
+ let {
|
|
|
|
+ text,
|
|
|
|
+ ...rest
|
|
|
|
+ } = item;
|
|
|
|
+ return <View style={{cursor: 'pointer'}} {...rest}>
|
|
|
|
+ <Text>{item.text}</Text>
|
|
|
|
+ </View>
|
|
|
|
+ })}
|
|
|
|
+ </View>
|
|
|
|
+ </div> : null;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
-export default class MainBar{
|
|
|
|
|
|
+export default class MainBar extends BaseSystem {
|
|
constructor(){
|
|
constructor(){
|
|
|
|
+ super();
|
|
this.__save = null
|
|
this.__save = null
|
|
|
|
+
|
|
|
|
+ this.Menu = new Menu();
|
|
|
|
+ this.Menu.addItem({
|
|
|
|
+ text: "New page",
|
|
|
|
+ onClick: () => this.createPage()
|
|
|
|
+ }).addItem({
|
|
|
|
+ text: "Save",
|
|
|
|
+ onClick: () => this.save()
|
|
|
|
+ }).onUpdate(() => this.forceUpdate());
|
|
}
|
|
}
|
|
|
|
|
|
onSave(fn){
|
|
onSave(fn){
|
|
@@ -20,8 +60,26 @@ export default class MainBar{
|
|
triggerSave(){
|
|
triggerSave(){
|
|
this.save();
|
|
this.save();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ createPage() {
|
|
|
|
+ // think!
|
|
|
|
+ // Create a new page on CoreSystem
|
|
|
|
+ // switch to it as active view
|
|
|
|
+ // Decide how page switching works
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
none(){
|
|
none(){
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ toggleMenu() {
|
|
|
|
+ this.Menu.toggle();
|
|
|
|
+ }
|
|
|
|
+ showMenu() {
|
|
|
|
+ this.Menu.show();
|
|
|
|
+ }
|
|
|
|
+ hideMenu() {
|
|
|
|
+ this.Menu.hide();
|
|
}
|
|
}
|
|
render(){
|
|
render(){
|
|
return (
|
|
return (
|
|
@@ -29,29 +87,29 @@ export default class MainBar{
|
|
<Button
|
|
<Button
|
|
color="#f1f1f1"
|
|
color="#f1f1f1"
|
|
title={<Icon name='menu'
|
|
title={<Icon name='menu'
|
|
- color="#606060"
|
|
|
|
|
|
+ color="#606060"
|
|
/>}
|
|
/>}
|
|
- />
|
|
|
|
|
|
+ onPress={(e) => this.toggleMenu()}
|
|
|
|
+ />
|
|
<Button
|
|
<Button
|
|
color="#f1f1f1"
|
|
color="#f1f1f1"
|
|
title={<Icon name='home'
|
|
title={<Icon name='home'
|
|
- color="#606060"
|
|
|
|
|
|
+ color="#606060"
|
|
/>}
|
|
/>}
|
|
- />
|
|
|
|
|
|
+ />
|
|
<Text style={{height:30,width:80,fontSize:11,marginTop:6}}>
|
|
<Text style={{height:30,width:80,fontSize:11,marginTop:6}}>
|
|
<Button
|
|
<Button
|
|
onPress={(e) => this.triggerSave()}
|
|
onPress={(e) => this.triggerSave()}
|
|
title="Save"
|
|
title="Save"
|
|
color="#606060"
|
|
color="#606060"
|
|
-
|
|
|
|
/>
|
|
/>
|
|
</Text>
|
|
</Text>
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ {this.Menu.render()}
|
|
</View>)
|
|
</View>)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
const styles = StyleSheet.create({
|
|
const styles = StyleSheet.create({
|
|
container:{
|
|
container:{
|
|
flex:1,
|
|
flex:1,
|
|
@@ -59,5 +117,10 @@ const styles = StyleSheet.create({
|
|
|
|
|
|
flexDirection:'row',
|
|
flexDirection:'row',
|
|
|
|
|
|
|
|
+ },
|
|
|
|
+ menu: {
|
|
|
|
+ height:100,
|
|
|
|
+ width: 200,
|
|
|
|
+ backgroundColor: 'gray'
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+})
|