nimanyatta_v001/nimanyatta_v001/src/app.rs

299 lines
12 KiB
Rust

use makepad_widgets::*;
live_design! {
import makepad_draw::shader::std::*;
import makepad_widgets::base::*;
import makepad_widgets::theme_desktop_dark::*;
import crate::home::home_screen::HomeScreen;
import crate::default_choice::default_choice_screen::DefaultChoiceScreen;
import crate::two::two_screen::TwoScreen;
import crate::three::three_screen::ThreeScreen;
import crate::four::four_screen::FourScreen;
import crate::five::five_screen::FiveScreen;
import crate::shared::styles::*;
REGULAR_TEXT = {
font_size: (12),
font: {path: dep("crate://makepad-widgets/resources/GoNotoKurrent-Regular.ttf")}
}
ICON_CHAT = dep("crate://self/resources/icons/chat.svg")
PHONE_CHAT = dep("crate://self/resources/icons/chat.svg")
AppTab = <RadioButton> {
width: Fit,
height: Fill,
flow: Right,
align: {x: 0.0, y: 0.0}
margin: <SPACING_0> {}
padding: <SPACING_0> {}
// color: #000
draw_radio: {
radio_type: Tab,
color_active: #fff,
color_inactive: #fff,
}
draw_text: {
color_selected: #000, //#0b0,
color_unselected: #000,
color_unselected_hover: #111,
text_style: <H3_TEXT_REGULAR> {}
}
}
App = {{App}} {
ui: <Window> {
caption_bar = { margin: {left: -100}, visible: true, caption_label = {label = {text: "NiManyatta"}} },
body = {
show_bg: true
flow: Down,
spacing: 20,
align: {
x: 0.5,
y: 1.0
},
width: Fill,
height: Fill
draw_bg: {
fn pixel(self) -> vec4 {
return mix(#3, #1, self.pos.y);
}
}
navigation = <StackNavigation> {
root_view = {
width: Fill,
height: Fill,
padding: 0, align: {x: 1, y: 0.0}, spacing: 0., flow: Down
mobile_menu = <View> {
width: Fill,
height: 80,
// flow: Down,
show_bg: true
spacing: 0.0, padding: 0
draw_bg: {
instance radius: 0.0,
instance border_width: 0.0,
instance border_color: #000,
color: #fff
}
mobile_modes = <View> {
home_tab = <AppTab> {
flow: Right,
align: {x: 0.0, y: 0.5}
animator: {selected = {default: on}}
label: ""
draw_icon: {
svg_file: (ICON_CHAT),
fn get_color(self) -> vec4 {
return mix(
#000,
#016def,//#0b0,
self.selected
)
}
}
width: Fill,
icon_walk: {width: 20, height: 20}
flow: Right, spacing: 5.0, align: {x: 0.2, y: 0.5}
}
two_tab = <AppTab> {
flow: Right,
align: {x: 0.0, y: 0.5}
animator: {selected = {default: on}}
label: "2"
draw_icon: {
svg_file: (ICON_CHAT),
fn get_color(self) -> vec4 {
return mix(
#000,
#016def,//#0b0,
self.selected
)
}
}
width: Fill,
icon_walk: {width: 20, height: 20}
flow: Down, spacing: 5.0, align: {x: 0.5, y: 0.5}
}
three_tab = <AppTab> {
flow: Right,
align: {x: 0.0, y: 0.5}
animator: {selected = {default: on}}
label: "3"
draw_icon: {
svg_file: (ICON_CHAT),
fn get_color(self) -> vec4 {
return mix(
#000,
#016def,//#0b0,
self.selected
)
}
}
width: Fill,
icon_walk: {width: 20, height: 20}
flow: Down, spacing: 5.0, align: {x: 0.5, y: 0.5}
}
four_tab = <AppTab> {
flow: Right,
align: {x: 0.0, y: 0.5}
animator: {selected = {default: on}}
label: "4"
draw_icon: {
svg_file: (ICON_CHAT),
fn get_color(self) -> vec4 {
return mix(
#000,
#016def,//#0b0,
self.selected
)
}
}
width: Fill,
icon_walk: {width: 20, height: 20}
flow: Down, spacing: 5.0, align: {x: 0.5, y: 0.5}
}
five_tab = <AppTab> {
flow: Right,
align: {x: 0.0, y: 0.5}
animator: {selected = {default: on}}
label: ""
draw_icon: {
svg_file: (PHONE_CHAT),
fn get_color(self) -> vec4 {
return mix(
#000,
#016def,//#0b0,
self.selected
)
}
}
width: Fill,
icon_walk: {width: 20, height: 20}
flow: Right, spacing: 5.0, align: {x: 0.8, y: 0.5}
}
}
}
application_pages = <View> {
margin: 0.0,
padding: 0.0
home_frame = <HomeScreen> { visible: true }
kimanyatta_frame = <TwoScreen> {visible: false}
insurance_frame = <ThreeScreen> {visible: false}
matatu_frame = <FourScreen> {visible: false}
contactus_frame = <FiveScreen> {visible: false}
}
}
default_choices_stack_view = <StackNavigationView> { //default_choices_stack_view
header = {
content = {
title_container = {
title = {
text: "Help Me Choose"
}
}
}
}
body = {
<DefaultChoiceScreen> {}
}
}
}
}
}
}
}
app_main!(App);
#[derive(Live)]
pub struct App {
#[live]
ui: WidgetRef,
}
impl LiveRegister for App {
fn live_register(cx: &mut Cx) {
crate::makepad_widgets::live_design(cx);
crate::home::home_screen::live_design(cx);
crate::default_choice::default_choice_screen::live_design(cx);
crate::two::two_screen::live_design(cx);
crate::three::three_screen::live_design(cx);
crate::four::four_screen::live_design(cx);
crate::five::five_screen::live_design(cx);
crate::shared::styles::live_design(cx);
crate::shared::custom_button::live_design(cx);
}
}
impl LiveHook for App {
// fn after_new_from_doc(&mut self, _cx: &mut Cx) {
// // self.init_navigation_destinations();
// }
fn after_new_from_doc(&mut self, _cx: &mut Cx) {
println!("after_new_from_doc(): starting some kind of a loop");
// crate::sliding_sync::start_matrix_tokio().unwrap();
}
}
impl MatchEvent for App {
fn handle_startup(&mut self, _cx: &mut Cx) {
log!("App::handle_startup(): starting nigig sdk loop");
// crate::sliding_sync::start_matrix_tokio().unwrap();
}
fn handle_shutdown(&mut self, _cx: &mut Cx) {
log!("App::handle_shutdown()");
}
fn handle_pause(&mut self, _cx: &mut Cx) {
log!("App::handle_pause()");
}
fn handle_resume(&mut self, _cx: &mut Cx) {
log!("App::handle_resume()");
}
fn handle_app_got_focus(&mut self, _cx: &mut Cx) {
log!("App::handle_app_got_focus()");
}
fn handle_app_lost_focus(&mut self, _cx: &mut Cx) {
log!("App::handle_app_lost_focus()");
}
fn handle_actions(&mut self, cx: &mut Cx, actions: &Actions) {
self.ui
.radio_button_set(ids!(
mobile_modes.home_tab,
mobile_modes.two_tab,
mobile_modes.three_tab,
mobile_modes.four_tab,
mobile_modes.five_tab,
))
.selected_to_visible(
cx,
&self.ui,
&actions,
ids!(
application_pages.home_frame,
application_pages.two_frame,
application_pages.three_frame,
application_pages.four_frame,
application_pages.five_frame,
),
);
let mut navigation = self.ui.stack_navigation(id!(navigation));
navigation.handle_stack_view_actions(cx, &actions);
}
}
impl AppMain for App {
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
self.match_event(cx, event);
self.ui.handle_event(cx, event, &mut Scope::empty());
}
}