11import ErrorHandling
22import SwiftUI
33import XcodesKit
4+ import Path
5+ import Version
46
57struct MainWindow : View {
68 @EnvironmentObject var appState : AppState
@@ -16,7 +18,7 @@ struct MainWindow: View {
1618 @AppStorage ( " isInstalledOnly " ) private var isInstalledOnly = false
1719
1820 var body : some View {
19- HSplitView {
21+ NavigationSplitViewWrapper {
2022 XcodeListView ( selectedXcodeID: $selectedXcodeID, searchText: searchText, category: category, isInstalledOnly: isInstalledOnly)
2123 . frame ( minWidth: 300 )
2224 . layoutPriority ( 1 )
@@ -26,25 +28,73 @@ struct MainWindow: View {
2628 primaryButton: . destructive( Text ( " Uninstall " ) , action: { self . appState. uninstall ( xcode: xcode) } ) ,
2729 secondaryButton: . cancel( Text ( " Cancel " ) ) )
2830 }
29-
30- if isShowingInfoPane {
31- Group {
32- if let xcode = xcode {
33- InfoPane ( xcode: xcode)
31+ . searchable ( text: $searchText, placement: . sidebar)
32+ . mainToolbar (
33+ category: $category,
34+ isInstalledOnly: $isInstalledOnly,
35+ isShowingInfoPane: $isShowingInfoPane
36+ )
37+ } detail: {
38+ Group {
39+ if let xcode = xcode {
40+ InfoPane ( xcode: xcode)
41+ } else {
42+ UnselectedView ( )
43+ }
44+ }
45+ . padding ( )
46+ . toolbar {
47+ ToolbarItemGroup {
48+ Button ( action: { appState. presentedSheet = . signIn } , label: {
49+ Label ( " Login " , systemImage: " person.circle " )
50+ } )
51+ . help ( " LoginDescription " )
52+ if #available( macOS 14 , * ) {
53+ SettingsLink ( label: {
54+ Label ( " Preferences " , systemImage: " gearshape " )
55+ } )
56+ . help ( " PreferencesDescription " )
3457 } else {
35- UnselectedView ( )
58+ Button ( action: {
59+ if #available( macOS 13 , * ) {
60+ NSApp . sendAction ( Selector ( ( " showSettingsWindow: " ) ) , to: nil , from: nil )
61+ } else {
62+ NSApp . sendAction ( Selector ( ( " showPreferencesWindow: " ) ) , to: nil , from: nil )
63+ }
64+ } , label: {
65+ Label ( " Preferences " , systemImage: " gearshape " )
66+ } )
67+ . help ( " PreferencesDescription " )
3668 }
3769 }
38- . padding ( )
39- . frame ( minWidth: 300 , maxWidth: . infinity)
4070 }
4171 }
42- . mainToolbar (
43- category: $category,
44- isInstalledOnly: $isInstalledOnly,
45- isShowingInfoPane: $isShowingInfoPane,
46- searchText: $searchText
47- )
72+
73+ // HSplitView {
74+ // XcodeListView(selectedXcodeID: $selectedXcodeID, searchText: searchText, category: category, isInstalledOnly: isInstalledOnly)
75+ // .frame(minWidth: 300)
76+ // .layoutPriority(1)
77+ // .alert(item: $appState.xcodeBeingConfirmedForUninstallation) { xcode in
78+ // Alert(title: Text(String(format: localizeString("Alert.Uninstall.Title"), xcode.description)),
79+ // message: Text("Alert.Uninstall.Message"),
80+ // primaryButton: .destructive(Text("Uninstall"), action: { self.appState.uninstall(xcode: xcode) }),
81+ // secondaryButton: .cancel(Text("Cancel")))
82+ // }
83+ // .searchable(text: $searchText)
84+ //
85+ // if isShowingInfoPane {
86+ // Group {
87+ // if let xcode = xcode {
88+ // InfoPane(xcode: xcode)
89+ // } else {
90+ // UnselectedView()
91+ // }
92+ // }
93+ // .padding()
94+ // .frame(minWidth: 300, maxWidth: .infinity)
95+ // }
96+ // }
97+
4898 . bottomStatusBar ( )
4999 . padding ( [ . top] , 0 )
50100 . navigationSubtitle ( subtitleText)
@@ -197,6 +247,16 @@ struct MainWindow: View {
197247
198248struct MainWindow_Previews : PreviewProvider {
199249 static var previews : some View {
200- MainWindow ( )
250+ MainWindow ( ) . environmentObject ( { ( ) -> AppState in
251+ let a = AppState ( )
252+ a. allXcodes = [
253+ Xcode ( version: Version ( " 12.0.0+1234A " ) !, identicalBuilds: [ Version ( " 12.0.0+1234A " ) !, Version ( " 12.0.0-RC+1234A " ) !] , installState: . installed( Path ( " /Applications/Xcode-12.3.0.app " ) !) , selected: false , icon: nil ) ,
254+ Xcode ( version: Version ( " 12.3.0 " ) !, installState: . installed( Path ( " /Applications/Xcode-12.3.0.app " ) !) , selected: true , icon: nil ) ,
255+ Xcode ( version: Version ( " 12.2.0 " ) !, installState: . notInstalled, selected: false , icon: nil ) ,
256+ Xcode ( version: Version ( " 12.1.0 " ) !, installState: . installing( . downloading( progress: configure ( Progress ( totalUnitCount: 100 ) ) { $0. completedUnitCount = 40 } ) ) , selected: false , icon: nil ) ,
257+ Xcode ( version: Version ( " 12.0.0 " ) !, installState: . installed( Path ( " /Applications/Xcode-12.3.0.app " ) !) , selected: false , icon: nil ) ,
258+ ]
259+ return a
260+ } ( ) )
201261 }
202262}
0 commit comments