view Supply/Selection.swift @ 0:668fd7e0d121

first commit
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Tue, 05 Jan 2021 16:43:09 +0000
parents
children 3bd2e5d6e89d
line wrap: on
line source

//
//  Selection.swift
//  LazyBear
//
//  Created by Dennis Concepción Martín on 30/12/20.
//

import SwiftUI

struct Selection: View {
    @Binding var showingInsiders: Bool
    @Binding var showingMain: Bool
    
    var body: some View {
        // Buttons
        HStack {
            Group {
                // Insiders
                Button(action: {toggle(type: "insider")}) {
                    if showingInsiders {
                        Image(systemName: "person.fill")
                            .resizable()
                            .frame(width: 35, height: 35)
                    } else {
                        Image(systemName: "person")
                            .resizable()
                            .frame(width: 35, height: 35)
                    }
                }
                
                // Stock
                Button(action: {toggle(type: "stock")}) {
                    if showingMain {
                        Image(systemName: "dollarsign.square.fill")
                            .resizable()
                            .frame(width: 35, height: 35)
                            
                    } else {
                        Image(systemName: "dollarsign.square")
                            .resizable()
                            .frame(width: 35, height: 35)
                    }
                }
            }.padding().padding().padding()
        }
    }
    
    func toggle(type: String) {
        if type == "insider" {
            self.showingMain = false
            self.showingInsiders = true
        }
        
        if type == "stock" {
            self.showingMain = true
            self.showingInsiders = false
        }
        
        if type == "description" {
            self.showingMain = false
            self.showingInsiders = false
        }
    }
}

struct Selection_Previews: PreviewProvider {
    static var previews: some View {
        Selection(showingInsiders: .constant(false), showingMain: .constant(true))
    }
}

/*
 
 */