forked from d-date/SwiftPMProjectExample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHome.swift
106 lines (93 loc) · 3.69 KB
/
Home.swift
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import Build
import SwiftUI
import BlogLinks
import WebView
public struct Home: View {
var build: Build
var primaryColor: Color
public init(build: Build, primaryColor: Color) {
self.build = build
self.primaryColor = primaryColor
}
public var body: some View {
NavigationView {
ZStack {
WebView(request: .init(url: build.iOSDCJapanWebURL()), configuration: .init())
VStack {
Spacer()
Button(action: {
let url = build.eventbriteURL()
#if os(macOS)
NSWorkspace.shared.open(url)
#else
UIApplication.shared.open(url, options: [:], completionHandler: nil)
#endif
}, label: {
HStack {
Spacer()
Image(systemName: "ticket")
Text("Buy Ticket", bundle: .module)
Spacer()
}
})
.buttonStyle(PrimaryButtonStyle(primaryColor: primaryColor))
NavigationLink(destination: BlogLinks(url: build.bloglinkURL()), label: {
HStack {
Spacer()
Image(systemName: "pencil")
Text("Post your report", bundle: .module)
Spacer()
}
})
.buttonStyle(PrimaryButtonStyle(primaryColor: primaryColor))
}
.padding()
}
.navigationBarHidden(true)
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
struct Home_Previews: PreviewProvider {
static var previews: some View {
Home(build: .none, primaryColor: Color.init(.label)).environment(\.locale, .init(identifier: "ja"))
}
}
var conferenceDateInterval: String {
let start = DateComponents(calendar: .autoupdatingCurrent, timeZone: .autoupdatingCurrent, year: 2021, month: 9, day: 17, hour: 0, minute: 0, second: 0, nanosecond: 0)
let end = DateComponents(calendar: .autoupdatingCurrent, timeZone: .autoupdatingCurrent, year: 2021, month: 9, day: 19, hour: 0, minute: 0, second: 0, nanosecond: 0)
let formatter = DateIntervalFormatter()
formatter.dateStyle = .medium
formatter.timeStyle = .none
return formatter.string(from: start.date!, to: end.date!)
}
struct PrimaryButtonStyle: ButtonStyle {
let primaryColor: Color
func makeBody(configuration: Configuration) -> some View {
#if os(macOS)
return configuration.label
.font(Font.body.bold())
.foregroundColor(.init(.windowBackgroundColor))
.opacity(configuration.isPressed ? 0.2 : 1.0)
.padding()
.background(
RoundedRectangle(cornerRadius: 16, style: .continuous)
.foregroundColor(primaryColor)
)
.cornerRadius(4.0)
.shadow(color: Color(.labelColor).opacity(0.12), radius: 20, x: 0, y: 6)
#else
return configuration.label
.font(Font.body.bold())
.foregroundColor(.init(.systemBackground))
.opacity(configuration.isPressed ? 0.2 : 1.0)
.padding()
.background(
RoundedRectangle(cornerRadius: 16, style: .continuous)
.foregroundColor(primaryColor)
)
.cornerRadius(4.0)
.shadow(color: Color(.label).opacity(0.12), radius: 20, x: 0, y: 6)
#endif
}
}