good enough

This commit is contained in:
aOK 2023-12-13 03:39:09 +03:00
parent fd005e4d97
commit 36740dc2db
7 changed files with 194 additions and 59 deletions

View file

@ -15,6 +15,7 @@ live_design!{
import crate::shared::stack_navigation::*;
import crate::shared::styles::*;
import crate::shared::helpers::*;
ICON_CHAT = dep("crate://self/resources/icons/chat.svg")
@ -68,19 +69,20 @@ live_design!{
// welcome_frame = <CounterScreen> { visible: true }
}
}
my_counter_stack_view = <StackNavigationView> {
header = {
content = {
title_container = {
title = {
text: "Counter"
my_counter_stack_view = <StackNavigationView> {
position: vec2(0, 0),
header = {
content = {
title_container = {
title = {
text: "Counter"
}
}
}
}
// <CounterScreen> {}
<CounterScrn> {}
}
// <CounterScreen> {}
<CounterScrn> {}
}
}
}
}

View file

@ -64,7 +64,7 @@ live_design! {
<View> {
width: Fit, height: Fill
flow: Down,
align: {x: 0, y: 0.5},
align: {x: 0.5, y: 0.5},
padding: {top: 5., left: 10., right: 10.}, spacing: 20.
// username = <Label> {
// // padding: {top: 50., left: 140.}
@ -104,7 +104,6 @@ live_design! {
}
}
label1 = <Label> {
width: Fill, height: Fit, margin: 0
draw_text: {
color: #000
},
@ -181,22 +180,22 @@ impl Counter {
// log!("WELCOME BUTTON CLICKED");
// }
if self
.view
.clickable_view(id!(button1.button))
.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.button)).clicked(&actions)
// 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));
}
}
}

144
src/shared/card.rs Normal file
View file

@ -0,0 +1,144 @@
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
CatalogItem = <ClickableView> {
width: Fill
height: Fit
show_bg: false
container = <RoundedView> {
width: Fill
height: Fit
flow: Down
align: {x: 0.5, y: 0.0}
spacing: 2.0
draw_bg: {
color: #fff,
radius: 8.
}
image = <Image> {
width: Fill, height: 166
source: (CATALOG_FLIP_FLOPS_IMG)
// Override to have the upper corners rounded
draw_bg: {
instance radius: 8.
fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
sdf.box(
1,
1,
self.rect_size.x - 2.0,
// This calculation is to make sure the bottom part is not rounded
self.rect_size.y + self.radius * 2.0,
max(1.0, self.radius)
)
sdf.fill_keep(self.get_color())
sdf.stroke(#fff, 1);
return sdf.result
}
}
}
info = <View> {
width: Fill
height: Fit
flow: Down
padding: 5.
spacing: 3.
title = <Label> {
width: Fill
height: Fit
text: "男士人字拖 2023"
draw_text: {
color: #000
text_style: <REGULAR_TEXT> {font_size: 12.0},
}
}
subtitle = <Label> {
width: Fill
height: Fit
text: "500+人付费"
draw_text: {
color: #888
text_style: <REGULAR_TEXT> {font_size: 8.0},
}
}
<View> {
width: 160
height: 40
flow: Overlay
<Image> {
width: Fill
height: Fill
source: (BUY_IT_BANNER_IMG)
}
<View> {
width: Fill
height: Fill
padding: 5.
flow: Down
spacing: 2.
<View> {
width: Fit
height: Fit
flow: Right
spacing: 1.
align: {x: 0.0, y: 1.0}
<Label> {
width: Fit
height: Fit
margin: {bottom: 2.}
text: "¥"
draw_text: {
color: #fff
text_style: <REGULAR_TEXT> {font_size: 10.0},
}
}
<Label> {
width: Fit
height: Fit
text: "58"
draw_text: {
color: #fff
text_style: <REGULAR_TEXT> {font_size: 14.0},
}
}
}
<Label> {
width: Fit
height: Fit
text: "USD 8.11"
draw_text: {
color: #fff
text_style: <REGULAR_TEXT> {font_size: 8.0},
}
}
}
}
}
}
}
}

View file

@ -8,7 +8,7 @@ live_design! {
import crate::shared::styles::*;
import crate::shared::clickable_view::ClickableView
CButton = <View> {
CButton = <ClickableView> {
width: Fill, height: Fit
// flow: Right
show_bg: false

View file

@ -8,16 +8,7 @@ live_design! {
import crate::shared::styles::*;
import crate::shared::clickable_view::ClickableView
CustomButton = <ClickableView> {
width: Fill, height: Fit
// flow: Right
show_bg: false
draw_bg: {
// color: #EDEDED;
color: #000;
}
button = <Button> {
CustomButton = <Button> {
width: Fill, height: 34.
text: "Welcome"
draw_text: {
@ -50,6 +41,5 @@ live_design! {
return sdf.result
}
}
}
}
}

View file

@ -32,6 +32,7 @@ live_design! {
visible: false
width: Fill, height: Fill
flow: Down
// flow: Overlay
show_bg: true
draw_bg: {
color: #fff

View file

@ -14,6 +14,7 @@ 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")
@ -24,7 +25,7 @@ live_design! {
Welcome = {{Welcome}} {
view: {
width: Fill, height: Fit
width: Fill, height: Fill
spacing: 10.
draw_bg: {
color: #000
@ -43,15 +44,14 @@ live_design! {
color: #fff
}
<View> {
width: Fit
height: Fill
width: Fill height: Fill
show_bg: false
// align:{ x: 0.5 }
align: {x: 0.5, y: 0.5}
container = <RoundedView> {
width: 360
height: 400
// flow: Down
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
@ -62,25 +62,22 @@ live_design! {
radius: (CARD_CORNER_RADIUS)
}
<View> {
width: Fit, height: Fill
width: Fill, height: Fill
flow: Down,
align: {x: 0, 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"
}
// <FillerY> {}
message_input = <SearchBar> {
show_bg: false
input = {
width: Fill, height: Fit, margin: 0
empty_message: "Enter Your Name"
// text: ""
draw_bg: {
color: #fff
border_width: 0.5,
@ -90,11 +87,9 @@ live_design! {
}
welcome_frame = <CustomButton> {
button = {
// width: Fill, height: Fit, margin: 0
text: "Welcome"
}
}
// <FillerY> {}
}
}
}
@ -156,24 +151,28 @@ impl Welcome {
) {
let actions = self.view.handle_widget_event(cx, event);
if self
.view
.clickable_view(id!(welcome_frame))
.clicked(&actions)
// if self
// .view
// .clickable_view(id!(welcome_frame))
// .clicked(&actions)
// {
// dispatch_action(cx, StackViewAction::ShowCounterScreen);
// // let input11 = self.view.text_input(id!(message_input));
// let user_prompt1 = self.view.text_input(id!(message_input.input)).text();
// log!("WELCOME BUTTON CLICKED: {}", user_prompt1);
// }
if self.view.button(id!(welcome_frame)).clicked(&actions)
{
dispatch_action(cx, StackViewAction::ShowCounterScreen);
// let input11 = self.view.text_input(id!(message_input));
let user_prompt1 = self.view.text_input(id!(message_input.input)).text();
log!("WELCOME BUTTON CLICKED: {}", user_prompt1);
log!("WELCOME BUTTON CLICKED: {}", user_prompt1);
// 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));
// }
}
}