解决设置的view问题
This commit is contained in:
parent
58aa779a60
commit
1e4e10f847
@ -9,6 +9,7 @@ import SwiftUI
|
||||
|
||||
struct NetworkView: View {
|
||||
@Environment(UserContext.self) var userContext: UserContext
|
||||
@Environment(\.openWindow) private var openWindow
|
||||
@State private var networkModel = NetworkModel()
|
||||
@State private var showMode: ShowMode = .resource
|
||||
|
||||
@ -41,18 +42,20 @@ struct NetworkView: View {
|
||||
}
|
||||
.frame(width: 320)
|
||||
|
||||
// 显示设备和资源选项
|
||||
HStack {
|
||||
Button {
|
||||
self.showMode = .resource
|
||||
} label: {
|
||||
Text("资源")
|
||||
}
|
||||
if self.networkModel.connectState == .connected {
|
||||
// 显示设备和资源选项
|
||||
HStack {
|
||||
Button {
|
||||
self.showMode = .resource
|
||||
} label: {
|
||||
Text("资源")
|
||||
}
|
||||
|
||||
Button {
|
||||
self.showMode = .device
|
||||
} label: {
|
||||
Text("设备")
|
||||
Button {
|
||||
self.showMode = .device
|
||||
} label: {
|
||||
Text("设备")
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
@ -81,11 +84,13 @@ struct NetworkView: View {
|
||||
.padding(.top, 10)
|
||||
.padding(.leading, 10)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button {
|
||||
print("clicked")
|
||||
} label: {
|
||||
Image(systemName: "gearshape")
|
||||
if self.networkModel.connectState == .connected {
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button {
|
||||
openWindow(id: "settings")
|
||||
} label: {
|
||||
Image(systemName: "gearshape")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsView: View {
|
||||
@State private var columnVisibility: NavigationSplitViewVisibility = .all
|
||||
@State private var state = SettingsState()
|
||||
@State private var hovering = false
|
||||
@State private var selectedMenu: MenuItem = .accout
|
||||
@ -21,7 +22,7 @@ struct SettingsView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationSplitView {
|
||||
NavigationSplitView(columnVisibility: $columnVisibility) {
|
||||
List(MenuItem.allCases, id: \.self) { menu in
|
||||
HStack(alignment: .center) {
|
||||
Rectangle()
|
||||
@ -46,7 +47,7 @@ struct SettingsView: View {
|
||||
}
|
||||
}
|
||||
.listStyle(.sidebar)
|
||||
.border(Color.red)
|
||||
.frame(minWidth: 180, idealWidth: 200, maxWidth: 250)
|
||||
|
||||
} detail: {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
|
||||
@ -48,10 +48,12 @@ struct punchnetApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup(id: "mainWindow") {
|
||||
RootView()
|
||||
//NetworkDisconnctedView(state: NetworkState())
|
||||
.frame(width: 800, height: 500)
|
||||
.onAppear {
|
||||
// 获取主屏幕的尺寸
|
||||
guard let screenFrame = NSScreen.main?.frame else { return }
|
||||
guard let screenFrame = NSScreen.main?.frame else {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取当前应用的窗口(假设只有一个窗口)
|
||||
NSApplication.shared.windows.forEach { window in
|
||||
@ -81,10 +83,10 @@ struct punchnetApp: App {
|
||||
.windowResizability(.contentSize)
|
||||
.windowToolbarStyle(.unified)
|
||||
|
||||
Window("", id: "abortPunchnet") {
|
||||
AbortView()
|
||||
.frame(minWidth: 300, maxWidth: 300, minHeight: 500, maxHeight: 500)
|
||||
Window("设置", id: "settings") {
|
||||
SettingsView()
|
||||
}
|
||||
.defaultSize(width: 800, height: 500)
|
||||
|
||||
MenuBarExtra("punchnet", image: "logo_32") {
|
||||
VStack {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user