Category "swiftui"

SwiftUI modal presentation works only once from navigationBarItems

Here is a bug in SwiftUI when you show modal from button inside navigation bar items. In code below Button 1 works as expected, but Button 2 works only once: s

What happens when you apply an idealHeight to a Spacer's frame in SwiftUI?

I'm curious what SwiftUI is doing under the covers when applying an idealHeight to a Spacer's frame. Will the Spacer use the idealHeight as its target height bu

SwiftUI: List does not update automatically after deleting all Core Data Entity entries

I know SwiftUI uses state-driven rendering. So I was assuming, when I delete Core Data Entity entries, that my List with Core Data elements gets refreshed immed

SwiftUI: upload multiple images to Firebase

Goal: upload 3 images from SwiftUI app to Firebase, with different URL for each. Problem: I only managed to upload 1. What I have tried (but didn't work).... :

How to make inner shadow in SwiftUI?

How can I use Inner Shadow on a Rectangle()? Rectangle() .foregroundColor(.green) .frame(width: 400, height: 300) I can only manage t

SwiftUI - Pulsating Animation & Change Colour

I'm trying to change the colour of my animation based on the state of something. The colour change works but it animates the previous (orange) colour with it. I

Dismiss a parent modal in SwiftUI from a NavigationView

I am aware of how to dismiss a modal from a child view using @Environment (\.presentationMode) var presentationMode / self.presentationMode.wrappedValue.dismiss

SwiftUI: DatePicker is it possible to display date/time in other timezone then current?

In UIDatePicker we can do something like this datePicker.timeZone = TimeZone(secondsFromGMT: 5*60*60) in order to specify timezone of datepicker. But how

SwiftUI drag gesture across multiple subviews

I'm attempting to create a grid of small square views, that when the user hovers over them with their thumb (or swipes across them), the little squares will tem

How do I properly test a var that changes through a publisher in my viewModel in XCTestCase

Im trying to test a simple publisher within the Combine framework and SwiftUI. My test tests a published bool named isValid in my view model. My view model al

Passing an ObservableObject model through another ObObject?

I feel like I can sort of understand why what I'm doing isn't working but I'm still trying to wrap my head around Combine and SwiftUI so any help here would be

SwiftUI Force Portrait On All Except One View

I have a SwiftUI project. For all but one of the views, I want to allow portrait and only portrait mode. For only one view, I want to allow both portrait and la

Is it correct to expect internal updates of a SwiftUI DynamicProperty property wrapper to trigger a view update?

I'm attempting to create a custom property wrapper supported by SwiftUI, meaning that changes to the corresponding properties values would cause an update to th

Binding ViewModel and TextFields with SwiftUI

I'm looking for the best way to create a bind between textfields and ViewModel. At the moment I'm creating a @State for each textfield and I'm manually sending

SwiftUI Button inside a NavigationLink

I have a view for a list item that displays some basic information about a task embedded within a navigationLink. I would like to use a button within the navi

How to limit the number of results in a FetchRequest in SwiftUI

How can I limit the size of the retrieved FetchedResults when making a FetchRequest to CoreData? struct ContentView: View { var fetchRequest:FetchRequest&l

Quickest way to dirty a FileReferenceDocument in SwiftUI for macOS

I have a number of changes to a document-based application which are not undoable (conceptually, think quiz progress) but which should dirty the document so the

SwiftUI picker .onChanged only firing on 2+ selection changes

I have a picker that will change an attribute of an object that is bound to the view. When the picker is changed I want to update the bound object so the change

How can I detect a right-click in SwiftUI?

I'm writing a simple Mines app to help me get to know SwiftUI. As such, I want primary click (usually LMB) to "dig" (reveal whether there's a mine there), and s

SwiftUI: How to only run code when the user stops typing in a TextField?

so I'm trying to make a search bar that doesn't run the code that displays the results until the user stops typing for 2 seconds (AKA it should reset a sort of