This file contains hidden or 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
| import SwiftUI | |
| import SwiftData | |
| import Algorithms | |
| struct EntryListView: View { | |
| @Query(sort: \Entry.created, order: .reverse) private var entries: [Entry] | |
| let entryDateFormatter = DateFormatter() | |
| let sectionDateFormatter = DateFormatter() | |
| init() { |
This file contains hidden or 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
| import SwiftUI | |
| import SwiftData | |
| import Algorithms | |
| struct EntryListView: View { | |
| @Query(sort: \Entry.created, order: .reverse) private var entries: [Entry] | |
| let entryDateFormatter = DateFormatter() | |
| let sectionDateFormatter = DateFormatter() | |
| init() { |
This file contains hidden or 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
| import Algorithms | |
| func chunkEntries(entriesToChunk: [Entry]) -> [(String, [Entry])] { | |
| let chunks = entriesToChunk.chunked(on: { | |
| Calendar.current.dateComponents([.year, .month], from: $0.created) | |
| }) | |
| return chunks.map { | |
| let chunkDate = Calendar.current.date(from: $0.0) | |
| return (sectionDateFormatter.string(from: chunkDate!), Array($0.1)) | |
| } |
This file contains hidden or 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
| import SwiftUI | |
| import SwiftData | |
| struct EntryListView: View { | |
| @Query(sort: \Entry.created, order: .reverse) private var entries: [Entry] | |
| let entryDateFormatter = DateFormatter() | |
| init() { | |
| entryDateFormatter.dateFormat = "EEEE, dd MMM yyyy" | |
| } |
This file contains hidden or 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
| import Foundation | |
| import SwiftData | |
| @Model class Entry { | |
| var created: Date = Date.now | |
| var text: String = "" | |
| init(created: Date, text: String) { | |
| self.created = created | |
| self.text = text |
This file contains hidden or 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
| const { useRef } = React | |
| const Graph = () => { | |
| const fgRef = useRef(); | |
| return <ForceGraph2D | |
| ref={fgRef} | |
| graphData={data} | |
| nodeCanvasObject={nodeCanvasObject} | |
| nodePointerAreaPaint={nodePointerAreaPaint} |
This file contains hidden or 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
| function nodeCanvasObject(node, ctx, globalScale) { | |
| const nodeColour = 'red' | |
| const fontSize = 12/globalScale; | |
| ctx.font = `${fontSize}px Sans-Serif`; | |
| const textWidth = ctx.measureText(node.name).width; | |
| const bckgDimensions = [textWidth, fontSize].map(n => n + fontSize * 0.2); // some padding | |
| // node circle | |
| ctx.fillStyle = 'red' | |
| ctx.beginPath() |
This file contains hidden or 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
| ReactDOM.render( | |
| <ForceGraph2D | |
| graphData={data} | |
| />, | |
| document.getElementById('graph') | |
| ) |
This file contains hidden or 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
| const data = { | |
| nodes: [ | |
| { | |
| id: "persona-unauthorised-user", | |
| name: "Unauthorised user" | |
| }, | |
| { | |
| id: "persona-authorised-user", | |
| name: "Authorised user" | |
| }, |
This file contains hidden or 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
| struct CVDetailView: View { | |
| @State private var cvdata: Data? | |
| var body: some View { | |
| VStack { | |
| if (cvData != nil) { | |
| CVPreviewView(pdfData: PDFDocument(data: cvData!)!) | |
| } | |
| } | |
| .onAppear { |