imports/ui/layouts/app-body.js
import './app-body.html';
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { ReactiveDict } from 'meteor/reactive-dict';
import { Template } from 'meteor/peerlibrary:blaze-components';
import { TabBar } from 'meteor/flextab';
import '../components/loader/loading.js';
import '../components/flex-tab-bar/default-tab-bars.js';
import '../components/flex-tab-bar/flex-tab-bar.js';
import '../components/account/account-box.js';
import '../components/circuits-list.js';
const CONNECTION_ISSUE_TIMEOUT = 5000;
// A store which is local to this file?
const showConnectionIssue = new ReactiveVar(false);
Meteor.startup(() => {
// Only show the connection error box if it has been 5 seconds since
// the app started
setTimeout(() => {
// FIXME:
// Launch screen handle created in lib/router.js
// dataReadyHold.release();
// Show the connection error box
showConnectionIssue.set(true);
}, CONNECTION_ISSUE_TIMEOUT);
});
Template.App_body.onCreated(function appBodyOnCreated() {
this.state = new ReactiveDict();
this.state.setDefault({
menuOpen: false,
});
});
Template.App_body.helpers({
menuOpen() {
const instance = Template.instance();
return instance.state.get('menuOpen') && 'menu-open';
},
cordova() {
return Meteor.isCordova && 'cordova';
},
connected() {
if (showConnectionIssue.get()) {
return Meteor.status().connected;
}
return true;
},
templateGestures: {
'swipeleft .cordova'(event, instance) {
instance.state.set('menuOpen', false);
},
'swiperight .cordova'(event, instance) {
instance.state.set('menuOpen', true);
},
},
flexOpened() {
return TabBar.isFlexOpen() ? 'flex-opened' : '';
},
flexTemplate() {
return TabBar.getTemplate();
},
flexData() {
return TabBar.getData();
},
});
Template.App_body.events({
'click .js-menu'(event, instance) {
instance.state.set('menuOpen', !instance.state.get('menuOpen'));
},
'click #menu button'(event, instance) {
instance.state.set('menuOpen', false);
},
});