view LazyBear/UI/CompanyRow.swift @ 262:cd902f3f7f33

Implement PriceView in CompanyRow
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sat, 13 Mar 2021 15:32:24 +0100
parents 46b503fcb0f9
children 9e3c7d7fcbff
line wrap: on
line source

//
//  CompanyRow.swift
//  LazyBear
//
//  Created by Dennis Concepción Martín on 19/2/21.
//

import SwiftUI

struct CompanyRow: View {
    var symbol: String
    var name: String
    var rowNumber: Int
    var showPrice: Bool
//    @Environment(\.editMode) var mode
    
    var body: some View {
        HStack {
            SideColor(rowNumber: rowNumber)
            VStack(alignment: .leading) {
                Text(symbol.uppercased())
                    .fontWeight(.semibold)

                Text(name.capitalized)
                    .lineLimit(1)
            }
            
            Spacer()
            if showPrice {
                PriceView(symbol: symbol, showVertical: true)
                    .animation(.easeInOut)
            }
        }
        
//        if self.mode?.wrappedValue.isEditing ?? true {
//            return PriceView(symbol: symbol)
//        }
        
    }
}

struct Row_Previews: PreviewProvider {
    static var previews: some View {
        List {
            CompanyRow(symbol: "aapl", name: "apple inc", rowNumber: 2, showPrice: true)
        }
    }
}