#![cfg(target_os = "ios")]
#![cfg(feature = "ios-uikit-ffi")]
use objc2::MainThreadMarker;
use objc2_core_foundation::{CGPoint, CGRect, CGSize};
use objc2_foundation::NSString;
use objc2_ui_kit::{NSObjectUIAccessibility, UIColor, UIViewController, UIWindow};
fn make_rect(x: i32, y: i32, width: u32, height: u32) -> CGRect {
CGRect::new(
CGPoint::new(x as f64, y as f64),
CGSize::new(width.max(1) as f64, height.max(1) as f64),
)
}
pub(crate) fn create_ui_window(
mtm: MainThreadMarker,
title: &str,
_x: i32,
_y: i32,
width: u32,
height: u32,
) -> objc2::rc::Retained<UIWindow> {
let frame = make_rect(0, 0, width, height);
#[allow(deprecated)]
let window = UIWindow::initWithFrame(mtm.alloc(), frame);
let bg = UIColor::whiteColor();
window.setBackgroundColor(Some(&bg));
let vc = UIViewController::initWithNibName_bundle(mtm.alloc(), None, None);
window.setRootViewController(Some(&vc));
window.makeKeyAndVisible();
window.setAccessibilityLabel(Some(&NSString::from_str(title)), mtm);
window
}