FEATURE: on iPhone 6 or wider show mobile toolbar by default.

FEATURE: if user enables or disables mobile toolbar, remember state in local storage.
This commit is contained in:
Sam 2016-03-07 15:50:10 +11:00
parent 995f13d442
commit ccf835e342
1 changed files with 19 additions and 1 deletions

View File

@ -57,7 +57,25 @@ export default Ember.Controller.extend({
lastValidatedAt: null, lastValidatedAt: null,
isUploading: false, isUploading: false,
topic: null, topic: null,
showToolbar: false, showToolbar: Em.computed({
get(key){
const keyValueStore = this.container.lookup('key-value-store:main');
const storedVal = keyValueStore.get("toolbar-enabled");
if (this._toolbarEnabled === undefined && storedVal === undefined) {
// iPhone 6 is 375, anything narrower and toolbar should
// be default disabled.
// That said we should remember the state
this._toolbarEnabled = $(window).width() > 370;
}
return this._toolbarEnabled || storedVal === "true";
},
set(key, val){
const keyValueStore = this.container.lookup('key-value-store:main');
this._toolbarEnabled = val;
keyValueStore.set({key: "toolbar-enabled", value: val ? "true" : "false"});
return val;
}
}),
_initializeSimilar: function() { _initializeSimilar: function() {
this.set('similarTopics', []); this.set('similarTopics', []);