Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
perf(wallets): use a modal for wallet settings and smooth transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
devinus committed Apr 2, 2018
1 parent 49fe4c6 commit 39cad40
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 165 deletions.
7 changes: 2 additions & 5 deletions app/components/navigation-bar/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@
</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">
{{#link-to 'wallets.overview.settings' wallet class="nav-link"}}
{{t 'settings'}}
{{#bs-popover placement="bottom" triggerEvents='click focus' title=(t 'walletSettings')}}
{{wallet-settings wallet=wallet representative=wallet.representative onChangeRepresentative=(action onChangeRepresentative) onChangePassword=(action onChangePassword)}}
{{/bs-popover}}
</a>
{{/link-to}}
</li>
<li class="nav-item">
{{#link-to 'wallets.logout' wallet class="nav-link"}}
Expand Down
11 changes: 6 additions & 5 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@ Router.map(function routerMap() {
});

this.route('wallets', { path: '/:wallet_id' }, function walletsRoute() {
this.route('send');
this.route('logout');

this.route('overview', function overviewRoute() {
this.route('settings');
this.route('accounts', { path: '/:account_id' }, function accountsRoute() {
this.route('send');
this.route('history');
this.route('settings');
});
});
this.route('send');
this.route('settings', function settingsRoute() {
this.route('password');
});
this.route('logout');

this.route('accounts', { path: '/:account_id' }, function accountsRoute() {
this.route('send');
this.route('history');
});
});

this.route('login');
this.route('logout');
this.route('error');
Expand Down
2 changes: 1 addition & 1 deletion app/setup/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</picture>
</h1>

{{liquid-outlet class="toLeft liquid-outlet px-2"}}
{{liquid-outlet class="setup-step px-2"}}
</div>
</div>
</section>
Expand Down
5 changes: 3 additions & 2 deletions app/styles/setup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
}
}

.liquid-outlet {
button.btn-lg {
.setup-step {
.btn-lg {
width: 49%;
}

.lead {
margin-bottom: 20px;
text-align: left;
Expand Down
78 changes: 3 additions & 75 deletions app/transitions.js
Original file line number Diff line number Diff line change
@@ -1,81 +1,9 @@
export default function () {
const duration = 100;
this.transition(
this.hasClass('hide-history'),

// this makes our rule apply when the liquid-if transitions to the
// true state.
this.toValue(false),
this.use('fade', { duration: 250 }),
this.reverse('fade', { duration: 250 }),
);
this.transition(
this.hasClass('hide-balance'),

// this makes our rule apply when the liquid-if transitions to the
// true state.
this.toValue(false),
this.use('toUp', { duration: 300 }),
this.reverse('toUp', { duration: 300 }),
);
this.transition(
this.hasClass('hide-qr'),

// this makes our rule apply when the liquid-if transitions to the
// true state.
this.toValue(false),
this.use('fade', { duration: 500 }),

// which means we can also apply a reverse rule for transitions to
// the false state.
this.reverse('fade', { duration: 500 }),
);

this.transition(
this.fromRoute('wallets.overview'),
this.toRoute('wallets.overview.accounts.history'),
this.hasClass('history'),
this.use('wait', 3000, { then: 'toUp' }),
this.reverse('wait', 3000, { then: 'toDown' }),
);

this.transition(
this.hasClass('toLeft'),
this.fromRoute('setup'),
this.toRoute('setup.index'),
this.use('fade'),
this.reverse('fade'),
);

this.transition(
this.hasClass('toLeft'),
this.fromRoute('setup.index'),
this.toRoute('setup.backup'),
this.use('toLeft', { duration }),
this.reverse('toRight', { duration }),
);

this.transition(
this.hasClass('toLeft'),
this.hasClass('setup-step'),
this.fromRoute('setup.index'),
this.toRoute('setup.import'),
this.use('toLeft', { duration }),
this.reverse('toRight', { duration }),
);

this.transition(
this.hasClass('toLeft'),
this.fromRoute('setup.backup'),
this.toRoute('setup.password'),
this.use('toLeft', { duration }),
this.reverse('toRight', { duration }),
);

this.transition(
this.fromRoute('wallets.overview'),
this.toRoute('wallets.overview.accounts.send'),
this.hasClass('send-outlet'),
this.use('wait', 1000, { then: 'fade' }),
this.reverse('wait', 1000, { then: 'fade' }),
this.use('toLeft', { duration: 100 }),
this.reverse('toRight', { duration: 100 }),
);
}
23 changes: 14 additions & 9 deletions app/wallets/overview/accounts/history/route.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import Route from '@ember/routing/route';
import { get } from '@ember/object';
import { get, set } from '@ember/object';
import { action } from 'ember-decorators/object';

import { hash } from 'rsvp';

export default Route.extend({
beforeModel() {
this.controllerFor('wallets.overview').set('hideHistory', false);
const hideHistory = this.controllerFor('wallets.overview').get('hideHistory');
this.controllerFor('wallets.overview.accounts.history').set('hideHistory', hideHistory);
},

async model() {
const wallet = this.modelFor('wallets');
const account = this.modelFor('wallets.overview.accounts');
Expand All @@ -26,10 +20,21 @@ export default Route.extend({
});
},

setupController(controller, model) {
const overviewController = this.controllerFor('wallets.overview');
set(overviewController, 'hideHistory', false);
set(controller, 'hideHistory', false);
return this._super(controller, model);
},

deactivate() {
const overviewController = this.controllerFor('wallets.overview');
set(overviewController, 'hideHistory', true);
set(this.controller, 'hideHistory', true);
},

@action
hideHistory() {
this.controllerFor(this.routeName).set('hideHistory', true);
this.controllerFor('wallets.overview').set('hideHistory', true);
return this.transitionTo('wallets.overview');
},
});
4 changes: 2 additions & 2 deletions app/wallets/overview/accounts/history/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<div class="container">
<div class="row">
<div class="col">
<a href="#" class="toggle-history-arrow" {{action (route-action 'hideHistory')}}>
{{#link-to 'wallets.overview' model.wallet class="toggle-history-arrow"}}
{{fa-icon "chevron-up"}}
</a>
{{/link-to}}
</div>
</div>
</div>
Expand Down
17 changes: 17 additions & 0 deletions app/wallets/overview/settings/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Route from '@ember/routing/route';

import { action } from 'ember-decorators/object';

export default Route.extend({
renderTemplate() {
this.render('wallets/overview/settings', {
into: 'wallets',
outlet: 'walletSettings',
});
},

@action
cancel() {
return this.transitionTo('wallets.overview');
},
});
10 changes: 10 additions & 0 deletions app/wallets/overview/settings/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{#bs-modal onHide=(route-action 'cancel') as |modal|}}
{{#modal.header}}
<h4 class="modal-title">
{{t 'walletSettings'}}
</h4>
{{/modal.header}}
{{#modal.body}}
{{wallet-settings wallet=model representative=model.representative onChangeRepresentative=(route-action 'changeRepresentative') onChangePassword=(route-action 'changePassword')}}
{{/modal.body}}
{{/bs-modal}}
4 changes: 2 additions & 2 deletions app/wallets/overview/template.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#liquid-if hideHistory class="hide-balance"}}
{{#if hideHistory}}
{{balance-overview wallet=model}}
{{/liquid-if}}
{{/if}}

{{wallet-overview wallet=model accounts=sortedAccounts hideHistory=hideHistory createAccount=(route-action 'createAccount') page=page perPage=perPage}}

Expand Down
30 changes: 0 additions & 30 deletions app/wallets/settings/password/route.js

This file was deleted.

1 change: 0 additions & 1 deletion app/wallets/settings/password/template.hbs

This file was deleted.

10 changes: 0 additions & 10 deletions app/wallets/settings/route.js

This file was deleted.

5 changes: 0 additions & 5 deletions app/wallets/settings/template.hbs

This file was deleted.

4 changes: 3 additions & 1 deletion app/wallets/template.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{{navigation-bar wallet=model onChangeRepresentative=(route-action 'changeRepresentative') onCreateAccount=(route-action 'createAccount') onChangePassword=(route-action 'changePassword')}}
{{navigation-bar wallet=model onCreateAccount=(route-action 'createAccount')}}

<main role="main">
{{notification-center}}

{{outlet}}

{{outlet 'walletSettings'}}
</main>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { expect } from 'chai';
import { describe, it } from 'mocha';
import { setupTest } from 'ember-mocha';

describe('Unit | Route | wallets/settings', () => {
setupTest('route:wallets/settings', {
describe('Unit | Route | wallets/overview/settings', () => {
setupTest('route:wallets/overview/settings', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
Expand Down
15 changes: 0 additions & 15 deletions tests/unit/wallets/settings/password/route-test.js

This file was deleted.

0 comments on commit 39cad40

Please sign in to comment.