Skip to content

Commit

Permalink
bookmark summary
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbarela committed Jan 31, 2024
1 parent bf4eb64 commit 5b75e52
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions Marlin/Marlin/UI/ASAM/AsamList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct AsamList: View {
switch asamItem {
case .listItem(let asam):
AsamSummaryView(asam: asam)
.showBookmarkNotes(true)
.paddedCard()
.onAppear {
if rows.last == asamItem {
Expand Down
27 changes: 21 additions & 6 deletions Marlin/Marlin/UI/Bookmark/BookmarkSummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,47 @@ struct BookmarkSummary: DataSourceSummaryView {

var showBookmarkNotes: Bool = true
var bookmark: Bookmark?
@State var dataSource: (any DataSource)?
@State var dataSource: (any Bookmarkable)?

var body: some View {
Self._printChanges()

return VStack(alignment: .leading) {
if let dataSource = dataSource as? (any DataSourceViewBuilder) {
HStack {

HStack {
if let dataSource = dataSource {
DataSourceIcon(dataSource: type(of: dataSource).definition)
Spacer()
}
}
switch dataSource {
case let dataSource as AsamModel:
AsamSummaryView(asam: AsamListModel(asamModel: dataSource))
.showBookmarkNotes(true)
case let dataSource as ModuModel:
ModuSummaryView(modu: ModuListModel(moduModel: dataSource))
.showBookmarkNotes(true)
case let dataSource as PortModel:
PortSummaryView(port: PortListModel(portModel: dataSource))
.showBookmarkNotes(true)
case let dataSource as any DataSourceViewBuilder:
AnyView(
dataSource.summary
.setShowTitle(true)
.setShowSectionHeader(false)
.setShowMoreDetails(false)
.showBookmarkNotes(true)
)
default:
EmptyView()
}

}
.task {
let context = PersistenceController.current.viewContext
context.perform {
dataSource = bookmark?.getDataSourceItem(
context: PersistenceController.current.viewContext) as? (any DataSource)
context: PersistenceController.current.viewContext) as? (any Bookmarkable)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Marlin/Marlin/UI/MODU/ModuList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct ModuList: View {
switch moduItem {
case .listItem(let modu):
ModuSummaryView(modu: modu)
.showBookmarkNotes(true)
.paddedCard()
.onAppear {
if rows.last == moduItem {
Expand Down

0 comments on commit 5b75e52

Please sign in to comment.