RiValT_SoundSettings_ViewController
@MainActor
class RiValT_SoundSettings_ViewController : RiValT_Base_ViewController
extension RiValT_SoundSettings_ViewController: UIPickerViewDataSource
extension RiValT_SoundSettings_ViewController: UIPickerViewDelegate
extension RiValT_SoundSettings_ViewController: UIPickerViewAccessibilityDelegate
extension RiValT_SoundSettings_ViewController: AVAudioPlayerDelegate
This view controller is for the popover that appears, when the user selects the sound prefs bar button item.
This has a segmented switch at the top, representing the user’s choice for final alarm sound.
It can be:
Silent
Sound Only
Vibration Only (iPhones only)
Sound and Vibration (iPhones only)
When the user makes a selection, a picker view may appear, directly under the switch. This appears for either Sound Only, or Sound and Vibration. This picker allows the user to choose from the app’s custom sounds.
If there is more than one timer in the group, a “Transition Sound” picker will appear, at the bottom of the screen. This allows the user to select a short transition sound, between timers.
-
The storyboard ID for instantiating the class.
Declaration
Swift
@MainActor static let storyboardID: String -
The timer group associated with these settings.
Declaration
Swift
@MainActor weak var group: TimerGroup? -
The size of the picker font
Declaration
Swift
@MainActor private static let _pickerFont: UIFont -
The padding on either side of the labels we use as picker rows.
Declaration
Swift
@MainActor private static let _pickerPaddingInDisplayUnits: CGFloat -
The SFSymbols names for the play sound button.
Declaration
Swift
@MainActor private static let _playSoundImageNames: [String] -
This is the audio player (for sampling sounds).
Declaration
Swift
@MainActor private var _audioPlayer: AVAudioPlayer! -
If true, then the currently selected alarm sound is playing. This is set or cleared by the “play sound” button, next to the alarm picker.
Declaration
Swift
@MainActor private var _isSoundPlaying: Bool { get set } -
If true, then the currently selected transition sound is playing. This is set or cleared by the “play sound” button, next to the transition sound picker.
Declaration
Swift
@MainActor private var _isTransitionSoundPlaying: Bool { get set } -
This references the presenting view controller.
Declaration
Swift
@MainActor weak var myController: RiValT_EditTimer_ViewController? -
The segmented switch that controls the alarm mode.
Declaration
Swift
@IBOutlet @MainActor weak var alarmModeSegmentedSwitch: UISegmentedControl? -
The picker view for the sounds. Only shown if the seg switch is set to sound.
Declaration
Swift
@IBOutlet @MainActor weak var soundsPickerView: UIPickerView? -
Displays a description of the current sound mode.
Declaration
Swift
@IBOutlet @MainActor weak var soundTypeLabel: UILabel? -
The stack view that holds the main sound selection picker, and the play sound button.
Declaration
Swift
@IBOutlet @MainActor weak var mainPickerStackView: UIView? -
This is the “play sound” button.
Declaration
Swift
@IBOutlet @MainActor weak var soundPlayButton: UIButton? -
The stack view that holds the transition sound selection picker, and the play sound button.
Declaration
Swift
@IBOutlet @MainActor weak var transitionPickerStackView: UIStackView? -
This is a visual separator.
Declaration
Swift
@IBOutlet @MainActor weak var transitionSeparatorView: UIView? -
The label for the transition picker.
Declaration
Swift
@IBOutlet @MainActor weak var transitionPickerLabel: UILabel? -
The picker view for transition sounds.
Declaration
Swift
@IBOutlet @MainActor weak var transitionPickerView: UIPickerView? -
This is the “play sound” button for the transition sounds.
Declaration
Swift
@IBOutlet @MainActor weak var transitionSoundPlayButton: UIButton?
-
This returns the 0-based index of the currently selected transition beep.
Declaration
Swift
@MainActor private var _selectedTransitionSoundIndex: Int { get }
-
Called when the view has loaded.
Declaration
Swift
@MainActor override func viewDidLoad()
-
This calculates the size needed for the popover, and sets the property, which causes the popover to change.
Declaration
Swift
@MainActor private func _setPreferredContentSize() -
This sets the picker to reflect the chosen sound.
Declaration
Swift
@MainActor func setSegmentedSwitchUp() -
This sets the picker to reflect the chosen sound.
Declaration
Swift
@MainActor func setPickerUp() -
Set up the transition sound picker.
Declaration
Swift
@MainActor func setTransitionPickerUp() -
Sets the image to the play button, depending on whether or not the sound is playing. It also starts or stops the sound play.
Declaration
Swift
@MainActor func setUpForSoundPlayMode() -
This plays any sound, using a given URL.
Declaration
Swift
@MainActor func playThisSound(_ inSoundURL: URL, numberOfRepeats inRepeatCount: Int = -1)Parameters
inSoundURLThis is the URI to the sound resource.
inRepeatCountThe number of times to repeat. -1 (continuous), if not provided.
-
Called when the alarm mode is changed.
Declaration
Swift
@IBAction @MainActor func alarmModeSegmentedSwitchHit(_ inSegmentedSwitch: UISegmentedControl)Parameters
inSegmentedSwitchThe segmented switch that changed.
-
Called when the “play sound” button is hit.
Declaration
Swift
@IBAction @MainActor func soundPlayButtonHit(_ inButton: UIButton)
-
Declaration
Swift
@MainActor func numberOfComponents(in: UIPickerView) -> IntParameters
inThe picker view (ignored).
-
Declaration
Swift
@MainActor func pickerView(_ inPickerView: UIPickerView, numberOfRowsInComponent inComponent: Int) -> IntParameters
inPickerViewThe picker view
inComponentThe 0-based index of the component we are querying.
-
This is called when a row is selected. It verifies that the value is OK, and may change the selection, if not.
Declaration
Swift
@MainActor func pickerView(_ inPickerView: UIPickerView, didSelectRow inRow: Int, inComponent: Int)Parameters
inPickerViewThe picker instance.
inRowThe 0-based row index, in the component.
inComponentThe component that contains the selected row (0-based index).
-
This returns the view to display for the picker row.
Declaration
Swift
@MainActor func pickerView(_ inPickerView: UIPickerView, viewForRow inRow: Int, forComponent inComponent: Int, reusing inView: UIView?) -> UIViewParameters
inPickerViewThe picker instance.
inRowThe 0-based row index to be displayed.
inComponentThe 0-based component index for the row.
inViewIf a view will be reused, we’ll use that, instead.
Return Value
A new view, containing the row. If it is selected, it is displayed as reversed.
-
This returns the accessibility hint for the picker component.
Declaration
Swift
@MainActor func pickerView(_ inPickerView: UIPickerView, accessibilityLabelForComponent inLabel: Int) -> String?Parameters
inPickerViewThe picker instance
inLabelThe 0-based component index for the label (ignored).
Return Value
An accessibility string for the component.
-
This returns the accessibility hint for the picker component.
Declaration
Swift
@MainActor func pickerView(_ inPickerView: UIPickerView, accessibilityHintForComponent inHint: Int) -> String?Parameters
inPickerViewThe picker instance
inHintThe 0-based component index for the Hint (ignored).
Return Value
An accessibility string for the component.
-
Called when the sound is done playing.
Declaration
Swift
@MainActor func audioPlayerDidFinishPlaying(_ inAudioPlayer: AVAudioPlayer, successfully inSuccess: Bool)Parameters
inAudioPlayerThe player (ignored)
inSuccessTrue, if the play was successful (also ignored).
View on GitHub