view LazyBear/Views/Home/Helpers/CurrencyItem.swift @ 357:eb97439e46cd

Implement ExtensiveList in HomeView
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Thu, 15 Apr 2021 23:37:25 +0200
parents 5ccceb527178
children 2984d8946342
line wrap: on
line source

//
//  CurrencyItem.swift
//  LazyBear
//
//  Created by Dennis Concepción Martín on 12/4/21.
//

import SwiftUI

struct CurrencyItem: View {
    var currencySymbol: String
    var currency: CurrencyModel
    
    var body: some View {
        RoundedRectangle(cornerRadius: 8)
            .foregroundColor(Color(.secondarySystemBackground))
            .frame(width: 330, height: 50)
            .overlay(
                HStack {
                    Color("default")
                        .frame(width: 40)
                        .overlay(
                            Text(currency.flag)
                        )
                    VStack(alignment: .leading) {
                        Text("USD/\(currencySymbol)")
                            .font(.headline)
                        
                        Text(currency.name)
                            .font(.callout)
                    }
                    
                    Spacer()
                    Text("\(currency.rate, specifier: "%.2f")")
                        .padding(.horizontal)
                }
                .clipShape(RoundedRectangle(cornerRadius: 8))
            )
    }
}

struct CurrencyItem_Previews: PreviewProvider {
    static var previews: some View {
        CurrencyItem(currencySymbol: "AUD", currency: CurrencyModel(flag: "🇺🇸", name: "Australian dollar", rate: 1.3116))
    }
}