view lazybear/Company.swift @ 21:12af515592b2

New repository
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Tue, 12 Jan 2021 21:32:39 +0000
parents Company.swift@3bd2e5d6e89d
children 9b84adfa89d4
line wrap: on
line source

//
//  Company.swift
//  LazyBear
//
//  Created by Dennis Concepción Martín on 29/12/20.
//

import SwiftUI

struct Company: View {
    // Company arguments
    var cik: Int
    var symbol: String
    var name: String
    
    @State public var showingInsiders: Bool = false
    @State public var showingStocks: Bool = true
    
    var body: some View {
        GeometryReader { geo in
            VStack {
                if showingStocks {
                    Stock(cik: cik, symbol: symbol, name: name)
                }
                else {
                    Insiders(cik: cik, symbol: symbol, name: name)
                }
                
                // Start bottom selection
                Rectangle()
                    .foregroundColor(.white)
                    .edgesIgnoringSafeArea(.bottom)
                    .frame(height: geo.size.height * 0.1)
                    .overlay(
                        Selection(showingInsiders: $showingInsiders, showingStocks: $showingStocks)
                    )
            }
            .background(Color(.systemGray6).edgesIgnoringSafeArea(.all))
        }
    }
}

struct Company_Previews: PreviewProvider {
    static var previews: some View {
        Company(cik: 320193, symbol: "aapl", name: "apple inc")
    }
}