From ae3080e486115bd854a194211753c08164820f48 Mon Sep 17 00:00:00 2001 From: "Li, Zhen" Date: Tue, 20 Feb 2024 22:13:34 -0500 Subject: [PATCH] Fix Observation --- Sources/Grape/Views/ForceDirectedGraph+Gesture.swift | 2 +- Sources/Grape/Views/ForceDirectedGraph+View.swift | 2 +- Sources/Grape/Views/ForceDirectedGraphModel.swift | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Grape/Views/ForceDirectedGraph+Gesture.swift b/Sources/Grape/Views/ForceDirectedGraph+Gesture.swift index 63f0909..90da0e5 100644 --- a/Sources/Grape/Views/ForceDirectedGraph+Gesture.swift +++ b/Sources/Grape/Views/ForceDirectedGraph+Gesture.swift @@ -183,7 +183,7 @@ extension ForceDirectedGraph { extension ForceDirectedGraph { @inlinable public func onTicked( - perform action: @escaping (KeyFrame) -> Void + perform action: @escaping (UInt) -> Void ) -> Self { self.model._onTicked = action return self diff --git a/Sources/Grape/Views/ForceDirectedGraph+View.swift b/Sources/Grape/Views/ForceDirectedGraph+View.swift index 69d935f..9fc30e3 100644 --- a/Sources/Grape/Views/ForceDirectedGraph+View.swift +++ b/Sources/Grape/Views/ForceDirectedGraph+View.swift @@ -46,7 +46,7 @@ extension ForceDirectedGraph: View { @inlinable var debugView: some View { VStack(alignment: .leading, spacing: 8.0) { - Text("Elapsed Time: \(model.currentFrame.rawValue)") + Text("Elapsed Time: \(model.currentFrame)") Divider() Text(self.model.changeMessage) Divider() diff --git a/Sources/Grape/Views/ForceDirectedGraphModel.swift b/Sources/Grape/Views/ForceDirectedGraphModel.swift index 63fca79..9e2be97 100644 --- a/Sources/Grape/Views/ForceDirectedGraphModel.swift +++ b/Sources/Grape/Views/ForceDirectedGraphModel.swift @@ -71,7 +71,7 @@ public final class ForceDirectedGraphModel { var _$changeMessage = "N/A" @usableFromInline - var _$currentFrame: KeyFrame = 0 + var _$currentFrame: UInt = 0 @inlinable var changeMessage: String { @@ -93,7 +93,7 @@ public final class ForceDirectedGraphModel { } @inlinable - var currentFrame: KeyFrame { + var currentFrame: UInt { @storageRestrictions(initializes: _$currentFrame) init(initialValue) { _$currentFrame = initialValue @@ -119,7 +119,7 @@ public final class ForceDirectedGraphModel { var scheduledTimer: Timer? = nil @usableFromInline - var _onTicked: ((KeyFrame) -> Void)? = nil + var _onTicked: ((UInt) -> Void)? = nil @usableFromInline var _onNodeDragChanged: ((NodeID, CGPoint) -> Void)? = nil @@ -245,7 +245,7 @@ extension ForceDirectedGraphModel { func tick() { withMutation(keyPath: \.currentFrame) { simulationContext.storage.tick() - currentFrame.advance() + currentFrame += 1 } _onTicked?(currentFrame) }