Clean up iOS ffi.rs (#3530)
This makes it easier to transition to a future autogenerated version of UIKit.
This commit is contained in:
parent
e41f0eabb1
commit
a4480a0652
9 changed files with 67 additions and 108 deletions
|
|
@ -1,9 +1,8 @@
|
|||
use icrate::Foundation::{MainThreadMarker, NSObject};
|
||||
use icrate::Foundation::{MainThreadMarker, NSInteger, NSObject};
|
||||
use objc2::encode::{Encode, Encoding};
|
||||
use objc2::rc::Id;
|
||||
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
||||
|
||||
use super::super::ffi::UIUserInterfaceIdiom;
|
||||
|
||||
extern_class!(
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub(crate) struct UIDevice;
|
||||
|
|
@ -24,3 +23,19 @@ extern_methods!(
|
|||
pub fn userInterfaceIdiom(&self) -> UIUserInterfaceIdiom;
|
||||
}
|
||||
);
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct UIUserInterfaceIdiom(NSInteger);
|
||||
|
||||
unsafe impl Encode for UIUserInterfaceIdiom {
|
||||
const ENCODING: Encoding = NSInteger::ENCODING;
|
||||
}
|
||||
|
||||
impl UIUserInterfaceIdiom {
|
||||
pub const Unspecified: UIUserInterfaceIdiom = UIUserInterfaceIdiom(-1);
|
||||
pub const Phone: UIUserInterfaceIdiom = UIUserInterfaceIdiom(0);
|
||||
pub const Pad: UIUserInterfaceIdiom = UIUserInterfaceIdiom(1);
|
||||
pub const TV: UIUserInterfaceIdiom = UIUserInterfaceIdiom(2);
|
||||
pub const CarPlay: UIUserInterfaceIdiom = UIUserInterfaceIdiom(3);
|
||||
}
|
||||
|
|
|
|||
14
src/platform_impl/ios/uikit/geometry.rs
Normal file
14
src/platform_impl/ios/uikit/geometry.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
use icrate::Foundation::NSUInteger;
|
||||
use objc2::encode::{Encode, Encoding};
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct UIRectEdge(pub NSUInteger);
|
||||
|
||||
impl UIRectEdge {
|
||||
pub const NONE: Self = Self(0);
|
||||
}
|
||||
|
||||
unsafe impl Encode for UIRectEdge {
|
||||
const ENCODING: Encoding = NSUInteger::ENCODING;
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ mod application;
|
|||
mod coordinate_space;
|
||||
mod device;
|
||||
mod event;
|
||||
mod geometry;
|
||||
mod gesture_recognizer;
|
||||
mod responder;
|
||||
mod screen;
|
||||
|
|
@ -22,8 +23,9 @@ mod window;
|
|||
|
||||
pub(crate) use self::application::UIApplication;
|
||||
pub(crate) use self::coordinate_space::UICoordinateSpace;
|
||||
pub(crate) use self::device::UIDevice;
|
||||
pub(crate) use self::device::{UIDevice, UIUserInterfaceIdiom};
|
||||
pub(crate) use self::event::UIEvent;
|
||||
pub(crate) use self::geometry::UIRectEdge;
|
||||
pub(crate) use self::gesture_recognizer::{
|
||||
UIGestureRecognizer, UIGestureRecognizerState, UIPinchGestureRecognizer,
|
||||
UIRotationGestureRecognizer, UITapGestureRecognizer,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use crate::platform::ios::StatusBarStyle;
|
||||
use icrate::Foundation::NSInteger;
|
||||
use objc2::encode::{Encode, Encoding};
|
||||
|
||||
|
|
@ -12,16 +11,6 @@ pub enum UIStatusBarStyle {
|
|||
DarkContent = 3,
|
||||
}
|
||||
|
||||
impl From<StatusBarStyle> for UIStatusBarStyle {
|
||||
fn from(value: StatusBarStyle) -> Self {
|
||||
match value {
|
||||
StatusBarStyle::Default => Self::Default,
|
||||
StatusBarStyle::LightContent => Self::LightContent,
|
||||
StatusBarStyle::DarkContent => Self::DarkContent,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Encode for UIStatusBarStyle {
|
||||
const ENCODING: Encoding = NSInteger::ENCODING;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue