diff --git a/Sources/CoffeeUI/Icon.swift b/Sources/CoffeeUI/Icon.swift new file mode 100644 index 0000000..0586bca --- /dev/null +++ b/Sources/CoffeeUI/Icon.swift @@ -0,0 +1,30 @@ +// +// SwiftUIView.swift +// +// +// Created by Yhanco Grey Esteban on 6/5/22. +// + +import SwiftUI + +struct Icon: View { + let name: String + + /// Creates a view with system icon that is resizable + /// - Parameter name: name of system icon + init(_ name: String) { + self.name = name + } + + var body: some View { + Image(systemName: name) + .resizable() + .scaledToFit() + } +} + +struct Icon_Previews: PreviewProvider { + static var previews: some View { + Icon("checkmark.circle.fill") + } +} diff --git a/Sources/CoffeeUI/IconButton.swift b/Sources/CoffeeUI/IconButton.swift new file mode 100644 index 0000000..c731873 --- /dev/null +++ b/Sources/CoffeeUI/IconButton.swift @@ -0,0 +1,39 @@ +// +// SwiftUIView.swift +// +// +// Created by Yhanco Grey Esteban on 6/5/22. +// + +import SwiftUI + +struct IconButton: View { + let name: String + let action: () -> Void + + + /// Creates a button using a system icon + /// - Parameters: + /// - name: system icon name + /// - action: The action to perform when the user triggers the button. + init(_ name: String, action: @escaping () -> Void) { + self.name = name + self.action = action + } + + var body: some View { + Button { + action() + } label: { + Icon(name) + } + } +} + +struct SwiftUIView_Previews: PreviewProvider { + static var previews: some View { + IconButton("checkmark.circle.fill") { + print("I did something") + } + } +}