omnivore/apple/OmnivoreKit/Sources/Views/Buttons/GoogleAuthButton.swift

56 lines
1.4 KiB
Swift
Raw Permalink Normal View History

2022-02-11 17:24:33 +00:00
import SwiftUI
public struct GoogleAuthButton: View {
2022-02-11 17:24:33 +00:00
let tapAction: () -> Void
public init(tapAction: @escaping () -> Void) {
self.tapAction = tapAction
}
public var body: some View {
2022-02-11 17:24:33 +00:00
Button(action: tapAction) {
HStack(spacing: 8) {
Image.googleIcon
.resizable()
2022-06-01 05:40:22 +00:00
.frame(width: 16, height: 16)
2022-02-11 17:24:33 +00:00
Text(LocalText.googleAuthButton)
2022-06-01 05:40:22 +00:00
.font(isMacApp ? .appCaption : .appTitleThree)
2022-02-11 17:24:33 +00:00
.foregroundColor(.black)
2022-06-01 17:49:00 +00:00
.fontWeight(Font.Weight.medium)
2022-02-11 17:24:33 +00:00
}
2022-06-01 15:13:55 +00:00
.frame(maxWidth: 300)
2022-06-01 05:40:22 +00:00
.frame(height: isMacApp ? 30 : 54)
2022-02-11 17:24:33 +00:00
}
.buttonStyle(GoogleButtonStyle())
}
}
struct GoogleButtonStyle: ButtonStyle {
func makeBody(configuration: Self.Configuration) -> some View {
configuration.label
.background(
RoundedRectangle(cornerRadius: 8)
.fill(Color.white)
.shadow(
color: .gray.opacity(0.6),
radius: 1, x: 0, y: 1
)
)
.opacity(configuration.isPressed ? 0.7 : 1.0)
}
}
#if DEBUG
struct GoogleAuthButtonPreview: PreviewProvider {
static var previews: some View {
registerFonts()
return Group {
GoogleAuthButton(tapAction: {})
GoogleAuthButton(tapAction: {})
.previewDevice("iPad Pro (9.7-inch)")
.environment(\.sizeCategory, .large)
}
}
}
#endif