Category "swiftui"

SwiftUI: Get sidebar isCollapsed state on macOS

I'm using a NavigationView to create a sidebar on macOS. I can toggle the sidebar using this code: Button { NSApp.keyWindow?.firstResponder?.tryToPerform(

SwiftUI - List Line Separator Inset like iOS Settings App

I'm trying to achieve the behavior that's also seen in in the iOS Settings App or for instance the Roborock App (see screenshots below). I'd like to go for an I

SwiftUI Custom List Cell - disable horizontal padding/shrink in EditMode

I'm trying to create a custom List cell in SwiftUI, where the drag-icon in Edit Mode stays inside the cell. By default, the cell gets horizontally shrinked do m

use Firestore model value as toggle to present fullscreen view in SwiftUI

I have two screens in a SwiftUI app. Screen A is displayed after the app launch and contains a button which will update the value for currentWorkoutID on the us

SwiftUI Preview crash with await async iOS15 if returns a struct with UUID

I reduced to very simple code. If the struct has a Int is working, if there is an UUID the preview is crashing (it's working if I run on the simulator or real

Add top shadow to TabView in SwiftUI

I have the following: I'm using a native TabView. I can change the background but I haven't been able to add a little shadow to the top of the UITabBar, I've t

Dynamically add textfields with a for each loop and a button in swiftUI

I am trying to use a ForEach loop to dynamically add textfields inside a form section with a button. Form { ForEach(0..<numberOfItems, id: \.

`Task` blocks main thread when calling async function inside

I have an ObservableObject class and a SwiftUI view. When a button is tapped, I create a Task and call populate (an async function) from within it. I thought th

swiftui matchedGeometryEffect with scaleEffect problem

Why when opening and closing the viewModel (color.green) , the circle tremble and vibrate and the model becomes above the circle when moving when i change the v

swiftui matchedGeometryEffect with scaleEffect problem

Why when opening and closing the viewModel (color.green) , the circle tremble and vibrate and the model becomes above the circle when moving when i change the v

SwiftUI scale path when Image size change

in my project i'm drawing a box over a an image using a custom drawing gesture. Image(uiImage: image!) .resizable() .sca

SwiftUI: use Link with onTapGesture

I want to specify a Link in my SwiftUI view, but I also want to register when/if that Link was actually tapped or not. What's the best way to do this? I tried a

Why is my view not updating when value is updated using @Published and @ObservedObject?

I am creating an object recognition app that takes frames from the camera and outputs a description of the image into a text view on the screen. I can print the

How to make search bar in iOS 15 appear by default?

I started to develop an application using iOS15 and the new .searchable modifier. I have a simple layout with some placeholder results on the main page and a se

SwiftUI Segmented Control Customizable

I want to achieve such a control like this (https://github.com/Yalantis/Segmentio) in SwiftUI (but without image): What would be the best approach? Should I us

SwiftUI: ScrollView that drags bottom sheet with it

I'm trying to create a SwiftUI Scrollview that drags its container like this: https://drive.google.com/file/d/1O92DgsVI1OjM1HEUXUwVywB8gcdShOP-/view?usp=sharing

How to show only the result of a searchable of a List Swiftui

I'm donig a list numbers but i want to show only the result of my searchable not the whole list, how can i hide the list? I was trying to change the state of a

Customisable SwiftUI Refresh spinner

I currently have a simple SwiftUI ScrollView that contains a single element. I have added the .refreshable(action: ) property to allow (pull down) refreshing of

Tappable portions within a string for SwiftUI

I'm trying to add tappable segments to a Text and I have most of it but I cannot make an array of Texts with .onTapGestures. How can I add the tap gestures to

SwiftUI calculate coordinate of the corner of UIimage

I'm looking to find the correct coordinate x,y of the 4 corners of the image display in the view. I wrote this code.. to calculate the first top left corner coo