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