CryptoWallet

IOS app for monitoring the cryptocurrencies

Stars
3

import Combine

func getCoin() {
     guard let url = URL(string: "https://api.coingecko.com/api/v3/coins/markets?       vs_currency=usd&order=market_cap_desc&per_page=250&page=1&sparkline=true&price_change_percentage=24h") else { return }
        
        coinSubscription = NetworkManager.download(url: url)
            .decode(type: [CoinModel].self , decoder: JSONDecoder())
            .sink(receiveCompletion: NetworkManager.handleCompletion, receiveValue: { [weak self] (returnedCoins) in
                self?.allCoins = returnedCoins
                self?.coinSubscription?.cancel()
            })
    }


import CoreData

init() {
        container = NSPersistentContainer(name: containerName)
        container.loadPersistentStores { (_, error) in
            if let error = error {
                print("Error loading CoreData! \(error)")
            }
            self.getPortfolio()
        }
    }


Initializing the view: Bitcoin
Recieve coin data: nil
Recieve coin data: Optional(CryptoWallet.CoinDetailModel(id: Optional("bitcoin"),
symbol: Optional("btc"), name: Optional("Bitcoin"), blockTimeInMinutes: Optional(10),
hashingAlgorithm: Optional("SHA-256"), description: Optional(CryptoWallet.Description(en: "Bitcoin is the first successful internet money based on peer-to-peer technology; whereby no central bank or authority is involved in the transaction and production of the Bitcoin currency. It was created by an anonymous individual/group under the name, Satoshi Nakamoto. The source code is available publicly as an open source project,
anybody can look at it and be part of the developmental process.\r\n\r\nBitcoin is changing the way we see money as we speak.
The idea was to produce a means of exchange, independent of any central authority, that could be transferred electronically in a secure,
verifiable and immutable way. It is a decentralized peer-to-peer internet currency making mobile payment easy,
very low transaction fees, protects your identity, and it works anywhere all the time with no central authority and banks.
\r\n\r\nBitcoin is designed to have only 21 million BTC ever created, thus making it a deflationary currency.
Bitcoin uses the <a href=\"https://www.coingecko.com/en?hashing_algorithm=SHA-256\">SHA-256</a> hashing algorithm with an average transaction confirmation time of 10 minutes. Miners today are mining Bitcoin using ASIC chip dedicated to only mining Bitcoin, and the hash rate has shot up to peta hashes.
\r\n\r\nBeing the first successful online cryptography currency, Bitcoin has inspired other alternative currencies such as <a href=\"https://www.coingecko.com/en/coins/litecoin\">Litecoin</a>, <a href=\"https://www.coingecko.com/en/coins/peercoin\">Peercoin</a>,
<a href=\"https://www.coingecko.com/en/coins/primecoin\">Primecoin</a>, and so on.
\r\n\r\nThe cryptocurrency then took off with the innovation of the turing-complete smart contract by
<a href=\"https://www.coingecko.com/en/coins/ethereum\">Ethereum</a> which led to the development of other amazing projects such as
<a href=\"https://www.coingecko.com/en/coins/eos\">EOS</a>, <a href=\"https://www.coingecko.com/en/coins/tron\">Tron</a>, and even crypto-collectibles such as
<a href=\"https://www.coingecko.com/buzz/ethereum-still-king-dapps-cryptokitties-need-1-billion-on-eos\">CryptoKitties</a>.")), links: Optional(CryptoWallet.Links(homepage: ["http://www.bitcoin.org", "", ""], subredditURL: Optional("https://www.reddit.com/r/Bitcoin/")))))



import Foundation
import SwiftUI

extension UIApplication {
    
    func endEditing() {
        sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
    }
}


extension Date {
    
    init(coinGeckoString: String) {
        let formatter = DateFormatter()
        formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
        let date = formatter.date(from: coinGeckoString) ?? Date()
        self.init(timeInterval: 0, since: date)
    }

cionGecko