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::{
2121 pub struct Auth {
2222 server_input: Entity<InputState>,
2323 any_cert: bool,
24+ server_open: bool,
2425 username_input: Entity<InputState>,
2526 password_input: Entity<InputState>,
2627 invite_input: Entity<InputState>,
@@ -54,6 +55,7 @@ impl Auth {
5455 Self {
5556 server_input,
5657 any_cert: server.any_cert,
58+ server_open: false,
5759 username_input,
5860 password_input,
5961 invite_input,
@@ -118,6 +120,39 @@ fn submit(this: &mut Yumush, window: &mut Window, cx: &mut Context<Yumush>) {
118120 .detach();
119121 }
120122
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+
121156 fn password_field(palette: Palette, input: &Entity<InputState>) -> Div {
122157 frame(palette, Input::new(input).mask_toggle())
123158 }
@@ -179,37 +214,49 @@ impl Yumush {
179214 .text_color(palette.muted)
180215 .child("Maintenance")
181216 }))
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- )
207217 .children(self.saved_accounts(&entity, palette))
208218 .child(tabs)
209219 .child(field(palette, &self.auth.username_input))
210220 .child(password_field(palette, &self.auth.password_input))
211221 .children(invite)
212222 .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+ }))
213260 .children(connection_notice(&self.connection, palette)),
214261 )
215262 }
crates/client/src/lib.rsmodified+2 -1
@@ -67,9 +67,10 @@ impl Server {
6767 pub fn load() -> Self {
6868 let saved = read_config("server");
6969 let mut lines = saved.as_deref().unwrap_or_default().lines().map(str::trim);
70+ let saved_address = lines.next();
7071 let address = std::env::var("YUMUSH_SERVER_ADDRESS")
7172 .ok()
72- .or_else(|| lines.next().map(str::to_string))
73+ .or_else(|| saved_address.map(str::to_string))
7374 .filter(|address| !address.is_empty())
7475 .unwrap_or_else(|| {
7576 Config::parse(CLIENT_CONFIG_FILE_CONTENT)