-
Notifications
You must be signed in to change notification settings - Fork 377
Expand file tree
/
Copy pathBottomStatusBar.swift
More file actions
88 lines (79 loc) · 2.66 KB
/
Copy pathBottomStatusBar.swift
File metadata and controls
88 lines (79 loc) · 2.66 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
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
//
// BottomStatusBar.swift
// Xcodes
//
// Created by Matt Kiazyk on 2022-06-03.
// Copyright © 2022 Robots and Pencils. All rights reserved.
//
import Foundation
import SwiftUI
struct BottomStatusModifier: ViewModifier {
@EnvironmentObject var appState: AppState
@AppStorage(PreferenceKey.hideSupportXcodes.rawValue) var hideSupportXcodes = false
@SwiftUI.Environment(\.openURL) var openURL: OpenURLAction
func body(content: Content) -> some View {
VStack(spacing: 0) {
content
VStack(spacing: 0) {
Divider()
HStack {
Text(appState.bottomStatusBarMessage)
.font(.subheadline)
Spacer()
if !hideSupportXcodes {
Button(action: {
openURL(URL(string: "https://opencollective.com/xcodesapp")!)
}) {
HStack {
Image(systemName: "heart.circle")
Text("Support.Xcodes")
}
}
}
Text(verbatim: "\(Bundle.main.shortVersion!) (\(Bundle.main.version!))")
.font(.subheadline)
}
.frame(maxWidth: .infinity, maxHeight: 30, alignment: .leading)
.padding([.leading, .trailing], 10)
}
.frame(maxWidth: .infinity, maxHeight: 30, alignment: .leading)
}
}
}
extension View {
func bottomStatusBar() -> some View {
self.modifier(
BottomStatusModifier()
)
}
}
struct Previews_BottomStatusBar_Previews: PreviewProvider {
static var previews: some View {
Group {
HStack {
}
.bottomStatusBar()
.environmentObject({ () -> AppState in
let a = AppState()
return a }()
)
.defaultAppStorage({ () -> UserDefaults in
let d = UserDefaults(suiteName: "hide_support")!
d.set(true, forKey: PreferenceKey.hideSupportXcodes.rawValue)
return d
}())
HStack {
}
.bottomStatusBar()
.environmentObject({ () -> AppState in
let a = AppState()
return a }()
)
.defaultAppStorage({ () -> UserDefaults in
let d = UserDefaults(suiteName: "show_support")!
d.set(false, forKey: PreferenceKey.hideSupportXcodes.rawValue)
return d
}())
}
}
}