I want this file(file2) to revvieve edge input results of file1, modify them as desired then send them along to file 3 (charts) for realtime feedback. how do I pass variables into other variables as well across files while keeping the information live and modifiable?
Paste bin: Paste Bin Folder
`
/*
I want this file(file2) to revvieve edge input results of file1, modify them as desired then send them along to file 3 (charts) for realtime feedback. how do I pass variables into other variables as well across files while keeping the information live and modifiable?
*/
import PlaygroundSupport
import Foundation
import SwiftUI
import UniformTypeIdentifiers
struct sliderHalf: View {
@State private var showingPopover = false
@State private var edge = 50.0
@State private var math = 50.0
@State private var physics = 50.0
@State private var isEditing = false
var body: some View {
VStack(alignment: .leading) {
Divider()
VStack(alignment: .leading) {
Button {
showingPopover = true
} label: {
ZStack(alignment: .leading){
RoundedRectangle(cornerRadius: 4.0)
.aspectRatio(4.5, contentMode: ContentMode.fit)
.shadow(radius: 3)
.foregroundColor(.blue)
HStack(alignment: .center){
Image("Hornet").resizable()
.aspectRatio(contentMode: .fit).padding(.leading, 2).padding(.trailing, 2)
.frame(
maxWidth: 50,
maxHeight: 50, alignment: .leading).shadow(radius: 3)
Text("Lab Math")
}.foregroundColor(.white)
// Label("Overlay HUD", systemimage: "cloud")
// .foregroundColor(.white)
.padding(.leading, 2)
}
.buttonStyle(.plain)
.popover(isPresented: $showingPopover) {
VStack(alignment: .leading){
Text("Crystalline")
.font(.subheadline)
Text("Proportional")
.font(.subheadline)
Text("Congruent")
.font(.subheadline)
Divider()
Text("Edge")
.font(.subheadline)
VStack(alignment: .center){
Slider(
value: $edge,
in: 0...100,
onEditingChanged: { editing in
isEditing = editing
}
)
Text("\(edge)")
.foregroundColor(isEditing ? .yellow : .white)
}
Text("Math")
.font(.subheadline)
VStack(alignment: .center){
Slider(
value: $math,
in: 0...100,
onEditingChanged: { editing in
isEditing = editing
}
)
Text("\(math)")
.foregroundColor(isEditing ? .yellow : .white)
}
Text("Physics")
.font(.subheadline)
VStack(alignment: .center){
Slider(
value: $physics,
in: 0...100,
onEditingChanged: { editing in
isEditing = editing
}
)
Text("\(physics)")
.foregroundColor(isEditing ? .yellow : .white)
}
} .frame(width: 300, height: 400) .shadow(radius: 3)
.padding(5)
.background(Color.blue.opacity(1.0))
// .padding()
} .foregroundColor(.white)
} .frame(
maxWidth: 200,
maxHeight: .infinity, alignment: .topLeading).padding(8)
}
HStack(alignment: .top){
VStack(alignment: .leading){
Text("Legend")
.italic()
Divider().frame(width:100)
VStack(alignment: .leading){
Text("File 1")
.font(.subheadline)
VStack(alignment: .leading){
RoundedRectangle(cornerRadius: 2.0)
.aspectRatio(1, contentMode: ContentMode.fill)
.shadow(radius: 3)
.shadow(radius: 3)
.foregroundColor(.indigo)
}.frame(maxWidth: 10, maxHeight: 10, alignment: .topLeading)
}
Text("File 2")
.font(.subheadline)
VStack(alignment: .leading){
VStack(alignment: .leading){
RoundedRectangle(cornerRadius: 2.0)
.aspectRatio(1, contentMode: ContentMode.fill)
.shadow(radius: 3)
.shadow(radius: 3)
.foregroundColor(.brown)
}.frame(maxWidth: 10, maxHeight: 10, alignment: .topLeading)
}
Text("File 3")
.font(.subheadline)
VStack(alignment: .leading){
VStack(alignment: .leading){
RoundedRectangle(cornerRadius: 2.0)
.aspectRatio(1, contentMode: ContentMode.fill)
.shadow(radius: 3)
.shadow(radius: 3)
.foregroundColor(.black)
}.frame(maxWidth: 10, maxHeight: 10, alignment: .topLeading)
}
}
}.padding()
}.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading).background(Color.brown)
}
}
`
DART Edge Live Data Passing and Editing Interface
I have tried other methods to pass data that cater to specific scenarios such as pdf rendering or grabbing image of the day, etc but I need something specific to math and science where variables can be manipulated live while updating other variables. I’m looking for the most optimal method to pass and manipulate data so I can pass the whole math lab via a scenario down the road such as cloud scaling. If it is specific to math or science I don’t quite have SwiftUI down with things like: State, Static, ObservableObject, Object, Published, etc.
I am developing solely on iPad Pro 6th gen Swift Playgrounds.