-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathYVPSignInWithYouVersionButton.swift
More file actions
50 lines (43 loc) · 1.4 KB
/
YVPSignInWithYouVersionButton.swift
File metadata and controls
50 lines (43 loc) · 1.4 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
import ExpoModulesCore
import YouVersionPlatform
import SwiftUI
import ExpoUI
class SignInWithYouVersionButtonProps: UIBaseViewProps {
@Field var mode: String = "full"
@Field var shape: String = "capsule"
@Field var isStroked: Bool = true
@Field var colorScheme: String?
var onTap = EventDispatcher()
}
struct YVPSignInWithYouVersionButton: ExpoSwiftUI.View {
@ObservedObject var props: SignInWithYouVersionButtonProps
@Environment(\.colorScheme) var environmentColorScheme
init(props: SignInWithYouVersionButtonProps) {
self.props = props
}
var body: some View {
SignInWithYouVersionButton(
shape: shape(),
mode: mode(),
isStroked: props.isStroked
) {
props.onTap()
}.environment(\.colorScheme, colorScheme())
}
func shape() -> SignInWithYouVersionButton.ButtonShape {
switch(props.shape) {
case "capsule": return .capsule
default: return .rectangle
}
}
func mode() -> SignInWithYouVersionButton.Mode {
return SignInWithYouVersionButton.Mode(rawValue: props.mode) ?? SignInWithYouVersionButton.Mode.full
}
func colorScheme() -> ColorScheme {
switch props.colorScheme?.lowercased() {
case "dark": return .dark
case "light": return .light
default: return environmentColorScheme
}
}
}