Post

Replies

Boosts

Views

Activity

Accessing variables in one class from other class
I have one child class which contains the username variable. I wanna access it from the parent class. But the variable does not appear when I type. And if I forcefully type Add_new_presets.username, then it throws the following error. Error: Instance member 'username' cannot be used on type 'Add_new_presets'; did you mean to use a value of this type instead? Child class import SwiftUI struct Add_new_presets: View { @State var username: String = "" @FocusState var emailFieldIsFocused :Bool = false var body: some View { TextField( "User name (email address)", text: $username ) .focused($emailFieldIsFocused) .onSubmit { //validate(name: username) } .textInputAutocapitalization(.never) .disableAutocorrection(true) .border(.secondary) } } Parent class import SwiftUI struct ContentView: View { var body: some View { HStack { Add_new_presets() Text( Add_new_presets.username) .foregroundColor(Add_new_presets.emailFieldIsFocused ? .red : .blue) } } }
4
0
1.6k
Dec ’21
Is there any way to prevent a folder (Group) from building/executing?
I have a folder (group) under my project folder, which I collect temporary files and mostly in .txt format. I need those files they are not complete garbage. The issue is xCode (swiftui) is throwing warnings of "No rule to process file..." etc. I know it's because of the txt files etc. How to let xCode (swiftui) know that I don't wanna compile or xCode (swiftui) doesn't even have to go through those files? or How to ignore all the warnings from that specific folder (group)?
1
0
1.3k
Dec ’21
How to popup on top of parent view without affecting parent's size?
The popup works. But when it pops up, it increases the parent view width and height as well (parent is smaller than pop-up and it's a requirement that parent to be smaller than pop-up). I want the popup to be an independent view. The popup should not affect the size of the parent. How to do that? import SwiftUI struct ParentView: View { @State private var WidgetSelectionShowState: Bool = false var body: some View { //Color.purple ZStack { Rectangle () .fill(.blue) .zIndex(0) // Button ("show", action: { withAnimation { WidgetSelectionShowState.toggle() } }) if (WidgetSelectionShowState) { popupPage () } } .frame(width: 300, height: 100, alignment: .center) } } struct popupPage: View { var body: some View { ZStack { Text("This is a popup") Rectangle () .fill(.green) .zIndex(0) //this is the layer order. }.transition(.asymmetric(insertion: .scale, removal: .opacity)) . frame(width: 200, height: 500, alignment: .center ) } }
0
0
855
Jan ’22
3D interactive software - which documentation should I look at first?
Thinking of trying to code a 3d engineering design software. I know it won't be easy to code. The basic idea is the user is given an interactive 3d interface, and the user can move through the 3d space, drag and drop columns beams etc, select deselect dragged or created items, assign values to it, dimensions etc. The user should be able to change sizes of elements (like when user type 10 width, the beam should change it's size to the typed value etc), get fixed to other elements etc. Any idea which documentation should I look at for xcode, swiftui to get an idea or first few steps into interactive 3d etc?
1
0
903
Jan ’23