RiValT_SoundSettings_ViewController

@MainActor
class RiValT_SoundSettings_ViewController : RiValT_GroupEditor_Popover
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.

The segmented switch at the top sets the final alarm mode.

It can be:

  • Silent

  • Sound Only

  • Vibration Only (iPhones only)

  • Sound and Vibration (iPhones only)

For groups with more than one timer, the Transition Sound label and picker appear below the switch.

The final alarm label follows, with a picker for Sound Only or Sound and Vibration.

  • Vertical space between each section label and its sound picker.

    Declaration

    Swift

    @MainActor
    private static let _labelToPickerSpacing: CGFloat
  • 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 row height required by the alarm picker font with two points of padding.

    Declaration

    Swift

    @MainActor
    private static let _pickerRowHeight: CGFloat
  • 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?

Computed Properties

Base Class Overrides

Instance Methods

  • 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

    inSoundURL

    This is the URI to the sound resource.

    inRepeatCount

    The number of times to repeat. -1 (continuous), if not provided.

Callbacks

  • Called when the alarm mode is changed.

    Declaration

    Swift

    @IBAction
    @MainActor
    func alarmModeSegmentedSwitchHit(_ inSegmentedSwitch: UISegmentedControl)

    Parameters

    inSegmentedSwitch

    The segmented switch that changed.

  • Called when the “play sound” button is hit.

    Declaration

    Swift

    @IBAction
    @MainActor
    func soundPlayButtonHit(_ inButton: UIButton)

UIPickerViewDataSource Conformance

UIPickerViewDelegate Conformance

  • 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

    inPickerView

    The picker instance.

    inRow

    The 0-based row index, in the component.

    inComponent

    The 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?) -> UIView

    Parameters

    inPickerView

    The picker instance.

    inRow

    The 0-based row index to be displayed.

    inComponent

    The 0-based component index for the row.

    inView

    If 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.

  • Keep the selected row tall enough for its text when the wheel has a shorter viewport.

    Declaration

    Swift

    @MainActor
    func pickerView(_ inPickerView: UIPickerView, rowHeightForComponent inComponent: Int) -> CGFloat

UIPickerViewAccessibilityDelegate Conformance

  • This returns the accessibility hint for the picker component.

    Declaration

    Swift

    @MainActor
    func pickerView(_ inPickerView: UIPickerView, accessibilityLabelForComponent inLabel: Int) -> String?

    Parameters

    inPickerView

    The picker instance

    inLabel

    The 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

    inPickerView

    The picker instance

    inHint

    The 0-based component index for the Hint (ignored).

    Return Value

    An accessibility string for the component.

AVAudioPlayerDelegate Conformance

  • Called when the sound is done playing.

    Declaration

    Swift

    @MainActor
    func audioPlayerDidFinishPlaying(_ inAudioPlayer: AVAudioPlayer, successfully inSuccess: Bool)

    Parameters

    inAudioPlayer

    The player (ignored)

    inSuccess

    True, if the play was successful (also ignored).