use uzor::platform::{PlatformEvent, SystemTheme};
use crate::{HapticStyle, ScreenOrientation};
#[cfg(feature = "ios")]
use objc2::runtime::NSObject;
pub struct IosBackend {
#[cfg(feature = "ios")]
_screen_scale: f64,
#[cfg(not(feature = "ios"))]
_stub: (),
}
impl IosBackend {
pub fn new() -> Result<Self, String> {
#[cfg(feature = "ios")]
{
Err("iOS backend not fully implemented yet".to_string())
}
#[cfg(not(feature = "ios"))]
{
Ok(Self { _stub: () })
}
}
pub fn screen_size(&self) -> (u32, u32) {
#[cfg(feature = "ios")]
{
(1179, 2556)
}
#[cfg(not(feature = "ios"))]
{
(1179, 2556)
}
}
pub fn scale_factor(&self) -> f64 {
#[cfg(feature = "ios")]
{
3.0
}
#[cfg(not(feature = "ios"))]
{
3.0
}
}
pub fn safe_area_insets(&self) -> (f64, f64, f64, f64) {
#[cfg(feature = "ios")]
{
let scale = self.scale_factor();
let top = 59.0 * scale; let bottom = 34.0 * scale; (top, 0.0, bottom, 0.0)
}
#[cfg(not(feature = "ios"))]
{
(177.0, 0.0, 102.0, 0.0) }
}
pub fn orientation(&self) -> ScreenOrientation {
#[cfg(feature = "ios")]
{
ScreenOrientation::Portrait
}
#[cfg(not(feature = "ios"))]
{
ScreenOrientation::Portrait
}
}
pub fn haptic_feedback(&mut self, style: HapticStyle) {
#[cfg(feature = "ios")]
{
let _ = style;
}
#[cfg(not(feature = "ios"))]
{
let _ = style;
}
}
pub fn poll_event(&mut self) -> Option<PlatformEvent> {
#[cfg(feature = "ios")]
{
None
}
#[cfg(not(feature = "ios"))]
{
None
}
}
pub fn set_title(&mut self, _title: &str) {
}
pub fn get_clipboard_text(&self) -> Option<String> {
#[cfg(feature = "ios")]
{
None
}
#[cfg(not(feature = "ios"))]
{
None
}
}
pub fn set_clipboard_text(&mut self, text: &str) -> Result<(), String> {
#[cfg(feature = "ios")]
{
let _ = text;
Err("iOS clipboard not implemented yet".to_string())
}
#[cfg(not(feature = "ios"))]
{
let _ = text;
Err("iOS feature not enabled".to_string())
}
}
pub fn open_url(&self, url: &str) -> Result<(), String> {
#[cfg(feature = "ios")]
{
let _ = url;
Err("iOS URL opening not implemented yet".to_string())
}
#[cfg(not(feature = "ios"))]
{
let _ = url;
Err("iOS feature not enabled".to_string())
}
}
pub fn system_theme(&self) -> Option<SystemTheme> {
#[cfg(feature = "ios")]
{
Some(SystemTheme::Light)
}
#[cfg(not(feature = "ios"))]
{
Some(SystemTheme::Light)
}
}
pub fn set_ime_position(&mut self, _x: f64, _y: f64) {
}
pub fn show_keyboard(&mut self) {
#[cfg(feature = "ios")]
{
}
}
pub fn hide_keyboard(&mut self) {
#[cfg(feature = "ios")]
{
}
}
}
#[cfg(feature = "ios")]
mod objc_helpers {
use super::*;
pub fn get_main_screen() -> Option<*mut NSObject> {
None
}
pub fn get_safe_area_insets() -> (f64, f64, f64, f64) {
(0.0, 0.0, 0.0, 0.0)
}
pub fn trigger_haptic(_style: HapticStyle) {
}
pub fn get_metal_layer() -> Option<*mut NSObject> {
None
}
}