This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add turtle, ntriples, sparql modes + Add tooltips on hover
- Loading branch information
1 parent
6569d00
commit 569dad0
Showing
5 changed files
with
100 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// Tooltip.swift | ||
// Snip | ||
// | ||
// Created by Anthony Fernandez on 11/2/20. | ||
// Copyright © 2020 pictarine. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
|
||
extension View { | ||
func tooltip(_ tip: String) -> some View { | ||
background(GeometryReader { childGeometry in | ||
TooltipView(tip, geometry: childGeometry) { | ||
self | ||
} | ||
}) | ||
} | ||
} | ||
|
||
private struct TooltipView<Content>: View where Content: View { | ||
let content: () -> Content | ||
let tip: String | ||
let geometry: GeometryProxy | ||
|
||
init(_ tip: String, geometry: GeometryProxy, @ViewBuilder content: @escaping () -> Content) { | ||
self.content = content | ||
self.tip = tip | ||
self.geometry = geometry | ||
} | ||
|
||
var body: some View { | ||
Tooltip(tip, content: content) | ||
.frame(width: geometry.size.width, height: geometry.size.height) | ||
} | ||
} | ||
|
||
private struct Tooltip<Content: View>: NSViewRepresentable { | ||
typealias NSViewType = NSHostingView<Content> | ||
|
||
init(_ text: String?, @ViewBuilder content: () -> Content) { | ||
self.text = text | ||
self.content = content() | ||
} | ||
|
||
let text: String? | ||
let content: Content | ||
|
||
func makeNSView(context _: Context) -> NSHostingView<Content> { | ||
NSViewType(rootView: content) | ||
} | ||
|
||
func updateNSView(_ nsView: NSHostingView<Content>, context _: Context) { | ||
nsView.rootView = content | ||
nsView.toolTip = text | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters