feedback_info_text.rs

 1// use gpui::{
 2//     elements::{Flex, Label, MouseEventHandler, ParentElement, Text},
 3//     platform::{CursorStyle, MouseButton},
 4//     AnyElement, Element, Entity, View, ViewContext, ViewHandle,
 5// };
 6// use workspace::{item::ItemHandle, ToolbarItemLocation, ToolbarItemView};
 7
 8// use crate::{feedback_editor::FeedbackEditor, open_zed_community_repo, OpenZedCommunityRepo};
 9
10// pub struct FeedbackInfoText {
11//     active_item: Option<ViewHandle<FeedbackEditor>>,
12// }
13
14// impl FeedbackInfoText {
15//     pub fn new() -> Self {
16//         Self {
17//             active_item: Default::default(),
18//         }
19//     }
20// }
21
22// impl Entity for FeedbackInfoText {
23//     type Event = ();
24// }
25
26// impl View for FeedbackInfoText {
27//     fn ui_name() -> &'static str {
28//         "FeedbackInfoText"
29//     }
30
31//     fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
32//         let theme = theme::current(cx).clone();
33
34//         Flex::row()
35//             .with_child(
36//                 Text::new(
37//                     "Share your feedback. Include your email for replies. For issues and discussions, visit the ",
38//                     theme.feedback.info_text_default.text.clone(),
39//                 )
40//                 .with_soft_wrap(false)
41//                 .aligned(),
42//             )
43//             .with_child(
44//                 MouseEventHandler::new::<OpenZedCommunityRepo, _>(0, cx, |state, _| {
45//                     let style = if state.hovered() {
46//                         &theme.feedback.link_text_hover
47//                     } else {
48//                         &theme.feedback.link_text_default
49//                     };
50//                     Label::new("community repo", style.text.clone())
51//                         .contained()
52//                         .with_style(style.container)
53//                         .aligned()
54//                         .left()
55//                         .clipped()
56//                 })
57//                 .with_cursor_style(CursorStyle::PointingHand)
58//                 .on_click(MouseButton::Left, |_, _, cx| {
59//                     open_zed_community_repo(&Default::default(), cx)
60//                 }),
61//             )
62//             .with_child(
63//                 Text::new(".", theme.feedback.info_text_default.text.clone())
64//                     .with_soft_wrap(false)
65//                     .aligned(),
66//             )
67//             .contained()
68//             .with_style(theme.feedback.info_text_default.container)
69//             .aligned()
70//             .left()
71//             .clipped()
72//             .into_any()
73//     }
74// }
75
76// impl ToolbarItemView for FeedbackInfoText {
77//     fn set_active_pane_item(
78//         &mut self,
79//         active_pane_item: Option<&dyn ItemHandle>,
80//         cx: &mut ViewContext<Self>,
81//     ) -> workspace::ToolbarItemLocation {
82//         cx.notify();
83//         if let Some(feedback_editor) = active_pane_item.and_then(|i| i.downcast::<FeedbackEditor>())
84//         {
85//             self.active_item = Some(feedback_editor);
86//             ToolbarItemLocation::PrimaryLeft {
87//                 flex: Some((1., false)),
88//             }
89//         } else {
90//             self.active_item = None;
91//             ToolbarItemLocation::Hidden
92//         }
93//     }
94// }