<ion-view id="coinbase" hide-tabs>
  <ion-nav-bar class="bar-royal">
    <ion-nav-back-button>
    </ion-nav-back-button>
    <ion-nav-title>Buy bitcoin</ion-nav-title>
  </ion-nav-bar>

  <ion-content class="add-bottom-for-cta">
    <!-- BUY -->
    <div class="list" ng-if="buyRequestInfo">

      <div class="item head">
        <div class="sending-label">
          <img src="img/buy-bitcoin.svg" alt="buy bitcoin" width="35" class="item-img-buy">
          <span>Buying</span>
        </div>
        <div class="amount-label">
          <div class="amount">{{amountUnitStr}}</div>
          <div class="alternative" ng-if="buyPrice">
            <span ng-show="isFiat">{{buyRequestInfo.amount.amount}} {{buyRequestInfo.amount.currency}}</span> 
            @ ${{buyPrice.amount}} per BTC
          </div>
        </div>
      </div>

      <div class="info">
        <label class="item item-input item-select">
          <div class="input-label">
            Payment Method
          </div>
          <select ng-model="selectedPaymentMethodId.value"
                  ng-options="item.id as item.name for item in paymentMethods"
                  ng-change="buyRequest()">
          </select>
        </label>

        <div class="item item-icon-right" ng-click="showWalletSelector()">
          <div class="label">Receive in</div>
          <div class="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>
            {{wallet ? wallet.name : '...'}}
          </div>
          <i class="icon bp-arrow-right"></i>
        </div>

        <div class="item item-divider">
          Transaction details
        </div>
        <div class="item">
          Amount
          <span class="item-note">
            {{buyRequestInfo.subtotal.amount}} {{buyRequestInfo.subtotal.currency}}
          </span>
        </div>
        <div class="item" ng-repeat="fee in buyRequestInfo.fees">
          <span class="capitalized">
            {{fee.type}} fee
          </span>
          <span class="item-note">
            {{fee.amount.amount}} {{fee.amount.currency}} 
          </span>
        </div>
        <div class="item">
          Total to pay
          <span class="item-note total-amount">
            {{buyRequestInfo.total.amount}} {{buyRequestInfo.total.currency}}
          </span>
        </div>
      </div>
    </div>

  </ion-content>

  <click-to-accept
    ng-disabled="!selectedPaymentMethodId.value || !buyRequestInfo || !wallet"
    ng-click="buyConfirm()"
    ng-if="!isCordova && buyRequestInfo"
    click-send-status="sendStatus"
    has-wallet-chosen="wallet"
    insufficient-funds="!selectedPaymentMethodId.value"
    no-matching-wallet="!buyRequestInfo">
    Confirm purchase
  </click-to-accept>
  <slide-to-accept
    ng-disabled="!selectedPaymentMethodId.value || !buyRequestInfo || !wallet"
    ng-if="isCordova && buyRequestInfo"
    slide-on-confirm="buyConfirm()"
    slide-send-status="sendStatus"
    has-wallet-chosen="wallet"
    insufficient-funds="!selectedPaymentMethodId.value"
    no-matching-wallet="!buyRequestInfo">
    Slide to buy
  </slide-to-accept>
  <slide-to-accept-success
    slide-success-show="sendStatus === 'success'"
    slide-success-on-confirm="goBackHome()"
    slide-success-hide-on-confirm="true">
    <span>Bought</span>
    <div class="m10 size-14">
      Bitcoin purchase completed. Coinbase has queued the transfer to your selected wallet
    </div>
  </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>
