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

Display verification status as a badge atop the user profile icon (issue241) #243

Closed
wants to merge 1 commit into from
Closed
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
108 changes: 71 additions & 37 deletions src/home/spaces_dock.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use makepad_widgets::*;
use matrix_sdk::encryption::VerificationState;
use crate::sliding_sync::get_client;

live_design! {
import makepad_widgets::base::*;
Expand Down Expand Up @@ -102,51 +104,83 @@ live_design! {
}
}

SDock = {{SDock}} {}

SpacesDock = <AdaptiveView> {
Desktop = {
flow: Down, spacing: 15
align: {x: 0.5}
padding: {top: 40., bottom: 20.}
width: 68., height: Fill
show_bg: true
draw_bg: {
color: (COLOR_SECONDARY)
Desktop = <SDock> {
flow: Down, spacing: 15
align: {x: 0.5}
padding: {top: 40., bottom: 20.}
width: 68., height: Fill
show_bg: true
draw_bg: {
color: (COLOR_SECONDARY)
}

profile = <Profile> {}

<Separator> {}

<Home> {}

<Filler> {}

<Settings> {}
}
Mobile = <SDock> {
flow: Right
align: {x: 0.5, y: 0.5}
padding: {top: 10, right: 10, bottom: 10, left: 10}
width: Fill, height: Fit
show_bg: true
draw_bg: {
color: (COLOR_SECONDARY)
}

<Profile> {}
<Filler> {}

<Separator> {}
profile = <Profile> {}

<Home> {}

<Filler> {}
<Filler> {}

<Settings> {}
}
<Home> {}

Mobile = {
flow: Right
align: {x: 0.5, y: 0.5}
padding: {top: 10, right: 10, bottom: 10, left: 10}
width: Fill, height: Fit
show_bg: true
draw_bg: {
color: (COLOR_SECONDARY)
<Filler> {}

<Settings> {}

<Filler> {}
}
}
}

<Filler> {}

<Profile> {}

<Filler> {}

<Home> {}

<Filler> {}

<Settings> {}

<Filler> {}
}
#[derive(Live, LiveHook, Widget)]
pub struct SDock {
#[deref]
view: View,
#[rust(None)]
verification_state: Option<matrix_sdk::encryption::VerificationState>,
}

impl Widget for SDock {
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
let client = get_client().unwrap();
let verficiation_state_subscriber = client.encryption().verification_state();
self.verification_state = Some(verficiation_state_subscriber.get());

self.view.handle_event(cx, event, scope);
}

fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {
if let Some(verification_state) = self.verification_state {
let verification_text = match verification_state {
VerificationState::Unknown => "U",
VerificationState::Verified => "V",
VerificationState::Unverified => "N",
};
self.label(id!(profile.text_view.text)).set_text(verification_text);
};

self.view.draw_walk(cx, scope, walk)
}
}