Category "swiftui"

Rectangle progress bar swiftUI

Hey does someone know how can I create rectangle progress bar in swiftUI? Something like this? https://i.stack.imgur.com/CMwB3.gif I have tried this: struct

Get Shape for view dynamically in SwiftUI

Using Swift 5.2 I would like to create a function to dynamically change the Shape I have a view like import SwiftUI struct CardView: View { let suit : S

SwiftUI DatePicker breaks sheet dismiss?

Scenario: RootScreen presents DateScreen modally though .sheet DateScreen has a DatePicker with CompactDatePickerStyle() and a button to dismiss the modal User

unable to align multiple controls in SwiftUI

I'm trying to align controls as shown in "Storyboard" pic using the SwiftUI but not sure why still there is distance between segment control and search-Bar, and

Swipe to delete function

using my code below how can I swipe right to left on a Task to have an option to be able to delete it. I have tried using .SwipeAction but have gotten no luck w

SwiftUI - how to avoid navigation hardcoded into the view?

I try to do the architecture for a bigger, production ready SwiftUI App. I am running all the time into the same problem which points to a major design flaw in

How to apply a context menu to buttons in a SwiftUI list row?

When I'm long-pressing on a button in list row, all of context menus for all buttons are shown. It looks like the whole list row is selected. How can I make it

SwiftUI: Display file url from Array after user Picks file using DocumentPicker

I followed a tutorial on getting Url from a Document a user chooses and be able to display it on the View. My problem now is I want to add those Url's into an a

SwiftUI MVVM Coordinator/Router/NavigationLink

I am having problems to translate UIKit architecture patterns to SwiftUI. My current pattern is mostly MVVM with Coordinators/Routers. The MVVM part seems quite

How to detect current device using SwiftUI?

I am trying to determine whether the device being used is iPhone or iPad. Please see this question: Detect current device with UI_USER_INTERFACE_IDIOM() in Swi

Manually set light/dark mode in SwiftUI and save users choice

I found a solution to manually set light/dark mode in a swiftui app in another thread found here https://stackoverflow.com/a/58476468/11698443 it mostly works,

How to enable pasting with keyboard shortcut into SwiftUI macOS agent application

I'm creating an app with Swift 5 and SwiftUI. The application runs as a status bar app (LSUIElement is true). I've created a simple preferences window with Swif

SwiftUI / Xcode Error - Updating took more than 5 seconds

When I try to preview one of my views in the canvas I keep getting the following error: PreviewUpdateTimedOutError: Updating took more than 5 seconds All

How to work with bindings when using a view model vs using @Binding in the view itself?

@State and @Binding work so well in SwiftUI, as long as you put all the view's data inside itself, like this: struct ColorView: View { @Binding public var

How to animate transition between views in SwiftUI?

I have the following view. import SwiftUI struct AppView: View { @EnvironmentObject var appStore: AppStore var body: some View { ZStack {

SwiftUI Pass Value from Geometry Reader to Function

I have a view which uses Geometry Reader to calculate how large the image area should be: GeometryReader { metrics in ZStack{ self.image

SwiftUI - how to detect long press on Button?

I have a Button where when it gets pressed, it performs some actions. But I would like to modify the same Button to detect a longer press, and perform a differe

SwiftUI HStack with equal Height

I want the Text("111") to have the equal height of the VStack containing 2222... and 333.... struct Test7: View { var body: some View { HStack (alignment:

Get CGRect of View

I'm using a "RectGetter" to get the CGRect of a View. Like this: Text("Hello") .background(RectGetter(rect: self.$rect)) struct RectGetter: View {

Swiftui - Fetch data after login

I'm starting to learn SwiftUI and i'm looking for better solution to fetch user data after successful login. For example, i need to see if the user has the acco