forge
Explore
Log in

Don't you dare go Hollow

Server address and certificate switch fold under a faint address line on the login screen

Browse files at this commit

c2a2d84073ea51462b4cb2174cc9d0d619b49611Ahmet Kaan GümüşParent: b986e58
  • style
    • server address and certificate switch fold under a faint address line on the login screen
  • fix
    • with YUMUSH_SERVER_ADDRESS set, the saved address line was read as the certificate flag
Show full message
🎨 style: server address and certificate switch fold under a faint address line on the login screen; 🐛 fix: with YUMUSH_SERVER_ADDRESS set, the saved address line was read as the certificate flag
crates/client/src/gui/auth.rsmodified+72 -25
@@ -21,6 +21,7 @@ use super::{
21 pub struct Auth {21 pub struct Auth {
22 server_input: Entity<InputState>,22 server_input: Entity<InputState>,
23 any_cert: bool,23 any_cert: bool,
24+ server_open: bool,
24 username_input: Entity<InputState>,25 username_input: Entity<InputState>,
25 password_input: Entity<InputState>,26 password_input: Entity<InputState>,
26 invite_input: Entity<InputState>,27 invite_input: Entity<InputState>,
@@ -54,6 +55,7 @@ impl Auth {
54 Self {55 Self {
55 server_input,56 server_input,
56 any_cert: server.any_cert,57 any_cert: server.any_cert,
58+ server_open: false,
57 username_input,59 username_input,
58 password_input,60 password_input,
59 invite_input,61 invite_input,
@@ -118,6 +120,39 @@ fn submit(this: &mut Yumush, window: &mut Window, cx: &mut Context<Yumush>) {
118 .detach();120 .detach();
119 }121 }
120 122
123+fn server_toggle(
124+ entity: &Entity<Yumush>,
125+ address: &str,
126+ open: bool,
127+ palette: Palette,
128+) -> impl IntoElement {
129+ let entity = entity.clone();
130+ clickable("server_toggle", palette, move |_, cx| {
131+ entity.update(cx, |yumush, cx| {
132+ yumush.auth.server_open = !yumush.auth.server_open;
133+ cx.notify();
134+ })
135+ })
136+ .self_center()
137+ .px(px(space::SM))
138+ .py(px(space::XXS))
139+ .rounded(px(radius::MD))
140+ .flex()
141+ .items_center()
142+ .gap(px(space::XS))
143+ .text_size(text(text::CAPTION))
144+ .text_color(palette.muted)
145+ .child(address.to_string())
146+ .child(
147+ Icon::new(if open {
148+ IconName::ChevronDown
149+ } else {
150+ IconName::ChevronRight
151+ })
152+ .size(px(size::ICON_SM)),
153+ )
154+}
155+
121 fn password_field(palette: Palette, input: &Entity<InputState>) -> Div {156 fn password_field(palette: Palette, input: &Entity<InputState>) -> Div {
122 frame(palette, Input::new(input).mask_toggle())157 frame(palette, Input::new(input).mask_toggle())
123 }158 }
@@ -179,37 +214,49 @@ impl Yumush {
179 .text_color(palette.muted)214 .text_color(palette.muted)
180 .child("Maintenance")215 .child("Maintenance")
181 }))216 }))
182- .child(field(palette, &self.auth.server_input))
183- .child(
184- div()
185- .flex()
186- .items_center()
187- .justify_between()
188- .text_size(text(text::CAPTION))
189- .text_color(palette.muted)
190- .child("Accept any certificate")
191- .child(super::parts::toggle(
192- "any_cert_switch",
193- self.auth.any_cert,
194- palette.tokens,
195- {
196- let entity = entity.clone();
197- move |_, cx| {
198- entity.update(cx, |yumush, cx| {
199- yumush.auth.any_cert = !yumush.auth.any_cert;
200- apply_server(yumush, cx);
201- cx.notify();
202- })
203- }
204- },
205- )),
206- )
207 .children(self.saved_accounts(&entity, palette))217 .children(self.saved_accounts(&entity, palette))
208 .child(tabs)218 .child(tabs)
209 .child(field(palette, &self.auth.username_input))219 .child(field(palette, &self.auth.username_input))
210 .child(password_field(palette, &self.auth.password_input))220 .child(password_field(palette, &self.auth.password_input))
211 .children(invite)221 .children(invite)
212 .child(action_button)222 .child(action_button)
223+ .child(server_toggle(
224+ &entity,
225+ &self.network.server().address,
226+ self.auth.server_open,
227+ palette,
228+ ))
229+ .children(self.auth.server_open.then(|| {
230+ div()
231+ .flex()
232+ .flex_col()
233+ .gap(px(space::SM))
234+ .child(field(palette, &self.auth.server_input))
235+ .child(
236+ div()
237+ .flex()
238+ .items_center()
239+ .justify_between()
240+ .text_size(text(text::CAPTION))
241+ .text_color(palette.muted)
242+ .child("Accept any certificate")
243+ .child(super::parts::toggle(
244+ "any_cert_switch",
245+ self.auth.any_cert,
246+ palette.tokens,
247+ {
248+ let entity = entity.clone();
249+ move |_, cx| {
250+ entity.update(cx, |yumush, cx| {
251+ yumush.auth.any_cert = !yumush.auth.any_cert;
252+ apply_server(yumush, cx);
253+ cx.notify();
254+ })
255+ }
256+ },
257+ )),
258+ )
259+ }))
213 .children(connection_notice(&self.connection, palette)),260 .children(connection_notice(&self.connection, palette)),
214 )261 )
215 }262 }
crates/client/src/lib.rsmodified+2 -1
@@ -67,9 +67,10 @@ impl Server {
67 pub fn load() -> Self {67 pub fn load() -> Self {
68 let saved = read_config("server");68 let saved = read_config("server");
69 let mut lines = saved.as_deref().unwrap_or_default().lines().map(str::trim);69 let mut lines = saved.as_deref().unwrap_or_default().lines().map(str::trim);
70+ let saved_address = lines.next();
70 let address = std::env::var("YUMUSH_SERVER_ADDRESS")71 let address = std::env::var("YUMUSH_SERVER_ADDRESS")
71 .ok()72 .ok()
72- .or_else(|| lines.next().map(str::to_string))73+ .or_else(|| saved_address.map(str::to_string))
73 .filter(|address| !address.is_empty())74 .filter(|address| !address.is_empty())
74 .unwrap_or_else(|| {75 .unwrap_or_else(|| {
75 Config::parse(CLIENT_CONFIG_FILE_CONTENT)76 Config::parse(CLIENT_CONFIG_FILE_CONTENT)