git_ui.rs

 1use ::settings::Settings;
 2use git::status::FileStatus;
 3use git_panel_settings::GitPanelSettings;
 4use gpui::App;
 5use project_diff::ProjectDiff;
 6use ui::{ActiveTheme, Color, Icon, IconName, IntoElement};
 7
 8pub mod branch_picker;
 9mod commit_modal;
10pub mod git_panel;
11mod git_panel_settings;
12pub mod picker_prompt;
13pub mod project_diff;
14pub mod repository_selector;
15
16pub fn init(cx: &mut App) {
17    GitPanelSettings::register(cx);
18    branch_picker::init(cx);
19    cx.observe_new(ProjectDiff::register).detach();
20    commit_modal::init(cx);
21}
22
23// TODO: Add updated status colors to theme
24pub fn git_status_icon(status: FileStatus, cx: &App) -> impl IntoElement {
25    let (icon_name, color) = if status.is_conflicted() {
26        (
27            IconName::Warning,
28            cx.theme().colors().version_control_conflict,
29        )
30    } else if status.is_deleted() {
31        (
32            IconName::SquareMinus,
33            cx.theme().colors().version_control_deleted,
34        )
35    } else if status.is_modified() {
36        (
37            IconName::SquareDot,
38            cx.theme().colors().version_control_modified,
39        )
40    } else {
41        (
42            IconName::SquarePlus,
43            cx.theme().colors().version_control_added,
44        )
45    };
46    Icon::new(icon_name).color(Color::Custom(color))
47}