From b500ed317177caf1b5ec2d77159864a7cc06b7be Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 21 Feb 2023 16:46:03 -0800 Subject: [PATCH] Changed label and text to be generic over static strings and owned strings --- crates/auto_update/src/update_notification.rs | 2 +- crates/breadcrumbs/src/breadcrumbs.rs | 2 +- crates/collab_ui/src/collab_titlebar_item.rs | 6 +++--- crates/collab_ui/src/contact_list.rs | 10 +++++----- .../collab_ui/src/incoming_call_notification.rs | 4 ++-- crates/collab_ui/src/notifications.rs | 8 ++++---- .../collab_ui/src/project_shared_notification.rs | 4 ++-- crates/command_palette/src/command_palette.rs | 2 +- crates/diagnostics/src/diagnostics.rs | 15 ++++++--------- crates/diagnostics/src/items.rs | 13 +++++-------- crates/editor/src/element.rs | 2 +- crates/editor/src/items.rs | 2 +- crates/feedback/src/deploy_feedback_button.rs | 6 +----- crates/feedback/src/feedback_editor.rs | 2 +- crates/feedback/src/feedback_info_text.rs | 2 +- crates/feedback/src/submit_feedback_button.rs | 2 +- crates/gpui/src/elements/label.rs | 16 +++++++--------- crates/gpui/src/elements/text.rs | 8 ++++---- crates/picker/src/picker.rs | 2 +- crates/search/src/buffer_search.rs | 8 ++++---- crates/search/src/project_search.rs | 10 +++++----- crates/terminal_view/src/terminal_view.rs | 2 +- crates/theme_testbench/src/theme_testbench.rs | 2 +- crates/workspace/src/workspace.rs | 2 +- 24 files changed, 60 insertions(+), 72 deletions(-) diff --git a/crates/auto_update/src/update_notification.rs b/crates/auto_update/src/update_notification.rs index e6b285b072..eaf958572a 100644 --- a/crates/auto_update/src/update_notification.rs +++ b/crates/auto_update/src/update_notification.rs @@ -78,7 +78,7 @@ impl View for UpdateNotification { ) .with_child({ let style = theme.action_message.style_for(state, false); - Text::new("View the release notes".to_string(), style.text.clone()) + Text::new("View the release notes", style.text.clone()) .contained() .with_style(style.container) .boxed() diff --git a/crates/breadcrumbs/src/breadcrumbs.rs b/crates/breadcrumbs/src/breadcrumbs.rs index 278b8f39e2..47b7f88453 100644 --- a/crates/breadcrumbs/src/breadcrumbs.rs +++ b/crates/breadcrumbs/src/breadcrumbs.rs @@ -47,7 +47,7 @@ impl View for Breadcrumbs { { Flex::row() .with_children(Itertools::intersperse_with(breadcrumbs.into_iter(), || { - Label::new(" 〉 ".to_string(), theme.breadcrumbs.text.clone()).boxed() + Label::new(" 〉 ", theme.breadcrumbs.text.clone()).boxed() })) .contained() .with_style(theme.breadcrumbs.container) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 184a432ea3..a767e50565 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -293,7 +293,7 @@ impl CollabTitlebarItem { let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar.share_button.style_for(state, false); - Label::new("Share".into(), style.text.clone()) + Label::new("Share", style.text.clone()) .contained() .with_style(style.container) .boxed() @@ -378,7 +378,7 @@ impl CollabTitlebarItem { .titlebar .sign_in_prompt .style_for(state, false); - Label::new("Sign in".to_string(), style.text.clone()) + Label::new("Sign in", style.text.clone()) .contained() .with_style(style.container) .boxed() @@ -531,7 +531,7 @@ impl CollabTitlebarItem { client::Status::UpgradeRequired => Some( MouseEventHandler::::new(0, cx, |_, _| { Label::new( - "Please update Zed to collaborate".to_string(), + "Please update Zed to collaborate", theme.workspace.titlebar.outdated_warning.text.clone(), ) .contained() diff --git a/crates/collab_ui/src/contact_list.rs b/crates/collab_ui/src/contact_list.rs index c4250c142b..a1607750c9 100644 --- a/crates/collab_ui/src/contact_list.rs +++ b/crates/collab_ui/src/contact_list.rs @@ -749,7 +749,7 @@ impl ContactList { ) .with_children(if is_pending { Some( - Label::new("Calling".to_string(), theme.calling_indicator.text.clone()) + Label::new("Calling", theme.calling_indicator.text.clone()) .contained() .with_style(theme.calling_indicator.container) .aligned() @@ -950,7 +950,7 @@ impl ContactList { .boxed(), ) .with_child( - Label::new("Screen".into(), row.name.text.clone()) + Label::new("Screen", row.name.text.clone()) .aligned() .left() .contained() @@ -994,7 +994,7 @@ impl ContactList { Some( MouseEventHandler::::new(0, cx, |state, _| { let style = theme.leave_call.style_for(state, false); - Label::new("Leave Session".into(), style.text.clone()) + Label::new("Leave Session", style.text.clone()) .contained() .with_style(style.container) .boxed() @@ -1026,7 +1026,7 @@ impl ContactList { .boxed(), ) .with_child( - Label::new(text.to_string(), header_style.text.clone()) + Label::new(text, header_style.text.clone()) .aligned() .left() .contained() @@ -1126,7 +1126,7 @@ impl ContactList { ) .with_children(if calling { Some( - Label::new("Calling".to_string(), theme.calling_indicator.text.clone()) + Label::new("Calling", theme.calling_indicator.text.clone()) .contained() .with_style(theme.calling_indicator.container) .aligned() diff --git a/crates/collab_ui/src/incoming_call_notification.rs b/crates/collab_ui/src/incoming_call_notification.rs index 5d888bc093..a0f54abe38 100644 --- a/crates/collab_ui/src/incoming_call_notification.rs +++ b/crates/collab_ui/src/incoming_call_notification.rs @@ -172,7 +172,7 @@ impl IncomingCallNotification { .with_child( MouseEventHandler::::new(0, cx, |_, cx| { let theme = &cx.global::().theme.incoming_call_notification; - Label::new("Accept".to_string(), theme.accept_button.text.clone()) + Label::new("Accept", theme.accept_button.text.clone()) .aligned() .contained() .with_style(theme.accept_button.container) @@ -188,7 +188,7 @@ impl IncomingCallNotification { .with_child( MouseEventHandler::::new(0, cx, |_, cx| { let theme = &cx.global::().theme.incoming_call_notification; - Label::new("Decline".to_string(), theme.decline_button.text.clone()) + Label::new("Decline", theme.decline_button.text.clone()) .aligned() .contained() .with_style(theme.decline_button.container) diff --git a/crates/collab_ui/src/notifications.rs b/crates/collab_ui/src/notifications.rs index 1e0574de95..06b6cf2a90 100644 --- a/crates/collab_ui/src/notifications.rs +++ b/crates/collab_ui/src/notifications.rs @@ -11,8 +11,8 @@ enum Button {} pub fn render_user_notification( user: Arc, - title: &str, - body: Option<&str>, + title: &'static str, + body: Option<&'static str>, dismiss_action: A, buttons: Vec<(&'static str, Box)>, cx: &mut RenderContext, @@ -83,7 +83,7 @@ pub fn render_user_notification( .named("contact notification header"), ) .with_children(body.map(|body| { - Label::new(body.to_string(), theme.body_message.text.clone()) + Label::new(body, theme.body_message.text.clone()) .contained() .with_style(theme.body_message.container) .boxed() @@ -97,7 +97,7 @@ pub fn render_user_notification( |(ix, (message, action))| { MouseEventHandler::