RVS_SetAlarmAmbiaMara_PopoverViewController

class RVS_SetAlarmAmbiaMara_PopoverViewController : UIViewController
extension RVS_SetAlarmAmbiaMara_PopoverViewController: UIPickerViewDataSource
extension RVS_SetAlarmAmbiaMara_PopoverViewController: UIPickerViewDelegate
extension RVS_SetAlarmAmbiaMara_PopoverViewController: UIPickerViewAccessibilityDelegate
extension RVS_SetAlarmAmbiaMara_PopoverViewController: AVAudioPlayerDelegate

This is the view controller for the alarm setup popover.

  • The size of the picker font

    Declaration

    Swift

    private static let _pickerFont: UIFont
  • The padding on either side of the labels we use as picker rows.

    Declaration

    Swift

    private static let _pickerPaddingInDisplayUnits: CGFloat
  • The SFSymbols names for the play sound button.

    Declaration

    Swift

    private static let _playSoundImageNames: [String]
  • The storyboard ID for this controller.

    Declaration

    Swift

    static let storyboardID: String
  • This is the audio player (for sampling sounds).

    Declaration

    Swift

    private var _audioPlayer: AVAudioPlayer!
  • This will provide haptic/audio feedback for subtle events.

    Declaration

    Swift

    private var _selectionFeedbackGenerator: UISelectionFeedbackGenerator?
  • This aggregates our available sounds. The sounds are files, stored in the resources, so this simply gets them, and stores them as path URIs.

    Declaration

    Swift

    private var _soundSelection: [String]
  • If true, then the currently selected sound is playing. This is set or cleared by the “play sound” button.

    Declaration

    Swift

    private var _isSoundPlaying: Bool { get set }
  • This references the presenting view controller.

    Declaration

    Swift

    weak var myController: RVS_SetTimerAmbiaMara_ViewController?
  • The segmented switch that controls the alarm mode.

    Declaration

    Swift

    @IBOutlet
    weak var alarmModeSegmentedSwitch: UISegmentedControl?
  • The stach view that holds the vibrate switch.

    Declaration

    Swift

    @IBOutlet
    weak var vibrateSwitchStackView: UIView?
  • The vibrate switch (only available on iPhones).

    Declaration

    Swift

    @IBOutlet
    weak var vibrateSwitch: UISwitch?
  • The label for the switch is actually a button, that toggles the switch.

    Declaration

    Swift

    @IBOutlet
    weak var vibrateSwitchLabelButton: UIButton?
  • The picker view for the sounds. Only shown if the seg switch is set to sound.

    Declaration

    Swift

    @IBOutlet
    weak var soundsPickerView: UIPickerView?
  • The stack view that holds the sound selection picker, and the play sound button.

    Declaration

    Swift

    @IBOutlet
    weak var soundSelectionStackView: UIView?
  • This is the “play sound” button.

    Declaration

    Swift

    @IBOutlet
    weak var soundPlayButton: UIButton?

Class Variables

  • The popover height. We adjust for the missing switch, if vibrate is not available.

    Declaration

    Swift

    class var settingsPopoverHeightInDisplayUnits: CGFloat { get }

Base Class Overrides

  • Called when the hierarchy has loaded. We set up the initial states, and all the localization and accessibility.

    Declaration

    Swift

    override func viewDidLoad()
  • Called just before the screen disappears. We use this to kill the sound (if playing).

    Declaration

    Swift

    override func viewWillDisappear(_ inAnimated: Bool)

    Parameters

    inIsAnimated

    True, if the disappearance is animated.

Instance Methods

  • 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

    func setUpForSoundPlayMode()
  • This plays any sound, using a given URL.

    Declaration

    Swift

    func playThisSound(_ inSoundURL: URL)

    Parameters

    inSoundURL

    This is the URI to the sound resource.

Callbacks

  • Called when the alarm mode is changed.

    Declaration

    Swift

    @IBAction
    func alarmModeSegmentedSwitchHit(_ inSegmentedSwitch: UISegmentedControl)

    Parameters

    inSegmentedSwitch

    The segmented switch that changed.

  • Called when the vibrate switch, or its label, changes.

    Declaration

    Swift

    @IBAction
    func vibrateSwitchChanged(_ inSender: UIControl)

    Parameters

    inSender

    The switch that changed, or the label button.

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

    Declaration

    Swift

    @IBAction
    func soundPlayButtonHit(_: UIButton)

UIPickerViewDataSource Conformance

  • Declaration

    Swift

    func numberOfComponents(in: UIPickerView) -> Int

    Parameters

    in

    The picker view (ignored).

  • Declaration

    Swift

    func pickerView(_: UIPickerView, numberOfRowsInComponent inComponent: Int) -> Int

    Parameters

    numberOfRowsInComponent

    The 0-based index of the component we are querying.

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

    func pickerView(_ inPickerView: UIPickerView, didSelectRow inRow: Int, inComponent: Int)

    Parameters

    inPickerView

    The picker instance.

    didSelectRow

    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

    func pickerView(_ inPickerView: UIPickerView, viewForRow inRow: Int, forComponent inComponent: Int, reusing inView: UIView?) -> UIView

    Parameters

    inPickerView

    The picker instance.

    viewForRow

    The 0-based row index to be displayed.

    forComponent

    The 0-based component index for the row.

    reusing

    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.

UIPickerViewAccessibilityDelegate Conformance

  • This returns the accessibility hint for the picker component.

    Declaration

    Swift

    func pickerView(_: UIPickerView, accessibilityHintForComponent: Int) -> String?

    Parameters

    accessibilityHintForComponent

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

    Return Value

    An accessibility string for the component.

AVAudioPlayerDelegate Conformance

  • Called when the sound is done playing.

    Declaration

    Swift

    func audioPlayerDidFinishPlaying(_: AVAudioPlayer, successfully: Bool)

    Parameters

    successfully

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