131 lines
4.7 KiB
Swift
131 lines
4.7 KiB
Swift
//
|
|
// WalletViewController.swift
|
|
// BlockEQ
|
|
//
|
|
// Created by Satraj Bambra on 2018-03-09.
|
|
// Copyright © 2018 Satraj Bambra. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class WalletViewController: UIViewController {
|
|
|
|
@IBOutlet var activityIndicator: UIActivityIndicatorView!
|
|
@IBOutlet var collectionView: UICollectionView!
|
|
@IBOutlet var pageControl: UIPageControl!
|
|
@IBOutlet var tableView: UITableView!
|
|
@IBOutlet var tableViewHeader: UIView!
|
|
@IBOutlet var tableViewHeaderLeftLabel: UILabel!
|
|
@IBOutlet var tableViewHeaderRightLabel: UILabel!
|
|
@IBOutlet var logoImageView: UIImageView!
|
|
|
|
@IBAction func receiveFunds() {
|
|
let receiveViewController = ReceiveViewController(address: "b1RXUJgnuxtzHyJ5UTWerh4pNBWcVikESZe")
|
|
let navigationController = AppNavigationController(rootViewController: receiveViewController)
|
|
|
|
present(navigationController, animated: true, completion: nil)
|
|
}
|
|
|
|
@IBAction func sendFunds() {
|
|
let sendViewController = SendViewController()
|
|
let navigationController = AppNavigationController(rootViewController: sendViewController)
|
|
|
|
present(navigationController, animated: true, completion: nil)
|
|
}
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
super.init(coder: aDecoder)
|
|
}
|
|
|
|
init() {
|
|
super.init(nibName: String(describing: WalletViewController.self), bundle: nil)
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
setupView()
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
|
|
navigationItem.setHidesBackButton(true, animated: false)
|
|
navigationController?.setNavigationBarHidden(false, animated: true)
|
|
}
|
|
|
|
func setupView() {
|
|
let collectionViewNib = UINib(nibName: WalletCell.cellIdentifier, bundle: nil)
|
|
collectionView.register(collectionViewNib, forCellWithReuseIdentifier: WalletCell.cellIdentifier)
|
|
|
|
let tableViewNib = UINib(nibName: TransactionHistoryCell.cellIdentifier, bundle: nil)
|
|
tableView.register(tableViewNib, forCellReuseIdentifier: TransactionHistoryCell.cellIdentifier)
|
|
|
|
navigationItem.titleView = logoImageView
|
|
|
|
tableViewHeaderLeftLabel.textColor = Colors.darkGrayTransparent
|
|
tableViewHeaderRightLabel.textColor = Colors.darkGrayTransparent
|
|
pageControl.currentPageIndicatorTintColor = Colors.primaryDark
|
|
pageControl.pageIndicatorTintColor = Colors.primaryDarkTransparent
|
|
tableView.backgroundColor = Colors.lightBackground
|
|
view.backgroundColor = Colors.primaryDark
|
|
}
|
|
}
|
|
|
|
extension WalletViewController: UICollectionViewDataSource {
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
|
return 2
|
|
}
|
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: WalletCell.cellIdentifier, for: indexPath) as! WalletCell
|
|
|
|
return cell
|
|
}
|
|
}
|
|
|
|
extension WalletViewController: UICollectionViewDelegateFlowLayout {
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
|
return CGSize(width: UIScreen.main.bounds.size.width, height: collectionView.frame.size.height)
|
|
}
|
|
}
|
|
|
|
extension WalletViewController: UITableViewDataSource {
|
|
func numberOfSections(in tableView: UITableView) -> Int {
|
|
return 1
|
|
}
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
return 10
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
|
return tableViewHeader
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
return tableViewHeader.frame.size.height
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: TransactionHistoryCell.cellIdentifier, for: indexPath) as! TransactionHistoryCell
|
|
|
|
return cell
|
|
}
|
|
}
|
|
|
|
extension WalletViewController: UITableViewDelegate {
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
return TransactionHistoryCell.rowHeight
|
|
}
|
|
}
|
|
|
|
extension WalletViewController: UIScrollViewDelegate {
|
|
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
|
|
if scrollView == collectionView {
|
|
pageControl.currentPage = Int(scrollView.contentOffset.x) / Int(scrollView.frame.width)
|
|
}
|
|
}
|
|
}
|
|
|
|
|