gh-XcodesOrg-XcodesApp/Xcodes/Frontend/XcodeList/BottomStatusBar.swift
Anand Biligiri e3f996da6e Restrict allowed versions & hide 'Support Xcodes'
- Introduced a new preference keys allowedMajorVersions, hideSupportXcodes
- allowedMajorVersions defaults to Int.max (ie allow all versions till date)
- allowedMajorVersions is used to limit the number of major versions to as many as
    value set for this key. Eg: A value of 1 would allow the latest GA version and one major version before
    A value of 0 would allow only the latest GA version
    A value of 2 would allow the latest GA and previous two major versions
- allowedMajorVersions does not have preference UI
    $ defaults write com.xcodesorg.xcodesapp allowedMajorVersions 2 #to limit to current GA and previous major
    $ defaults delete com.xcodesorg.xcodesapp allowedMajorVersions  #to remove limits
- Display buildNumber in bottom status bar
2024-10-20 12:51:14 -07:00

88 lines
2.7 KiB
Swift

//
// 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("\(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
}())
}
}
}