Merge pull request #2968 from troggy/addon-system

Addon support
This commit is contained in:
Gustavo Maximiliano Cortez 2015-07-16 12:00:54 -03:00
commit b580c3429d
9 changed files with 95 additions and 15 deletions

View file

@ -0,0 +1,5 @@
<div class="medium-2 small-2 columns text-center bottombar-item">
<a ng-click="showPlugins ? showPlugins = false : showPlugins = true" class="menu-toggle">
<i class="size-24 db" ng-class="{ 'icon-arrow-left': showPlugins, 'icon-arrow-right' : !showPlugins }"> </i>
</a>
</div>

View file

@ -1,5 +1,21 @@
<div class="bottom-bar row collapse">
<div class="medium-3 small-3 columns text-center bottombar-item" ng-repeat="item in index.menu">
<div class="bottom-bar second-bottom-bar row collapse animated slideInRight" ng-class="{ 'slideOutRight': !showPlugins }" ng-show="index.menu.length > 6">
<div class="medium-{{index.menuItemSize}} small-{{index.menuItemSize}} columns text-center bottombar-item" ng-repeat="item in index.menu | limitTo: 5 - index.menu.length">
<a ng-click="index.setTab(item.link)" ng-class="{'active': index.tab == item.link}" id="menu-{{item.link}}">
<i class="size-24 {{item.icon}} db"></i>
<div class="size-10 tu">
{{item.title|translate}}
</div>
</a>
</div>
<div class="medium-{{index.menuItemSize}} small-{{index.menuItemSize}} columns text-center bottombar-item" ng-repeat="n in index.menu | limitTo: 4 - index.menu.length % 6">
<a></a>
</div>
<menu-toggle ng-show="index.menu.length > 6"/>
</div>
<div class="bottom-bar row collapse">
<div class="medium-{{index.menuItemSize}} small-{{index.menuItemSize}} columns text-center bottombar-item" ng-repeat="item in index.menu | limitTo: (index.menu.length > 6 ? 5 : 6)">
<a ng-click="index.setTab(item.link)" ng-class="{'active': index.tab == item.link}" id="menu-{{item.link}}">
<i class="size-24 {{item.icon}} db"></i>
<div class="size-10 tu">
@ -10,4 +26,12 @@
</div>
</a>
</div>
<div class="medium-2 small-2 columns text-center bottombar-item" ng-show="index.menu.length == 5">
<a></a>
</div>
<menu-toggle ng-show="index.menu.length > 6"/>
</div>

View file

@ -515,6 +515,9 @@
<div class="extra-margin-bottom"></div>
</div> <!-- END History -->
<div id="{{view.id}}" class="{{view.class}} tab-view" ng-repeat="view in index.addonViews" ng-include="view.template">
</div>
</div>
</div>
<div class="extra-margin-bottom"></div>

View file

@ -151,6 +151,20 @@ _:-ms-fullscreen, :root .main {
background: #2C3E50;
}
.second-bottom-bar {
z-index: 6;
}
.second-bottom-bar.animated.slideInRight,
.second-bottom-bar.animated.slideInLeft {
-webkit-animation-duration: 0.3s;
animation-duration: 0.3s;
}
.menu-toggle {
padding-top: 1rem !important;
}
.amount {
width: 100%;
text-align: center;

View file

@ -12,7 +12,8 @@ var modules = [
'copayApp.filters',
'copayApp.services',
'copayApp.controllers',
'copayApp.directives'
'copayApp.directives',
'copayApp.addons'
];
var copayApp = window.copayApp = angular.module('copayApp', modules);
@ -21,3 +22,5 @@ angular.module('copayApp.filters', []);
angular.module('copayApp.services', []);
angular.module('copayApp.controllers', []);
angular.module('copayApp.directives', []);
angular.module('copayApp.addons', []);

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit) {
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager) {
var self = this;
self.isCordova = isCordova;
self.onGoingProcess = {};
@ -34,6 +34,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
'link': 'history'
}];
self.addonViews = addonManager.addonViews();
self.menu = self.menu.concat(addonManager.addonMenuItems());
self.menuItemSize = self.menu.length > 4 ? 2 : 3;
self.tab = 'walletHome';
self.availableLanguages = [{
@ -279,6 +283,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.otherWallets = lodash.filter(profileService.getWallets(self.network), function(w) {
return w.id != self.walletId;
});;
// Notify external addons or plugins
$rootScope.$emit('Local/BalanceUpdated', walletStatus.balance);
$rootScope.$apply();
if (opts.triggerTxUpdate) {
@ -555,7 +563,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}
});
}, false);
chooser.click();
chooser.click();
}
function formatDate(date) {

View file

@ -296,4 +296,11 @@ angular.module('copayApp.directives')
});
}
};
})
.directive('menuToggle', function() {
return {
restrict: 'E',
replace: true,
templateUrl: 'views/includes/menu-toggle.html'
}
});

View file

@ -0,0 +1,26 @@
'use strict';
angular.module('copayApp.services').provider('addonManager', function () {
var addonMenuItems = [];
var addonViews = [];
this.registerAddon = function(addonSpec) {
addonMenuItems.push(addonSpec.menuItem);
addonViews.push(addonSpec.view);
};
this.$get = function() {
var manager = {};
manager.addonMenuItems = function() {
return addonMenuItems;
};
manager.addonViews = function() {
return addonViews;
};
return manager;
}
});

View file

@ -1,10 +0,0 @@
'use strict';
angular.module('copayApp.services').factory('pluginManager', function() {
var root = {};
root.getInstance = function(config){
return new copay.PluginManager(config);
};
return root;
});