Skip to main content

polyhorn_ios_sys/polykit/
status_bar.rs

1use objc::runtime::*;
2use objc::*;
3
4use super::PLYWindow;
5use crate::uikit::UIStatusBarStyle;
6use crate::Raw;
7
8/// Host overlay view that shows time, network, etc. in a bar at the top of the
9/// screen.
10pub struct PLYStatusBar {
11    object: *mut Object,
12}
13
14impl PLYStatusBar {
15    /// Returns a reference to the given window's status bar.
16    pub fn new(window: &PLYWindow) -> PLYStatusBar {
17        unsafe {
18            let mut object: *mut Object = msg_send![class!(PLYStatusBar), alloc];
19            object = msg_send![object, initWithWindow: window.as_raw()];
20            PLYStatusBar { object }
21        }
22    }
23
24    /// Sets the style of the status bar.
25    pub fn set_style(&mut self, style: UIStatusBarStyle) {
26        unsafe {
27            let _: () = msg_send![self.object, setStyle: style];
28        }
29    }
30}
31
32impl Raw for PLYStatusBar {
33    unsafe fn from_raw(object: *mut Object) -> Self {
34        PLYStatusBar { object }
35    }
36
37    unsafe fn as_raw(&self) -> *mut Object {
38        self.object
39    }
40}
41
42impl Drop for PLYStatusBar {
43    fn drop(&mut self) {
44        unsafe { objc_release(self.object) }
45    }
46}