2020-06-29 20:14:03 +02:00
|
|
|
//
|
2020-07-06 08:32:43 +02:00
|
|
|
// SidebarContainerView.swift
|
2020-06-29 20:14:03 +02:00
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 6/28/20.
|
|
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
2020-07-06 08:32:43 +02:00
|
|
|
struct SidebarContainerView: View {
|
2020-06-29 20:14:03 +02:00
|
|
|
|
2020-07-12 01:22:47 +02:00
|
|
|
@Environment(\.undoManager) var undoManager
|
2020-06-29 20:14:03 +02:00
|
|
|
@EnvironmentObject private var sceneModel: SceneModel
|
|
|
|
|
2020-07-26 14:06:00 +02:00
|
|
|
@State var sidebarItems = [SidebarItem]()
|
|
|
|
|
2020-06-30 15:22:23 +02:00
|
|
|
@ViewBuilder var body: some View {
|
2020-07-26 14:06:00 +02:00
|
|
|
SidebarView(sidebarItems: $sidebarItems)
|
2020-07-05 21:45:19 +02:00
|
|
|
.modifier(SidebarToolbarModifier())
|
2020-07-06 08:32:43 +02:00
|
|
|
.modifier(SidebarListStyleModifier())
|
2020-07-12 01:22:47 +02:00
|
|
|
.environmentObject(sceneModel.sidebarModel)
|
2020-06-29 20:14:03 +02:00
|
|
|
.onAppear {
|
2020-07-12 01:22:47 +02:00
|
|
|
sceneModel.sidebarModel.undoManager = undoManager
|
2020-06-29 20:14:03 +02:00
|
|
|
}
|
2020-07-26 14:06:00 +02:00
|
|
|
.onReceive(sceneModel.sidebarModel.sidebarItemsPublisher!) { newItems in
|
|
|
|
withAnimation {
|
|
|
|
sidebarItems = newItems
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 20:14:03 +02:00
|
|
|
}
|
2020-06-30 15:22:23 +02:00
|
|
|
|
2020-06-29 20:14:03 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 08:32:43 +02:00
|
|
|
struct SidebarContainerView_Previews: PreviewProvider {
|
2020-06-29 20:14:03 +02:00
|
|
|
static var previews: some View {
|
2020-07-06 08:32:43 +02:00
|
|
|
SidebarContainerView()
|
2020-06-29 20:14:03 +02:00
|
|
|
.environmentObject(SceneModel())
|
|
|
|
}
|
|
|
|
}
|