notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

ui.rs (857B)


      1 use crate::NotedeckTextStyle;
      2 
      3 pub const NARROW_SCREEN_WIDTH: f32 = 550.0;
      4 
      5 pub fn richtext_small<S>(text: S) -> egui::RichText
      6 where
      7     S: Into<String>,
      8 {
      9     egui::RichText::new(text).text_style(NotedeckTextStyle::Small.text_style())
     10 }
     11 
     12 /// Determine if the screen is narrow. This is useful for detecting mobile
     13 /// contexts, but with the nuance that we may also have a wide android tablet.
     14 pub fn is_narrow(ctx: &egui::Context) -> bool {
     15     let screen_size = ctx.input(|c| c.screen_rect().size());
     16     screen_size.x < NARROW_SCREEN_WIDTH
     17 }
     18 
     19 pub fn is_oled() -> bool {
     20     is_compiled_as_mobile()
     21 }
     22 
     23 #[inline]
     24 #[allow(unreachable_code)]
     25 pub fn is_compiled_as_mobile() -> bool {
     26     #[cfg(any(target_os = "android", target_os = "ios"))]
     27     {
     28         true
     29     }
     30 
     31     #[cfg(not(any(target_os = "android", target_os = "ios")))]
     32     {
     33         false
     34     }
     35 }