NetNewsWire/Multiplatform/Shared/Sidebar/SidebarView.swift

41 lines
892 B
Swift
Raw Normal View History

2020-06-28 21:21:43 +02:00
//
// SidebarView.swift
// NetNewsWire
//
// Created by Maurice Parker on 6/28/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import SwiftUI
struct SidebarView: View {
@EnvironmentObject private var sceneModel: SceneModel
@StateObject private var sidebarModel = SidebarModel()
2020-06-28 21:21:43 +02:00
var body: some View {
2020-06-29 13:16:48 +02:00
List {
ForEach(sidebarModel.sidebarItems) { section in
2020-06-29 13:31:50 +02:00
OutlineGroup(sidebarModel.sidebarItems, children: \.children) { sidebarItem in
Text(sidebarItem.nameForDisplay)
2020-06-29 13:16:48 +02:00
}
}
2020-06-29 13:16:48 +02:00
}
.navigationTitle(Text("Feeds"))
2020-06-29 13:31:50 +02:00
.listStyle(SidebarListStyle())
2020-06-29 13:16:48 +02:00
.onAppear {
sceneModel.sidebarModel = sidebarModel
sidebarModel.delegate = sceneModel
sidebarModel.rebuildSidebarItems()
}
}
2020-06-28 21:21:43 +02:00
}
struct SidebarView_Previews: PreviewProvider {
static var previews: some View {
SidebarView()
.environmentObject(SceneModel())
2020-06-28 21:21:43 +02:00
}
}