main: allow switching between UUP Dump and ESD Convert modes

This commit is contained in:
osy 2023-08-11 18:19:06 -07:00
parent 5086227d62
commit 733f9ae7b8
6 changed files with 92 additions and 13 deletions

View file

@ -11,6 +11,7 @@
844A8EFF2A86CA8C009A389C /* SimpleContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844A8EFE2A86CA8C009A389C /* SimpleContentView.swift */; };
844A8F032A86E86F009A389C /* EULAView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844A8F022A86E86F009A389C /* EULAView.swift */; };
844A8F062A86F92F009A389C /* esd2iso.sh in Resources */ = {isa = PBXBuildFile; fileRef = 844A8F052A86F92F009A389C /* esd2iso.sh */; };
84EB35722A870EA7004F252E /* ShowWindowButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84EB35712A870EA6004F252E /* ShowWindowButtonView.swift */; };
CEC09F0F2A6BB66200980857 /* Main.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEC09F0E2A6BB66200980857 /* Main.swift */; };
CEC09F112A6BB66200980857 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEC09F102A6BB66200980857 /* ContentView.swift */; };
CEC09F132A6BB66300980857 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CEC09F122A6BB66300980857 /* Assets.xcassets */; };
@ -495,6 +496,7 @@
844A8EFE2A86CA8C009A389C /* SimpleContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleContentView.swift; sourceTree = "<group>"; };
844A8F022A86E86F009A389C /* EULAView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EULAView.swift; sourceTree = "<group>"; };
844A8F052A86F92F009A389C /* esd2iso.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = esd2iso.sh; sourceTree = "<group>"; };
84EB35712A870EA6004F252E /* ShowWindowButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowWindowButtonView.swift; sourceTree = "<group>"; };
CEC09F0B2A6BB66200980857 /* CrystalFetch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CrystalFetch.app; sourceTree = BUILT_PRODUCTS_DIR; };
CEC09F0E2A6BB66200980857 /* Main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.swift; sourceTree = "<group>"; };
CEC09F102A6BB66200980857 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@ -961,6 +963,7 @@
CEC09F362A6E5B7600980857 /* BuildDetails.swift */,
CEC09F382A6E5D5C00980857 /* BuildEditions.swift */,
CEC09F342A6DF33C00980857 /* BuildsListView.swift */,
84EB35712A870EA6004F252E /* ShowWindowButtonView.swift */,
CEC09F272A6DBED400980857 /* Worker.swift */,
CEC09F122A6BB66300980857 /* Assets.xcassets */,
CEC09F172A6BB66300980857 /* CrystalFetch.entitlements */,
@ -1582,6 +1585,7 @@
CEC09F3D2A6EECC700980857 /* Downloader.swift in Sources */,
CEC09F2D2A6DC60500980857 /* UUPDetails.swift in Sources */,
CEC09F352A6DF33C00980857 /* BuildsListView.swift in Sources */,
84EB35722A870EA7004F252E /* ShowWindowButtonView.swift in Sources */,
CEC09F392A6E5D5C00980857 /* BuildEditions.swift in Sources */,
844A8F032A86E86F009A389C /* EULAView.swift in Sources */,
CEC09F2F2A6DC72000980857 /* UUPEditions.swift in Sources */,

View file

@ -54,6 +54,12 @@ struct ContentView: View {
ProgressView()
}
}
ToolbarItem(placement: .navigation) {
ShowWindowButtonView(id: "ESDConvert") {
Label("Simple…", systemImage: "arrowshape.turn.up.backward.fill")
}.disabled(worker.isBusy)
.help("Build installation for the latest release through ESD conversion.")
}
ToolbarItem(placement: .principal) {
Button {
worker.refresh(findDefault: true)

View file

@ -2,25 +2,34 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>crystalfetch</string>
</array>
</dict>
</array>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSExceptionDomains</key>
<dict>
<key>tlu.dl.delivery.mp.microsoft.com</key>
<key>dl.delivery.mp.microsoft.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
<key>dl.delivery.mp.microsoft.com</key>
<key>tlu.dl.delivery.mp.microsoft.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
</dict>
</plist>

View file

@ -21,16 +21,16 @@ struct Main: App {
@StateObject private var worker = Worker()
var body: some Scene {
WindowGroup(id: "simple") {
WindowGroup(id: "ESDConvert") {
SimpleContentView().environmentObject(worker)
.frame(minWidth: 500, idealWidth: 500, minHeight: 300, idealHeight: 300)
}
}.handlesExternalEvents(matching: Set(["ESDConvert"]))
WindowGroup(id: "advanced") {
WindowGroup(id: "UUPDump") {
ContentView().environmentObject(worker)
.frame(minWidth: 800, minHeight: 400)
}.commands {
SidebarCommands()
}
}.handlesExternalEvents(matching: Set(["UUPDump"]))
}
}

View file

@ -0,0 +1,62 @@
//
// Copyright © 2023 Turing Software, LLC. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import SwiftUI
struct ShowWindowButtonView<Label: View>: View {
let id: String
let label: () -> Label
@Environment(\.dismiss) private var dismiss
var body: some View {
if #available(macOS 13, *) {
ShowWindowButtonViewNew(id: id, label: label)
} else {
Button(action: {
open(id: id)
dismiss()
}, label: label)
}
}
private func open(id: String) {
let url = URL(string: "crystalfetch://\(id)")!
NSWorkspace.shared.open(url)
}
}
@available(macOS 13, *)
private struct ShowWindowButtonViewNew<Label: View>: View {
let id: String
let label: () -> Label
@Environment(\.openWindow) private var openWindow
@Environment(\.dismiss) private var dismiss
var body: some View {
Button(action: {
openWindow(id: id)
dismiss()
}, label: label)
}
}
#Preview {
ShowWindowButtonView(id: "UUPDump") {
Text("All builds…")
}
}

View file

@ -29,8 +29,6 @@ struct SimpleContentView: View {
@State private var languages: [DisplayString] = []
@State private var editions: [DisplayString] = []
@Environment(\.openWindow) private var openWindow
var body: some View {
VStack {
Form {
@ -87,11 +85,10 @@ struct SimpleContentView: View {
}
}
HStack {
Button {
} label: {
ShowWindowButtonView(id: "UUPDump") {
Text("All builds…")
}.disabled(worker.isBusy)
.help("Build custom installation for any build through UUP Dump.")
Spacer()
if worker.isBusy {
Button(role: .cancel) {
@ -133,6 +130,7 @@ struct SimpleContentView: View {
.padding()
.onAppear {
worker.refreshEsdCatalog()
refreshList()
}
.onChange(of: worker.completedDownloadUrl) { newValue in
if newValue != nil {