SwiftUI add sound effect when a button is pressed - swiftui

I would like to add a sound effect when a button is pressed in my app for SwiftUI. The button has another feature, but I just want to add a sound effect. I have found information for previous versions of Xcode using UIkit, but I'm not understanding how to do it in SwiftUI.
Edit: I'm very new to programming if that explains my lack of knowledge.

from answer:
Play reminder sound SwiftUI
you can use this simple method:
import AVFoundation
AudioServicesPlaySystemSound(1026)
where the number 1026 is the SystemSound id.

Related

XCode 12.2/Big Sur: Where are the object inspector and SwiftUI library?

I don't know how to accurately phrase this, but after upgrading to Big Sur and XCode 12.2, I have discovered that I cannot Command-Click on a SwiftUI keyword (i.e., HStack or TextField) and get the object-specific inspector to come up. On my right panel I only ever see the inspector/settings for the .swift source file I have open; how do I get the object-specific context menu to come back?
Another issue, probably related to the first: when pressing the "+" button to insert a new object from the library, there are no longer any SwiftUI library objects available to pick; see the screenshot below:
[
The Canvas Editor must be open, and then everything works.

iOS SwiftUI how to bring up extra actions like "Embed in VStack" when interacting with code?

I am looking at this SwiftUI tutorial and it suggests I can see extra actions upon Command-Clicking the SwiftUI elements in code. In my Xcode, this jumps me to the class definition.
I see there's an option in XCode 11.0 t change the Option key to show SwiftUI inspector, however, this still does not let me modify SwiftUI code elements using actions like "Embed in VStack"
How can I get both inspector and extra SwiftUI actions when interacting with SwiftUI Code (not the preview)?
Extra SwiftUI actions show when Canvas is opened (shortcut: Option-Command-Enter or ⌥+⌘+↵):
canvas is closed
canvas is opened
The accepted answer doesn't work for me on macOS 10.15.5 and Xcode 11.4.1.
The Good news is that you can get it via a shortcut of [Command][Shift][Left Click] on a SwiftUI element or by clicking Show Code Actions on the right click menu.
Instead of using the mouse, I recommend using the Xcode hotkey for bringing up code actions. Navigate to Preferences -> Key Bindings and search for Show Code Actions. You'll see the preset hotkey which you can then customize. My default key binding was Shift+Command+A. Just make sure you cursor is over the intended element when you press the hotkey.
You can change the command click behavior where you were looking under Xcode -> Preferences, Navigate tab.
Rather unintuitively, if you pick "Selects Code Structure", then command+click will bring up the SwiftUI menu options you're looking for (granted the canvas is open).
If you do this, you can still jump to definition via control+command+click
Conversely, if you'd prefer to continue to use command+click to jump to definition, you can instead use control+command+click to bring up the SwiftUI menu options.
Command clicking on a view will not work in Xcode 12.2 and 12.3 (under MacOS 10.15.5) if you have your preferences different than Xcode expects.
You have to change your Navigation preferences for Command-click on Code: to Selects Code Structure before the proper menu will appear when you command click on a View.
To change this. press command , to open your preferences and select the Navigation button. The option you need to change is in the first popup menu.

How do we add "InputAccessoryItem"s in Swift UI?

Using SwiftUI and running into an issue with the keyboard. I want to use the .deicmalPad but I can't dismiss it since it has no "return" button.
Found a workaround: use UIApplication.shared.windows[0].endEditing(true) on a button. (Tried using it on the viewController for the app but it broke NavigationLinks)
Now I want to add the "Next", "Previous" and "Submit" strip above the keyboard, like in this picture: http://brainwashinc.com/wp-content/uploads/2017/07/Simulator-Screen-Shot-Jul-28-2017-9.07.42-AM.png
can't find SwiftUI documentation for this feature, only finding incompatable UIKit solutions involving inputAccessoryView and it's items.
Ultimatly want to use the "Submit" button's event to use UIApplication.shared.windows[0].endEditing(true) and finally get the keyboard to go away.
Thanks in advance

GDK : How to show status similar to 'Recording" and 'Complete"

I'm developing a GDK app where I need to provide an user experience to display status text similar to video recording status that Glass provides ( displaying "Recording" status then displaying progress indicator and finally showing 'Complete' text ). Appreciate your input.
Right now, you'll need to write your own UI logic to do this (perhaps by using a Dialog with a custom layout that has the appropriate centered label and icon, with a progress bar at the bottom, and changing the label and dismissing the dialog when the action is complete).
You may want to follow issue 271 in our issue tracker, which covers the progress indicator part of this flow.
Tony is right. There is no way to do this naively but you can build it yourself. You can create a layout that is build exactly like the menu is built in the GDK, and then just update the setcontentview() with a new layout each time you want to move to the next card. Also you can build a layout with the holo horizontal progressbar to get the general idea but it won't be like the one Google uses.
Also wanted to add that I have built a repo that you can drop into your project for this. Here is the link: https://github.com/w9jds/GDK-ProgressBar

How do I keep a button depressed in C++?

I want to create a navigation panel in my C++.net application, and I want to keep a button (or similar component) depressed to show that is the page the user is currently on.
Here is a image of what I mean:
How do I create a button that looks like that. (After further inspection, I think it's not a button, however, I cannot figure out the exact control unless it is a image drawn on the screen.)
Thanks.
That is commonly called an "Outlook Bar". There are several examples at codeproject.com