use libc::c_float;
use objc::{msg_send, sel, sel_impl};
use rust_macios_objective_c_runtime_proc_macros::interface_impl;
use crate::{
object,
objective_c_runtime::traits::{FromId, PNSObject},
};
use super::UNNotificationSoundName;
object! {
unsafe pub struct UNNotificationSound;
}
#[interface_impl(NSObject)]
impl UNNotificationSound {
#[property]
pub fn default_sound() -> UNNotificationSound {
unsafe { UNNotificationSound::from_id(msg_send![Self::m_class(), defaultSound]) }
}
#[method]
pub fn sound_named(name: UNNotificationSoundName) -> Self
where
Self: Sized + FromId,
{
unsafe { Self::from_id(msg_send![Self::m_class(), soundNamed: name]) }
}
#[property]
pub fn default_critical_sound() -> UNNotificationSound {
unsafe { UNNotificationSound::from_id(msg_send![Self::m_class(), defaultCriticalSound]) }
}
#[method]
pub fn default_critical_sound_with_audio_volume(volume: c_float) -> Self
where
Self: Sized + FromId,
{
unsafe {
Self::from_id(msg_send![
Self::m_class(),
defaultCriticalSoundWithAudioVolume: volume
])
}
}
#[method]
pub fn critical_sound_named(name: UNNotificationSoundName) -> Self
where
Self: Sized + FromId,
{
unsafe { Self::from_id(msg_send![Self::m_class(), criticalSoundNamed: name]) }
}
#[method]
pub fn critical_sound_named_with_audio_volume(
name: UNNotificationSoundName,
volume: c_float,
) -> Self
where
Self: Sized + FromId,
{
unsafe {
Self::from_id(
msg_send![Self::m_class(), criticalSoundNamed: name withAudioVolume: volume],
)
}
}
#[property]
pub fn default_ringtone_sound() -> UNNotificationSound {
unsafe { UNNotificationSound::from_id(msg_send![Self::m_class(), defaultRingtoneSound]) }
}
#[method]
pub fn ringtone_sound_named(name: UNNotificationSoundName) -> Self
where
Self: Sized + FromId,
{
unsafe { Self::from_id(msg_send![Self::m_class(), ringtoneSoundNamed: name]) }
}
}