1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#![allow(unused_imports)]

pub mod website_desktop;
pub mod website_mobile;

use pax_lang::api::*;
use pax_lang::*;
use pax_std::components::Stacker;
use pax_std::primitives::{Frame, Group, Image, Rectangle, Text};
use pax_std::types::{Color, Fill, LinearGradient, StackerDirection};

use crate::website_desktop::WebsiteDesktop;
use crate::website_mobile::WebsiteMobile;

#[derive(Pax)]
#[main]
#[inlined(
    <Frame width=100% height=100% @did_mount=handle_did_mount @will_render=handle_will_render >
     if container_width > 800.0  {
        <WebsiteDesktop />
    }
    if container_width == 800.0 || container_width < 800.0 {
        <WebsiteMobile />
    }
    </Frame>
 )]
pub struct Example {
    pub container_width: Property<f64>,
}

impl Example {
    pub fn handle_did_mount(&mut self, ctx: RuntimeContext) {
        self.container_width.set(ctx.bounds_parent.0);
    }

    pub fn handle_will_render(&mut self, ctx: RuntimeContext) {
        self.container_width.set(ctx.bounds_parent.0);
    }
}