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