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 git_panel;
 9mod git_panel_settings;
10pub mod project_diff;
11pub mod repository_selector;
12
13pub fn init(cx: &mut App) {
14    GitPanelSettings::register(cx);
15    cx.observe_new(ProjectDiff::register).detach();
16}
17
18// TODO: Add updated status colors to theme
19pub fn git_status_icon(status: FileStatus, cx: &App) -> impl IntoElement {
20    let (icon_name, color) = if status.is_conflicted() {
21        (
22            IconName::Warning,
23            cx.theme().colors().version_control_conflict,
24        )
25    } else if status.is_deleted() {
26        (
27            IconName::SquareMinus,
28            cx.theme().colors().version_control_deleted,
29        )
30    } else if status.is_modified() {
31        (
32            IconName::SquareDot,
33            cx.theme().colors().version_control_modified,
34        )
35    } else {
36        (
37            IconName::SquarePlus,
38            cx.theme().colors().version_control_added,
39        )
40    };
41    Icon::new(icon_name).color(Color::Custom(color))
42}