<ion-view id="view-confirm" hide-tabs>
  <ion-nav-bar class="bar-royal">
    <ion-nav-title>
      {{'Confirm'|translate}}
    </ion-nav-title>
    <ion-nav-back-button>
    </ion-nav-back-button>
  </ion-nav-bar>

  <ion-content ng-class="{'add-bottom-for-cta': !insufficientFunds && !noMatchingWallet}">
    <div class="list">
      <div class="item head">
        <div class="sending-label">
          <img src="img/icon-tx-sent-outline.svg">
          <span translate ng-if="!useSendMax">Sending</span>
          <span translate ng-if="useSendMax">Sending maximum amount</span>
        </div>
        <div class="amount-label">
          <div class="amount">{{displayAmount || '...'}} <span class="unit">{{displayUnit}}</span></div>
          <div class="alternative">{{alternativeAmountStr || '...'}}</div>
        </div>
      </div>
      <div class="info">
        <div class="item single-line" ng-if="paypro">
          <span class="label" translate>Payment Expires:</span>
          <span class="item-note" ng-if="!paymentExpired.value">{{remainingTimeStr.value}}</span>
          <span class="item-note" ng-if="paymentExpired.value" ng-style="{'color': 'red'}" translate>Expired</span>
        </div>

        <div class="item">
          <span class="label" translate>To</span>
          <span class="payment-proposal-to" ng-if="!recipientType">
            <img src="img/icon-bitcoin-small.svg">

            <div copy-to-clipboard="toAddress" ng-if="!paypro" class="ellipsis">
              <contact ng-if="!toName" address="{{toAddress}}"></contact>
              <span class="m15l size-14" ng-if="toName">{{toName}}</span>
            </div>

            <div ng-if="paypro" ng-click="openPPModal(paypro)" class="m15l size-14 w100p pointer">
              <i ng-show="paypro.verified && paypro.caTrusted" class="ion-locked" style="color:green"></i>
              <i ng-show="!paypro.caTrusted" class="ion-unlocked" style="color:red"></i>
              <span class="ellipsis" ng-show="!toName">{{paypro.domain || paypro.toAddress}}</span>
              <span ng-show="toName">{{toName}}</span>
            </div>
            <!-- <contact ng-if="!tx.hasMultiplesOutputs" class="ellipsis" address="{{toAddress}}"></contact>
            <span ng-if="tx.hasMultiplesOutputs" translate>Multiple recipients</span> -->
          </span>
          <div class="wallet" ng-if="recipientType == 'wallet'">
            <i class="icon big-icon-svg">
              <img src="img/icon-wallet.svg" ng-style="{'background-color': toColor}" class="bg"/>
            </i>
            <div copy-to-clipboard="toAddress" class="ellipsis">
              <contact ng-if="!toName" address="{{toAddress}}"></contact>
              <span ng-if="toName" class="wallet-name">{{toName}}</span>
            </div>
          </div>
          <div ng-if="recipientType == 'contact' && !isChromeApp" class="gravatar-contact toggle" ng-click="toggleAddress()">
            <gravatar class="send-gravatar" name="{{toName}}" height="30" width="30" email="{{toEmail}}"></gravatar>
            <span ng-if="toName && !showAddress">{{toName}}</span>
            <span ng-if="toName && showAddress">{{toAddress}}</span>
          </div>
        </div>
        <a class="item item-icon-right" ng-hide="!useSendMax && (insufficientFunds || noMatchingWallet)" ng-click="showWalletSelector()">
          <span class="label" translate>From</span>
          <div class="wallet" ng-if="wallet">
            <i class="icon big-icon-svg">
              <img src="img/icon-wallet.svg" ng-class="{'wallet-background-color-default': !wallet.color}" ng-style="{'background-color': wallet.color}" class="bg"/>
            </i>
            <div>{{wallet.name}}</div>
          </div>
          <div class="wallet" ng-if="!wallet">
            <i class="icon big-icon-svg">
              <img src="img/icon-wallet.svg" ng-style="{'background-color': 'grey'}" class="bg"/>
            </i>
            <div>...</div>
          </div>
          <i class="icon bp-arrow-right"></i>
        </a>
        <a class="item single-line item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet" ng-click="showDescriptionPopup()">
          <span class="label" translate>Add Memo</span>
          <span class="item-note m10l">
            {{description}}
          </span>
          <i class="icon bp-arrow-right"></i>
        </a>
        <div class="item single-line toggle" ng-if="!insufficientFunds && !noMatchingWallet">
          <span class="label">{{'Fee' | translate}}: {{feeLevel | translate}}</span>
          <span ng-if="!showFeeFiat" class="item-note" ng-click="toggleFeeValue()">{{fee || '...'}}</span>
          <span ng-if="showFeeFiat" class="item-note" ng-click="toggleFeeValue()">{{feeFiat || '...'}}</span>
        </div>
        <div class="text-center" ng-show="noMatchingWallet">
          <span class="badge badge-energized" translate>No wallets available</span>
        </div>
        <div class="text-center" ng-show="insufficientFunds">
          <span class="badge badge-energized" translate>Insufficient funds</span>
        </div>
      </div>
    </div>
  </ion-content>
  <click-to-accept
    ng-click="approve(statusChangeHandler)"
    ng-if="!isCordova"
    click-send-status="sendStatus"
    has-wallet-chosen="wallet"
    insufficient-funds="insufficientFunds"
    no-matching-wallet="noMatchingWallet">
    {{buttonText}}
  </click-to-accept>
  <slide-to-accept
    ng-if="isCordova && (wallet && !insufficientFunds && !noMatchingWallet)"
    slide-on-confirm="onConfirm()"
    slide-send-status="sendStatus"
    has-wallet-chosen="wallet"
    insufficient-funds="insufficientFunds"
    no-matching-wallet="noMatchingWallet">
    {{buttonText}}
  </slide-to-accept>
  <slide-to-accept-success
    slide-success-show="sendStatus === 'success'"
    slide-success-on-confirm="onSuccessConfirm()"
    slide-success-hide-on-confirm="true">
    <span ng-show="wallet.m == 1 && (wallet.canSign() || wallet.isPrivKeyExternal())" translate>Payment Sent</span>
    <span ng-show="wallet.m > 1 && (wallet.canSign() || wallet.isPrivKeyExternal())" translate>Proposal Created</span>
    <span ng-show="!wallet.canSign() && !wallet.isPrivKeyExternal()" translate>Transaction created</span>
  </slide-to-accept-success>

  <wallet-selector
    wallet-selector-title="walletSelectorTitle"
    wallet-selector-wallets="wallets"
    wallet-selector-selected-wallet="wallet"
    wallet-selector-show="showWallets"
    wallet-selector-on-select="onWalletSelect">
  </wallet-selector>

</ion-view>
