Created
June 26, 2020 15:28
-
-
Save prafullakumar/fc6a04ba2323771da5b6a0a4acf6d89f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct Chips: View { | |
let systemImage: String //pass system image | |
let titleKey: LocalizedStringKey //text or localisation value | |
@State var isSelected: Bool | |
var body: some View { | |
HStack { | |
Image.init(systemName: systemImage).font(.title3) | |
Text(titleKey).font(.title3).lineLimit(1) | |
}.padding(.all, 10) | |
.foregroundColor(isSelected ? .white : .blue) | |
.background(isSelected ? Color.blue : Color.white) //different UI for selected and not selected view | |
.cornerRadius(40) //rounded Corner | |
.overlay( | |
RoundedRectangle(cornerRadius: 40) | |
.stroke(Color.blue, lineWidth: 1.5) | |
).onTapGesture { | |
isSelected.toggle() // toggle select - not selected | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment