use objc2::{
extern_class, extern_methods, msg_send_id, mutability, rc::Id, ClassType, Encode, Encoding,
};
use objc2_foundation::{CGFloat, NSInteger, NSObject};
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIFeedbackGenerator;
unsafe impl ClassType for UIFeedbackGenerator {
type Super = NSObject;
type Mutability = mutability::InteriorMutable;
}
);
extern_methods!(
unsafe impl UIFeedbackGenerator {
#[method(prepare)]
pub fn prepare(&self);
}
);
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIImpactFeedbackGenerator;
unsafe impl ClassType for UIImpactFeedbackGenerator {
type Super = UIFeedbackGenerator;
type Mutability = mutability::InteriorMutable;
}
);
#[derive(Debug, PartialEq, Eq)]
#[allow(dead_code)]
#[repr(isize)]
pub enum UIImpactFeedbackStyle {
UIImpactFeedbackStyleLight,
UIImpactFeedbackStyleMedium,
UIImpactFeedbackStyleHeavy,
UIImpactFeedbackStyleSoft,
UIImpactFeedbackStyleRigid,
}
unsafe impl Encode for UIImpactFeedbackStyle {
const ENCODING: Encoding = NSInteger::ENCODING;
}
extern_methods!(
unsafe impl UIImpactFeedbackGenerator {
#[allow(non_snake_case)]
pub fn initWithStyle(style: UIImpactFeedbackStyle) -> Option<Id<Self>> {
let this = UIImpactFeedbackGenerator::alloc();
unsafe {
msg_send_id![
this,
initWithStyle: style,
]
}
}
#[allow(non_snake_case)]
#[method(impactOccurred)]
pub fn impactOccurred(&self);
#[allow(non_snake_case)]
#[method(impactOccurredWithIntensity:)]
pub fn impactOccurredWithIntensity(&self, intensity: CGFloat);
}
);