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

Replace AdaptiveView with Makepad's version. Fixes rooms search bug. #316

Merged
merged 2 commits into from
Jan 6, 2025
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
52 changes: 26 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/home/home_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ live_design! {
use crate::home::rooms_sidebar::RoomsSideBar;
use crate::home::spaces_dock::SpacesDock;
use crate::shared::styles::*;
use crate::shared::adaptive_view::AdaptiveView;
use crate::shared::search_bar::SearchBar;
use crate::home::main_desktop_ui::MainDesktopUI;

Expand Down
12 changes: 7 additions & 5 deletions src/home/room_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use makepad_widgets::*;

use crate::{
shared::{
adaptive_view::{AdaptiveViewWidgetExt, DisplayContext},
avatar::AvatarWidgetExt,
html_or_plaintext::HtmlOrPlaintextWidgetExt,
},
Expand All @@ -19,7 +18,6 @@ live_design! {
use crate::shared::styles::*;
use crate::shared::helpers::*;
use crate::shared::avatar::Avatar;
use crate::shared::adaptive_view::AdaptiveView;
use crate::shared::html_or_plaintext::HtmlOrPlaintext;

RoomName = <Label> {
Expand Down Expand Up @@ -103,9 +101,13 @@ live_design! {
}

pub RoomPreview = {{RoomPreview}} {
flow: Down, height: Fit

// Wrap the RoomPreviewContent in an AdaptiveView to change the displayed content
// (and its layout) based on the available space in the sidebar.
adaptive_preview = <AdaptiveView> {
height: Fit

kevinaboos marked this conversation as resolved.
Show resolved Hide resolved
OnlyIcon = <RoomPreviewContent> {
align: {x: 0.5, y: 0.5}
padding: 5.
Expand Down Expand Up @@ -152,11 +154,11 @@ pub enum RoomPreviewAction {
}

impl LiveHook for RoomPreview {
fn after_new_from_doc(&mut self, cx: &mut Cx) {
fn after_new_from_doc(&mut self, _cx: &mut Cx) {
// Adapt the preview based on the available space.
self.view
.adaptive_view(id!(adaptive_preview))
.set_variant_selector(cx, |_cx, parent_size| match parent_size.x {
.set_variant_selector(|_cx, parent_size| match parent_size.x {
width if width <= 70.0 => live_id!(OnlyIcon),
width if width <= 200.0 => live_id!(IconAndName),
_ => live_id!(FullPreview),
Expand Down Expand Up @@ -235,7 +237,7 @@ impl Widget for RoomPreviewContent {
}
}

if cx.get_global::<DisplayContext>().is_desktop() {
if cx.display_context.is_desktop() {
self.update_preview_colors(cx, room_info.is_selected);
} else if room_info.is_selected {
// Mobile doesn't have a selected state. Always use the default colors.
Expand Down
1 change: 0 additions & 1 deletion src/home/rooms_sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ live_design! {

use crate::shared::styles::*;
use crate::shared::helpers::*;
use crate::shared::adaptive_view::AdaptiveView;
use crate::shared::search_bar::SearchBar;

use crate::home::rooms_list::RoomsList;
Expand Down
4 changes: 1 addition & 3 deletions src/home/spaces_dock.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use makepad_widgets::*;

use crate::shared::adaptive_view::DisplayContext;
use crate::shared::color_tooltip::*;
use crate::shared::verification_badge::{VerificationBadge, VerificationText};
use crate::verification::VerificationStateAction;
Expand All @@ -15,7 +14,6 @@ live_design! {

use crate::shared::styles::*;
use crate::shared::helpers::*;
use crate::shared::adaptive_view::AdaptiveView;
use crate::shared::verification_badge::*;
use crate::shared::color_tooltip::*;

Expand Down Expand Up @@ -204,7 +202,7 @@ impl Widget for Profile {
VerificationState::Unknown => vec4(0.2, 0.2, 0.2, 1.0), // Grey
};

let tooltip_pos = if cx.get_global::<DisplayContext>().is_desktop() {
let tooltip_pos = if cx.display_context.is_desktop() {
DVec2 {
x: icons_rect.pos.x + icons_rect.size.x + 1.,
y: icons_rect.pos.y - 10.,
Expand Down
Loading
Loading