cleanup
This commit is contained in:
parent
36740dc2db
commit
21b28f7f11
7 changed files with 80 additions and 366 deletions
16
src/app.rs
16
src/app.rs
|
@ -9,7 +9,6 @@ live_design!{
|
|||
|
||||
import crate::welcome::welcome_screen::WelcomeScreen
|
||||
import crate::counter::counter_screen::CounterScreen
|
||||
import crate::counter::counterscrn::CounterScrn
|
||||
|
||||
import crate::shared::clickable_view::ClickableView
|
||||
import crate::shared::stack_navigation::*;
|
||||
|
@ -46,14 +45,6 @@ live_design!{
|
|||
dpi_override: 2
|
||||
},
|
||||
pass: {clear_color: #2A}
|
||||
// show_bg: true
|
||||
// width: Fill,
|
||||
// height: Fill
|
||||
// draw_bg: {
|
||||
// fn pixel(self) -> vec4 {
|
||||
// return mix(#7, #3, self.pos.y);
|
||||
// }
|
||||
// }
|
||||
body = {
|
||||
navigation = <StackNavigation> {
|
||||
root_view = {
|
||||
|
@ -66,11 +57,9 @@ live_design!{
|
|||
padding: 0.0
|
||||
|
||||
welcome_frame = <WelcomeScreen> { visible: true }
|
||||
// welcome_frame = <CounterScreen> { visible: true }
|
||||
}
|
||||
}
|
||||
my_counter_stack_view = <StackNavigationView> {
|
||||
position: vec2(0, 0),
|
||||
header = {
|
||||
content = {
|
||||
title_container = {
|
||||
|
@ -80,8 +69,7 @@ live_design!{
|
|||
}
|
||||
}
|
||||
}
|
||||
// <CounterScreen> {}
|
||||
<CounterScrn> {}
|
||||
<CounterScreen> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +94,6 @@ impl LiveHook for App {
|
|||
crate::welcome::welcome_screen::live_design(cx);
|
||||
// counter
|
||||
crate::counter::counter_screen::live_design(cx);
|
||||
crate::counter::counterscrn::live_design(cx);
|
||||
|
||||
// shared
|
||||
crate::shared::styles::live_design(cx);
|
||||
|
@ -114,7 +101,6 @@ impl LiveHook for App {
|
|||
crate::shared::header::live_design(cx);
|
||||
crate::shared::search_bar::live_design(cx);
|
||||
crate::shared::custom_button::live_design(cx);
|
||||
crate::shared::cbutton::live_design(cx);
|
||||
crate::shared::popup_menu::live_design(cx);
|
||||
crate::shared::dropdown_menu::live_design(cx);
|
||||
crate::shared::stack_navigation::live_design(cx);
|
||||
|
|
|
@ -8,92 +8,105 @@ live_design! {
|
|||
import makepad_widgets::base::*;
|
||||
import makepad_widgets::theme_desktop_dark::*;
|
||||
|
||||
import crate::shared::helpers::FillerX;
|
||||
import crate::shared::helpers::*;
|
||||
import crate::shared::helpers::Divider;
|
||||
import crate::shared::styles::*;
|
||||
import crate::shared::clickable_view::ClickableView
|
||||
// import crate::shared::header::HeaderDropDownMenu;
|
||||
|
||||
import crate::shared::search_bar::SearchBar;
|
||||
import crate::shared::custom_button::CustomButton;
|
||||
import crate::shared::cbutton::CButton;
|
||||
|
||||
IMG_DEFAULT_AVATAR = dep("crate://self/resources/img/default_avatar.png")
|
||||
IMG_FAVORITES = dep("crate://self/resources/img/favorites.png")
|
||||
IMG_MY_POSTS = dep("crate://self/resources/img/my-posts.png")
|
||||
IMG_STICKER_GALLERY = dep("crate://self/resources/img/sticker-gallery.png")
|
||||
IMG_SETTINGS = dep("crate://self/resources/img/settings.png")
|
||||
IMG_QR = dep("crate://self/resources/img/qr_icon.png")
|
||||
|
||||
Counter = {{Counter}} {
|
||||
view: {
|
||||
width: Fill, height: Fit
|
||||
flow: Down, spacing: 10.
|
||||
|
||||
show_bg: true,
|
||||
spacing: 10.
|
||||
draw_bg: {
|
||||
color: #ddd
|
||||
color: #000
|
||||
}
|
||||
// <CounterHeader> {}
|
||||
|
||||
body = <View>{
|
||||
|
||||
flow: Down,
|
||||
spacing: 20,
|
||||
CounterInfo = <View> {
|
||||
width: Fill, height: Fill
|
||||
flow: Right,
|
||||
spacing: 10.,
|
||||
align: {
|
||||
x: 0.5,
|
||||
y: 0.5
|
||||
},
|
||||
|
||||
avatar = <Image> {
|
||||
source: (LOGO_MAKEPAD),
|
||||
width: 300., height: 80.
|
||||
show_bg: true
|
||||
draw_bg: {
|
||||
color: #fff
|
||||
}
|
||||
button1 = <CButton> {
|
||||
button = {
|
||||
width: Fit, height: Fit, margin: 0
|
||||
text: "Hello world"
|
||||
// draw_bg: {
|
||||
// border_radius: 0.
|
||||
// }
|
||||
}
|
||||
}
|
||||
// button1 = <Button> {
|
||||
// text: "Hello world"
|
||||
// }
|
||||
// input1 = <TextInput> {
|
||||
// width: 100, height: 30
|
||||
// text: "Click to count"
|
||||
// }
|
||||
input1 = <SearchBar> {
|
||||
<View> {
|
||||
width: Fit
|
||||
height: Fill
|
||||
show_bg: false
|
||||
input = {
|
||||
width: Fill, height: Fit, margin: 0
|
||||
empty_message: "Click to count"
|
||||
align: {x: 0.5, y: 0.5}
|
||||
container = <RoundedView> {
|
||||
width: 360
|
||||
height: 400
|
||||
align: {x: 0.5, y: 0.5}
|
||||
spacing: 2.0
|
||||
draw_bg: {
|
||||
color: #fff
|
||||
border_width: 0.5,
|
||||
border_color: #b4b4b4,
|
||||
color: #ddd,
|
||||
radius: (CARD_CORNER_RADIUS)
|
||||
}
|
||||
<View> {
|
||||
width: Fit, height: Fill
|
||||
flow: Down,
|
||||
align: {x: 0.5, y: 0.5},
|
||||
padding: {top: 5., left: 10., right: 10.}, spacing: 20.
|
||||
|
||||
avatar = <Image> {
|
||||
source: (LOGO_MAKEPAD),
|
||||
width: 300., height: 80.
|
||||
}
|
||||
button1 = <CustomButton> {
|
||||
button = {
|
||||
text: "Hello world"
|
||||
}
|
||||
}
|
||||
message_input = <SearchBar> {
|
||||
show_bg: false
|
||||
input = {
|
||||
width: Fill, height: Fit, margin: 0
|
||||
empty_message: "Click to count"
|
||||
draw_bg: {
|
||||
color: #fff
|
||||
border_width: 0.5,
|
||||
border_color: #b4b4b4,
|
||||
}
|
||||
}
|
||||
}
|
||||
label1 = <Label> {
|
||||
draw_text: {
|
||||
color: #000
|
||||
},
|
||||
text: "Counter: 0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
label1 = <Label> {
|
||||
draw_text: {
|
||||
color: #f
|
||||
},
|
||||
text: "Counter: 0"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CounterScreen = <View> {
|
||||
width: Fill, height: Fill
|
||||
|
||||
<Counter> {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[derive(Live)]
|
||||
pub struct Counter {
|
||||
#[live] view:View,
|
||||
#[live]
|
||||
view:View,
|
||||
#[rust] counter: usize,
|
||||
|
||||
}
|
||||
|
||||
impl LiveHook for Counter {
|
||||
|
@ -103,17 +116,17 @@ impl LiveHook for Counter {
|
|||
}
|
||||
|
||||
impl Widget for Counter {
|
||||
// fn handle_widget_event_with(
|
||||
// &mut self,
|
||||
// cx: &mut Cx,
|
||||
// event: &Event,
|
||||
// dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
||||
// ) {
|
||||
// let uid = self.widget_uid();
|
||||
// self.handle_event_with(cx, event, &mut |cx, action: StackViewAction| {
|
||||
// dispatch_action(cx, WidgetActionItem::new(action.into(), uid));
|
||||
// });
|
||||
// }
|
||||
fn handle_widget_event_with(
|
||||
&mut self,
|
||||
cx: &mut Cx,
|
||||
event: &Event,
|
||||
dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
||||
) {
|
||||
let uid = self.widget_uid();
|
||||
self.handle_event_with(cx, event, &mut |cx, action: StackViewAction| {
|
||||
dispatch_action(cx, WidgetActionItem::new(action.into(), uid));
|
||||
});
|
||||
}
|
||||
|
||||
fn redraw(&mut self, cx: &mut Cx) {
|
||||
self.view.redraw(cx);
|
||||
|
@ -133,31 +146,11 @@ impl Counter {
|
|||
&mut self,
|
||||
cx: &mut Cx,
|
||||
event: &Event,
|
||||
// dispatch_action: &mut dyn FnMut(&mut Cx, StackViewAction),
|
||||
_dispatch_action: &mut dyn FnMut(&mut Cx, StackViewAction),
|
||||
) {
|
||||
|
||||
let actions = self.view.handle_widget_event(cx, event);
|
||||
|
||||
// if self
|
||||
// .view
|
||||
// .clickable_view(id!(my_profile_frame))
|
||||
// .clicked(&actions)
|
||||
// {
|
||||
// dispatch_action(cx, StackViewAction::ShowCounterScreen);
|
||||
// }
|
||||
|
||||
// if self
|
||||
// .view
|
||||
// .clickable_view(id!(button1.button))
|
||||
// .clicked(&actions)
|
||||
// {
|
||||
// log!("BUTTON CLICKED {}", self.counter);
|
||||
// self.counter += 1;
|
||||
// let label = self.view.clickable_view(id!(label1));
|
||||
// label.set_text_and_redraw(cx,&format!("Counter: {}", self.counter));
|
||||
// }
|
||||
|
||||
if self.view.button(id!(button1.button)).clicked(&actions)
|
||||
if self.view.button(id!(button1)).clicked(&actions)
|
||||
{
|
||||
log!("BUTTON CLICKED {}", self.counter);
|
||||
self.counter += 1;
|
||||
|
@ -165,8 +158,4 @@ impl Counter {
|
|||
label.set_text_and_redraw(cx,&format!("Counter: {}", self.counter));
|
||||
}
|
||||
}
|
||||
|
||||
async fn _do_network_request(_cx:CxRef, _ui:WidgetRef, _url:&str)->String{
|
||||
"".to_string()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,201 +0,0 @@
|
|||
use crate::shared::clickable_view::*;
|
||||
use crate::shared::stack_view_action::StackViewAction;
|
||||
use makepad_widgets::widget::WidgetCache;
|
||||
use makepad_widgets::*;
|
||||
|
||||
live_design! {
|
||||
import makepad_draw::shader::std::*;
|
||||
import makepad_widgets::base::*;
|
||||
import makepad_widgets::theme_desktop_dark::*;
|
||||
|
||||
import crate::shared::helpers::*;
|
||||
import crate::shared::helpers::Divider;
|
||||
import crate::shared::styles::*;
|
||||
import crate::shared::clickable_view::ClickableView
|
||||
import crate::shared::search_bar::SearchBar;
|
||||
import crate::shared::custom_button::CustomButton;
|
||||
|
||||
IMG_DEFAULT_AVATAR = dep("crate://self/resources/img/default_avatar.png")
|
||||
IMG_FAVORITES = dep("crate://self/resources/img/favorites.png")
|
||||
IMG_MY_POSTS = dep("crate://self/resources/img/my-posts.png")
|
||||
IMG_STICKER_GALLERY = dep("crate://self/resources/img/sticker-gallery.png")
|
||||
IMG_SETTINGS = dep("crate://self/resources/img/settings.png")
|
||||
IMG_QR = dep("crate://self/resources/img/qr_icon.png")
|
||||
|
||||
Counter = {{Counter}} {
|
||||
view: {
|
||||
width: Fill, height: Fit
|
||||
spacing: 10.
|
||||
draw_bg: {
|
||||
color: #000
|
||||
}
|
||||
CounterInfo = <View> {
|
||||
width: Fill, height: Fill
|
||||
flow: Right,
|
||||
spacing: 10.,
|
||||
// padding: {top: 100., bottom: 100., right: 10., left: 10.}
|
||||
align: {
|
||||
x: 0.5,
|
||||
y: 0.5
|
||||
},
|
||||
show_bg: true
|
||||
draw_bg: {
|
||||
color: #fff
|
||||
}
|
||||
<View> {
|
||||
width: Fit
|
||||
height: Fill
|
||||
show_bg: false
|
||||
// align:{ x: 0.5 }
|
||||
align: {x: 0.5, y: 0.5}
|
||||
container = <RoundedView> {
|
||||
width: 360
|
||||
height: 400
|
||||
// flow: Down
|
||||
align: {x: 0.5, y: 0.5}
|
||||
// margin: {left: 200.0, right: 200.0, top: 100.0, bottom: 100.0}
|
||||
spacing: 2.0
|
||||
draw_bg: {
|
||||
color: #ddd,
|
||||
// border_width: 1.0,
|
||||
// border_color: #000,
|
||||
radius: (CARD_CORNER_RADIUS)
|
||||
}
|
||||
<View> {
|
||||
width: Fit, height: Fill
|
||||
flow: Down,
|
||||
align: {x: 0.5, y: 0.5},
|
||||
padding: {top: 5., left: 10., right: 10.}, spacing: 20.
|
||||
// username = <Label> {
|
||||
// // padding: {top: 50., left: 140.}
|
||||
// draw_text:{
|
||||
// color: #000,
|
||||
// text_style: <TEXT_SUB>{font_size: 20.},
|
||||
// }
|
||||
// text:"Welcome To Simple Nav"
|
||||
// }
|
||||
avatar = <Image> {
|
||||
source: (LOGO_MAKEPAD),
|
||||
width: 300., height: 80.
|
||||
}
|
||||
button1 = <CustomButton> {
|
||||
button = {
|
||||
// width: Fill, height: Fit, margin: 0
|
||||
text: "Hello world"
|
||||
}
|
||||
}
|
||||
// button1 = <Button> {
|
||||
// text: "Hello world"
|
||||
// }
|
||||
// input1 = <TextInput> {
|
||||
// width: 100, height: 30
|
||||
// text: "Click to count"
|
||||
// }
|
||||
message_input = <SearchBar> {
|
||||
show_bg: false
|
||||
input = {
|
||||
width: Fill, height: Fit, margin: 0
|
||||
empty_message: "Click to count"
|
||||
draw_bg: {
|
||||
color: #fff
|
||||
border_width: 0.5,
|
||||
border_color: #b4b4b4,
|
||||
}
|
||||
}
|
||||
}
|
||||
label1 = <Label> {
|
||||
draw_text: {
|
||||
color: #000
|
||||
},
|
||||
text: "Counter: 0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CounterScrn = <View> {
|
||||
width: Fill, height: Fill
|
||||
<Counter> {}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Live)]
|
||||
pub struct Counter {
|
||||
#[live]
|
||||
view:View,
|
||||
#[rust] counter: usize,
|
||||
}
|
||||
|
||||
impl LiveHook for Counter {
|
||||
fn before_live_design(cx: &mut Cx) {
|
||||
register_widget!(cx, Counter);
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for Counter {
|
||||
fn handle_widget_event_with(
|
||||
&mut self,
|
||||
cx: &mut Cx,
|
||||
event: &Event,
|
||||
dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
||||
) {
|
||||
let uid = self.widget_uid();
|
||||
self.handle_event_with(cx, event, &mut |cx, action: StackViewAction| {
|
||||
dispatch_action(cx, WidgetActionItem::new(action.into(), uid));
|
||||
});
|
||||
}
|
||||
|
||||
fn redraw(&mut self, cx: &mut Cx) {
|
||||
self.view.redraw(cx);
|
||||
}
|
||||
|
||||
fn find_widgets(&mut self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet) {
|
||||
self.view.find_widgets(path, cached, results);
|
||||
}
|
||||
|
||||
fn draw_walk_widget(&mut self, cx: &mut Cx2d, walk: Walk) -> WidgetDraw {
|
||||
self.view.draw_walk_widget(cx, walk)
|
||||
}
|
||||
}
|
||||
|
||||
impl Counter {
|
||||
fn handle_event_with(
|
||||
&mut self,
|
||||
cx: &mut Cx,
|
||||
event: &Event,
|
||||
_dispatch_action: &mut dyn FnMut(&mut Cx, StackViewAction),
|
||||
) {
|
||||
let actions = self.view.handle_widget_event(cx, event);
|
||||
|
||||
// if self
|
||||
// .view
|
||||
// .clickable_view(id!(welcome_frame))
|
||||
// .clicked(&actions)
|
||||
// {
|
||||
// dispatch_action(cx, StackViewAction::ShowCounterScreen);
|
||||
// log!("WELCOME BUTTON CLICKED");
|
||||
// }
|
||||
|
||||
// if self
|
||||
// .view
|
||||
// .clickable_view(id!(button1))
|
||||
// .clicked(&actions)
|
||||
// {
|
||||
// log!("BUTTON CLICKED {}", self.counter);
|
||||
// self.counter += 1;
|
||||
// let label = self.view.label(id!(label1));
|
||||
// label.set_text_and_redraw(cx,&format!("Counter: {}", self.counter));
|
||||
// }
|
||||
if self.view.button(id!(button1)).clicked(&actions)
|
||||
{
|
||||
log!("BUTTON CLICKED {}", self.counter);
|
||||
self.counter += 1;
|
||||
let label = self.view.label(id!(label1));
|
||||
label.set_text_and_redraw(cx,&format!("Counter: {}", self.counter));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,2 +1 @@
|
|||
pub mod counter_screen;
|
||||
pub mod counterscrn;
|
||||
pub mod counter_screen;
|
|
@ -1,56 +0,0 @@
|
|||
use makepad_widgets::*;
|
||||
|
||||
live_design! {
|
||||
import makepad_draw::shader::std::*;
|
||||
import makepad_widgets::base::*;
|
||||
import makepad_widgets::theme_desktop_dark::*;
|
||||
|
||||
import crate::shared::styles::*;
|
||||
import crate::shared::clickable_view::ClickableView
|
||||
|
||||
CButton = <ClickableView> {
|
||||
width: Fill, height: Fit
|
||||
// flow: Right
|
||||
show_bg: false
|
||||
draw_bg: {
|
||||
// color: #EDEDED;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
button = <Button> {
|
||||
width: Fill, height: 34.
|
||||
text: "Welcome"
|
||||
draw_text: {
|
||||
text_style: <REGULAR_TEXT>{font_size: 12.},
|
||||
fn get_color(self) -> vec4 {
|
||||
return #000
|
||||
}
|
||||
}
|
||||
draw_bg: {
|
||||
border_radius: 8.
|
||||
fn pixel(self) -> vec4 {
|
||||
let border_color = #b4b4b4;
|
||||
let border_width = 0.5;
|
||||
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
|
||||
let body = mix(mix(#f, #f0, self.hover), #d1, self.pressed);
|
||||
|
||||
sdf.box(
|
||||
1.,
|
||||
1.,
|
||||
self.rect_size.x - 2.0,
|
||||
self.rect_size.y - 2.0,
|
||||
self.border_radius
|
||||
)
|
||||
sdf.fill_keep(body)
|
||||
|
||||
sdf.stroke(
|
||||
border_color,
|
||||
border_width
|
||||
)
|
||||
return sdf.result
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,5 @@ pub mod popup_menu;
|
|||
pub mod header;
|
||||
pub mod search_bar;
|
||||
pub mod custom_button;
|
||||
pub mod cbutton;
|
||||
pub mod helpers;
|
||||
pub mod styles;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use crate::shared::clickable_view::*;
|
||||
use crate::shared::stack_view_action::StackViewAction;
|
||||
use makepad_widgets::widget::WidgetCache;
|
||||
use makepad_widgets::*;
|
||||
|
@ -14,7 +13,6 @@ live_design! {
|
|||
import crate::shared::clickable_view::ClickableView
|
||||
import crate::shared::search_bar::SearchBar;
|
||||
import crate::shared::custom_button::CustomButton;
|
||||
import crate::shared::cbutton::CButton;
|
||||
|
||||
IMG_DEFAULT_AVATAR = dep("crate://self/resources/img/default_avatar.png")
|
||||
IMG_FAVORITES = dep("crate://self/resources/img/favorites.png")
|
||||
|
|
Loading…
Reference in a new issue