Reduce amount of unsafe on iOS (#2579)
* Use objc2::foundation CG types * Add safe abstraction over UIApplication * Add safe abstraction over UIDevice * Add safe abstraction over UIScreen * Add safe abstraction over UIWindow * Add safe abstraction over UIViewController * Add safe abstraction over UIView * Appease clippy
This commit is contained in:
parent
5e77d70245
commit
ee88e38f13
20 changed files with 1048 additions and 962 deletions
|
|
@ -1,7 +1,8 @@
|
|||
use objc2::foundation::NSObject;
|
||||
use objc2::{extern_class, ClassType};
|
||||
use objc2::encode::{Encode, Encoding};
|
||||
use objc2::foundation::{NSObject, NSUInteger};
|
||||
use objc2::{extern_class, extern_methods, ClassType};
|
||||
|
||||
use super::UIResponder;
|
||||
use super::{UIResponder, UIView};
|
||||
|
||||
extern_class!(
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
|
|
@ -12,3 +13,38 @@ extern_class!(
|
|||
type Super = UIResponder;
|
||||
}
|
||||
);
|
||||
|
||||
extern_methods!(
|
||||
unsafe impl UIViewController {
|
||||
#[sel(attemptRotationToDeviceOrientation)]
|
||||
pub fn attemptRotationToDeviceOrientation();
|
||||
|
||||
#[sel(setNeedsStatusBarAppearanceUpdate)]
|
||||
pub fn setNeedsStatusBarAppearanceUpdate(&self);
|
||||
|
||||
#[sel(setNeedsUpdateOfHomeIndicatorAutoHidden)]
|
||||
pub fn setNeedsUpdateOfHomeIndicatorAutoHidden(&self);
|
||||
|
||||
#[sel(setNeedsUpdateOfScreenEdgesDeferringSystemGestures)]
|
||||
pub fn setNeedsUpdateOfScreenEdgesDeferringSystemGestures(&self);
|
||||
|
||||
#[sel(setView:)]
|
||||
pub fn setView(&self, view: Option<&UIView>);
|
||||
}
|
||||
);
|
||||
|
||||
bitflags! {
|
||||
pub struct UIInterfaceOrientationMask: NSUInteger {
|
||||
const Portrait = 1 << 1;
|
||||
const PortraitUpsideDown = 1 << 2;
|
||||
const LandscapeRight = 1 << 3;
|
||||
const LandscapeLeft = 1 << 4;
|
||||
const Landscape = Self::LandscapeLeft.bits() | Self::LandscapeRight.bits();
|
||||
const AllButUpsideDown = Self::Landscape.bits() | Self::Portrait.bits();
|
||||
const All = Self::AllButUpsideDown.bits() | Self::PortraitUpsideDown.bits();
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Encode for UIInterfaceOrientationMask {
|
||||
const ENCODING: Encoding = NSUInteger::ENCODING;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue