-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathYVPBibleWidgetView.swift
More file actions
62 lines (52 loc) · 1.61 KB
/
YVPBibleWidgetView.swift
File metadata and controls
62 lines (52 loc) · 1.61 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
52
53
54
55
56
57
58
59
60
61
62
import ExpoModulesCore
import YouVersionPlatform
import SwiftUI
import ExpoUI
class BibleWidgetViewProps: UIBaseViewProps {
// Bible reference
@Field var versionId: Int
@Field var bookUSFM: String
@Field var chapter: Int
@Field var verse: Int?
@Field var verseStart: Int?
@Field var verseEnd: Int?
@Field var fontSize: Float?
@Field var colorScheme: String?
}
struct YVPBibleWidgetView: ExpoSwiftUI.View {
@ObservedObject var props: BibleWidgetViewProps
@Environment(\.colorScheme) var environmentColorScheme
init(props: BibleWidgetViewProps) {
self.props = props
}
var body: some View {
BibleWidgetView(
reference: bibleReference(),
fontSize: CGFloat(props.fontSize ?? 23)
).environment(\.colorScheme, colorScheme())
}
func colorScheme() -> ColorScheme {
switch props.colorScheme?.lowercased() {
case "dark": return .dark
case "light": return .light
default: return environmentColorScheme
}
}
func bibleReference() -> BibleReference {
if let start = props.verseStart, let end = props.verseEnd {
return BibleReference(
versionId: props.versionId,
bookUSFM: props.bookUSFM,
chapter: props.chapter,
verseStart: start,
verseEnd: end
)
}
return BibleReference(
versionId: props.versionId,
bookUSFM: props.bookUSFM,
chapter: props.chapter,
verse: props.verse
)
}
}