-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[State Management] Add bidirection state management for running state…
… and transformation.
- Loading branch information
li3zhen1
committed
Feb 23, 2024
1 parent
df0963e
commit 2374701
Showing
13 changed files
with
173 additions
and
132 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
38 changes: 38 additions & 0 deletions
38
Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/GraphStateToolbar.swift
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,38 @@ | ||
// | ||
// GraphStateToolbar.swift | ||
// ForceDirectedGraphExample | ||
// | ||
// Created by li3zhen1 on 2/22/24. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
import Grape | ||
|
||
struct GraphStateToggle: View { | ||
@Bindable var graphStates: ForceDirectedGraphState | ||
var body: some View { | ||
|
||
Group { | ||
Button { | ||
graphStates.modelTransform.scaling(by: 0.9) | ||
} label: { | ||
Image(systemName: "minus") | ||
} | ||
Text(String(format:"Scale: %.2f", graphStates.modelTransform.scale)) | ||
.fontDesign(.monospaced) | ||
Button { | ||
graphStates.modelTransform.scaling(by: 1.1) | ||
} label: { | ||
Image(systemName: "plus") | ||
} | ||
} | ||
|
||
Button { | ||
graphStates.isRunning.toggle() | ||
} label: { | ||
Image(systemName: graphStates.isRunning ? "pause.fill" : "play.fill") | ||
Text(graphStates.isRunning ? "Pause" : "Start") | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.