new design refactor receive tab

This commit is contained in:
Gabriel Bazán 2016-08-12 16:04:17 -03:00
parent 8e031a83ad
commit 8a1abbec6b
4 changed files with 158 additions and 4 deletions

View File

@ -20,6 +20,7 @@
<!-- <ion&#45;nav&#45;back&#45;button class="button&#45;icon ion&#45;arrow&#45;left&#45;c"> -->
<!-- </ion&#45;nav&#45;back&#45;button> -->
<!-- </ion&#45;nav&#45;bar> -->
<ion-nav-bar class="bar-stable"></ion-nav-bar>
<ion-nav-view name="main"></ion-nav-view>
<script src="lib/ionic.bundle.js"></script>

View File

@ -1,5 +1,42 @@
<ion-view view-title="Home">
<ion-content class="receive">
<h2>Welcome to Receive</h2>
<ion-view ng-controller="tabReceiveController" cache-view="false">
<ion-nav-title>Receive</ion-nav-title>
<ion-content ng-init="init()">
<div class="text-center" ng-click="copyToClipboard(addr, $event)" ng-show="addr || generatingAddress">
<qrcode size="220" data="bitcoin:{{addr}}"></qrcode>
<div ng-show="home.generatingAddress" style="position:relative; top:-226px; height:0px">
<div style="height:220px; width:220px; margin:auto; background: white">
<ion-spinner class="spinner-stable" icon="lines" style="margin-top: 85px"></ion-spinner>
</div>
</div>
</div>
<div class="item item-icon-left" ng-click="shareAddress(addr)" ng-show="index.isCordova && home.addr" ng-disabled="generatingAddress">
<i class="icon ion-ios-upload-outline"></i>
<span translate>Share address</span>
</div>
<div class="item item-icon-left" ng-click="setAddress(true)" ng-show="!home.generatingAddress">
<i class="icon ion-ios-loop"></i>
<span translate>Next Address</span>
</div>
<div class="item item-icon-left">
<i class="icon ion-social-bitcoin-outline"></i>
{{generatingAddress ? '...' : addr}}
</div>
<div class="item item-text-wrap" ng-style="{'height' : '200px'}">
<ion-slides class="slides" options="options" slider="data.slider">
<ion-slide-page ng-repeat="item in wallets track by $index" >
<div class="list card">
<ul class="pr">
<li ng-show="wallets[0]" class="item item-icon-left">
<i class="icon icon-wallet size-21" ng-style="{'color':item.color}"></i>
{{item.name || item.id}}
<span class="item-note" ng-show="item.n > 1">
{{item.m}}-of-{{item.n}}
</span>
</li>
</ul>
</div>
</ion-slide-page>
</ion-slides>
</div>
</ion-content>
</ion-view>
</ion-view>

View File

@ -28,6 +28,10 @@
display: none !important;
}
.swiper-container-horizontal>.swiper-pagination{
display: none;
}
.bar .title {
font-size: 14px;
line-height: 48px;

View File

@ -0,0 +1,112 @@
'use strict';
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $ionicPopover, $timeout, platformInfo, nodeWebkit, addressService, profileService, configService, lodash) {
$scope.init = function() {
$scope.index = 0;
$scope.isCordova = platformInfo.isCordova;
$scope.isNW = platformInfo.isNW;
$scope.setWallets();
$scope.setAddress(false);
$scope.options = {
loop: false,
effect: 'flip',
speed: 500,
spaceBetween: 100
}
$scope.$on("$ionicSlides.sliderInitialized", function(event, data) {
// data.slider is the instance of Swiper
$scope.slider = data.slider;
});
$scope.$on("$ionicSlides.slideChangeStart", function(event, data) {
console.log('Slide change is beginning');
});
$scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {
$scope.index = data.slider.activeIndex;
$scope.setAddress(false);
});
}
$scope.copyToClipboard = function(addr, $event) {
var showPopover = function() {
$ionicPopover.fromTemplateUrl('views/includes/copyToClipboard.html', {
scope: $scope
}).then(function(popover) {
$scope.popover = popover;
$scope.popover.show($event);
});
$scope.close = function() {
$scope.popover.hide();
}
$timeout(function() {
$scope.popover.hide(); //close the popover after 0.7 seconds
}, 700);
$scope.$on('$destroy', function() {
$scope.popover.remove();
});
};
if ($scope.isCordova) {
window.cordova.plugins.clipboard.copy(addr);
window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard'));
} else if ($scope.isNW) {
nodeWebkit.writeToClipboard(addr);
showPopover($event);
}
};
$scope.shareAddress = function(addr) {
if ($scope.isCordova) {
window.plugins.socialsharing.share('bitcoin:' + addr, null, null, null);
}
};
$scope.setAddress = function(forceNew) {
$scope.addrError = null;
$scope.generatingAddress = true;
$timeout(function() {
addressService.getAddress($scope.wallets[$scope.index].id, forceNew, function(err, addr) {
$scope.generatingAddress = false;
if (err) {
$scope.addrError = err;
} else {
if (addr)
$scope.addr = addr;
}
$scope.$digest();
});
});
};
$scope.setWallets = function() {
if (!profileService.profile) return;
var config = configService.getSync();
config.colorFor = config.colorFor || {};
config.aliasFor = config.aliasFor || {};
// Sanitize empty wallets (fixed in BWC 1.8.1, and auto fixed when wallets completes)
var credentials = lodash.filter(profileService.profile.credentials, 'walletName');
var ret = lodash.map(credentials, function(c) {
return {
m: c.m,
n: c.n,
name: config.aliasFor[c.walletId] || c.walletName,
id: c.walletId,
color: config.colorFor[c.walletId] || '#4A90E2',
};
});
$scope.wallets = lodash.sortBy(ret, 'name');
};
});