import React from 'react'; import {StyleSheet, View, Text , Button } from 'react-native'; import { Icon } from 'react-native-elements' 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 ?
this.hide()}> {this.items.map((item) => { let { text, ...rest } = item; return {item.text} })}
: null; } } export default class MainBar extends BaseSystem { constructor(CS){ super(); this.__save = null this.CoreSystem = CS; this.Menu = new Menu(); this.Menu.addItem({ text: "New page", onClick: () => this.createPage() }).addItem({ text: "Save", onClick: () => this.save() }).addItem({ text: "Export", onClick: () => this.export() }).onUpdate(() => this.forceUpdate()); } export() { let json = JSON.stringify(this.CoreSystem.export()); console.log(json); } onSave(fn){ this.__save = fn; } save(){ this.__save && this.__save(); } triggerSave(){ this.save(); } createPage() { // think! // Create a new page on CoreSystem // switch to it as active view // Decide how page switching works } none(){ } toggleMenu() { this.Menu.toggle(); } showMenu() { this.Menu.show(); } hideMenu() { this.Menu.hide(); } render(){ return (