Show linking posts on page content
This commit is contained in:
25
CHDataManagement/Views/Generic/ListPopup.swift
Normal file
25
CHDataManagement/Views/Generic/ListPopup.swift
Normal file
@ -0,0 +1,25 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ListPopup: View {
|
||||
|
||||
@Environment(\.dismiss)
|
||||
var dismiss
|
||||
|
||||
let items: [String]
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
List {
|
||||
ForEach(items, id: \.self) { page in
|
||||
Text(page)
|
||||
}
|
||||
}
|
||||
.frame(minHeight: min(CGFloat(items.count) * 31, 500))
|
||||
Button("Dismiss") { dismiss() }
|
||||
}
|
||||
.padding(.vertical)
|
||||
.onTapGesture {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
36
CHDataManagement/Views/Generic/TextWithPopup.swift
Normal file
36
CHDataManagement/Views/Generic/TextWithPopup.swift
Normal file
@ -0,0 +1,36 @@
|
||||
import SwiftUI
|
||||
import SFSafeSymbols
|
||||
|
||||
struct TextWithPopup: View {
|
||||
|
||||
let symbol: SFSymbol
|
||||
|
||||
let text: LocalizedStringKey
|
||||
|
||||
let items: [String]
|
||||
|
||||
@State
|
||||
private var isHovering = false
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Image(systemSymbol: symbol)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 16, height: 16)
|
||||
Text(text)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
if items.count > 0 {
|
||||
isHovering.toggle()
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $isHovering) {
|
||||
ListPopup(items: items)
|
||||
.onTapGesture {
|
||||
isHovering.toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -42,9 +42,17 @@ struct LocalizedPageContentView: View {
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
if let generationResults {
|
||||
PageContentResultsView(results: generationResults)
|
||||
}
|
||||
|
||||
HStack {
|
||||
if let generationResults {
|
||||
PageContentResultsView(results: generationResults)
|
||||
}
|
||||
let linkingPosts = content.posts.filter { $0.linkedPage == page }
|
||||
TextWithPopup(
|
||||
symbol: .ipadAndArrowForward,
|
||||
text: "\(linkingPosts.count) linking posts",
|
||||
items: linkingPosts.map { $0.title(in: language) })
|
||||
}.foregroundStyle(.secondary)
|
||||
HighlightedTextEditor(
|
||||
text: $pageContent,
|
||||
highlightRules: .markdown)
|
||||
|
@ -1,64 +1,6 @@
|
||||
import SwiftUI
|
||||
import SFSafeSymbols
|
||||
|
||||
private struct ListPopup: View {
|
||||
|
||||
@Environment(\.dismiss)
|
||||
var dismiss
|
||||
|
||||
let items: [String]
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
List {
|
||||
ForEach(items, id: \.self) { page in
|
||||
Text(page)
|
||||
}
|
||||
}
|
||||
.frame(minHeight: min(CGFloat(items.count) * 31, 500))
|
||||
Button("Dismiss") { dismiss() }
|
||||
}
|
||||
.padding(.vertical)
|
||||
.onTapGesture {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct TextWithPopup: View {
|
||||
|
||||
let symbol: SFSymbol
|
||||
|
||||
let text: LocalizedStringKey
|
||||
|
||||
let items: [String]
|
||||
|
||||
@State
|
||||
private var isHovering = false
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Image(systemSymbol: symbol)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 16, height: 16)
|
||||
Text(text)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
if items.count > 0 {
|
||||
isHovering.toggle()
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $isHovering) {
|
||||
ListPopup(items: items)
|
||||
.onTapGesture {
|
||||
isHovering.toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct PageContentResultsView: View {
|
||||
|
||||
@Environment(\.language)
|
||||
|
Reference in New Issue
Block a user