Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup message input bar, fix keyboard view, better send icon #42

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions resources/icon_send.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
142 changes: 73 additions & 69 deletions src/home/room_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ live_design! {
ICO_FAV = dep("crate://self/resources/icon_favorite.svg")
ICO_COMMENT = dep("crate://self/resources/icon_comment.svg")
ICO_REPLY = dep("crate://self/resources/icon_reply.svg")
ICO_SEND = dep("crate://self/resources/icon_send.svg")
ICO_LIKES = dep("crate://self/resources/icon_likes.svg")
ICO_USER = dep("crate://self/resources/icon_user.svg")
ICO_ADD = dep("crate://self/resources/icon_add.svg")
Expand Down Expand Up @@ -131,7 +132,7 @@ live_design! {
}
}
padding: 9.0
text: "1"
text: ""
}

LineH = <RoundedView> {
Expand Down Expand Up @@ -464,89 +465,92 @@ live_design! {
IMG_KEYBOARD_ICON = dep("crate://self/resources/img/keyboard_icon.png")

RoomScreen = {{RoomScreen}} {
width: Fill, height: Fill
flow: Down
width: Fill, height: Fill,
show_bg: true,
draw_bg: {
color: #fff
}

// First, display the timeline of all messages/events.
timeline = <Timeline> {}

// Below that, display a view that holds the message input bar.
<View> {
width: Fill, height: Fit
flow: Right, align: {y: 0.5}, padding: 10.
show_bg: true,
draw_bg: {
color: #fff
}
<KeyboardView> {
width: Fill, height: Fill,
flow: Down,

message_input = <TextInput> {
width: Fill, height: Fit, margin: 0
align: {y: 0.5}
empty_message: "Write a message..."
// First, display the timeline of all messages/events.
timeline = <Timeline> {}

// Below that, display a view that holds the message input bar.
<View> {
width: Fill, height: Fit
flow: Right, align: {y: 1.0}, padding: 10.
show_bg: true,
draw_bg: {
color: #fff
}
draw_text: {
text_style:<REGULAR_TEXT>{},

fn get_color(self) -> vec4 {
return #ccc

message_input = <TextInput> {
width: Fill, height: Fit, margin: 0
align: {y: 0.5}
empty_message: "Write a message..."
draw_bg: {
color: #fff
}
draw_text: {
text_style:<REGULAR_TEXT>{},

fn get_color(self) -> vec4 {
return #ccc
}
}
}

// TODO find a way to override colors
draw_cursor: {
instance focus: 0.0
uniform border_radius: 0.5
fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
sdf.box(
0.,
0.,
self.rect_size.x,
self.rect_size.y,
self.border_radius
)
sdf.fill(mix(#0f0, #0b0, self.focus));
return sdf.result
// TODO find a way to override colors
draw_cursor: {
instance focus: 0.0
uniform border_radius: 0.5
fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
sdf.box(
0.,
0.,
self.rect_size.x,
self.rect_size.y,
self.border_radius
)
sdf.fill(mix(#0f0, #0b0, self.focus));
return sdf.result
}
}
}

// TODO find a way to override colors
draw_select: {
instance hover: 0.0
instance focus: 0.0
uniform border_radius: 2.0
fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
sdf.box(
0.,
0.,
self.rect_size.x,
self.rect_size.y,
self.border_radius
)
sdf.fill(mix(#0e0, #0d0, self.focus)); // Pad color
return sdf.result
// TODO find a way to override colors
draw_select: {
instance hover: 0.0
instance focus: 0.0
uniform border_radius: 2.0
fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
sdf.box(
0.,
0.,
self.rect_size.x,
self.rect_size.y,
self.border_radius
)
sdf.fill(mix(#0e0, #0d0, self.focus)); // Pad color
return sdf.result
}
}
}
}
<Image> {
source: (IMG_SMILEY_FACE_BW),
width: 36., height: 36.
}
<Image> {
source: (IMG_PLUS),
width: 36., height: 36.
}
send_message_button = <IconButton> {
draw_icon: {svg_file: (ICO_REPLY)},
icon_walk: {width: 15.0, height: Fit},
text: "Send",
// <Image> {
// source: (IMG_SMILEY_FACE_BW),
// width: 36., height: 36.
// }
// <Image> {
// source: (IMG_PLUS),
// width: 36., height: 36.
// }
send_message_button = <IconButton> {
draw_icon: {svg_file: (ICO_SEND)},
icon_walk: {width: 15.0, height: Fit},
}
}
}
}
Expand Down