Swiftly/src/ContentView.swift

31 lines
999 B
Swift

import SwiftUI
struct ContentView: View {
@ObservedObject var state: AppState
@State private var sidebarVisible: Bool = false
@AppStorage("themeMode") private var themeMode: String = "auto"
var body: some View {
let _ = themeMode
HSplitView {
if sidebarVisible {
SidebarView(state: state)
.frame(minWidth: 180, idealWidth: 250, maxWidth: 350)
}
EditorView(state: state)
.frame(minWidth: 400)
}
.frame(minWidth: 700, minHeight: 400)
.background(Color(ns: Theme.current.base))
.onReceive(NotificationCenter.default.publisher(for: .toggleSidebar)) { _ in
withAnimation { sidebarVisible.toggle() }
}
}
}
extension Notification.Name {
static let toggleSidebar = Notification.Name("toggleSidebar")
static let focusEditor = Notification.Name("focusEditor")
static let focusTitle = Notification.Name("focusTitle")
}