-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoginButton.swift
More file actions
51 lines (47 loc) · 1.38 KB
/
Copy pathLoginButton.swift
File metadata and controls
51 lines (47 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// LoginButton.swift
// DevLogPresentation
//
// Created by opfic on 4/25/25.
//
import SwiftUI
import DevLogDomain
struct LoginButton: View {
@State private var logo: Image?
@State private var text = ""
@ScaledMetric(relativeTo: .body) private var height = CGFloat(22)
private let action: () -> Void
init(
logo: Image? = nil,
text: String = "",
action: @escaping () -> Void = {}
) {
self._logo = State(initialValue: logo)
self._text = State(initialValue: text)
self.action = action
}
var body: some View {
Button {
action()
} label: {
Text(text)
.foregroundStyle(Color.primary)
.font(.system(.body))
.contentShape(.capsule)
.frame(width: 300, height: height + 16)
.overlay {
ZStack(alignment: .leading) {
Capsule()
.stroke(Color.gray, lineWidth: 1)
if let logo = logo {
logo
.resizable()
.scaledToFit()
.frame(width: height, height: height)
.padding(.leading)
}
}
}
}
}
}