update
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run
This commit is contained in:
@@ -245,12 +245,14 @@ impl Render for CreateRepoDialog {
|
||||
|
||||
fn choose_folder(folder_input: &Entity<InputState>, window: &mut Window, cx: &mut App) {
|
||||
let store = SettingsStore::global(cx);
|
||||
|
||||
let prompt = cx.prompt_for_paths(PathPromptOptions {
|
||||
files: false,
|
||||
directories: true,
|
||||
multiple: false,
|
||||
prompt: Some("Choose folder".into()),
|
||||
});
|
||||
|
||||
let handle = window.window_handle();
|
||||
let folder_input = folder_input.clone();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use nostr::prelude::RelayUrl;
|
||||
use settings::{DEFAULT_GRASP_SERVERS, GraspServersSettings};
|
||||
use signed_state::Backend;
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
use ui::common::{h_flex, v_flex};
|
||||
use ui::common::{Sizable, h_flex, v_flex};
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::switch::Switch;
|
||||
@@ -72,13 +72,24 @@ pub fn grasp_servers_field(
|
||||
h_flex()
|
||||
.justify_between()
|
||||
.items_center()
|
||||
.child(div().typeset(TextRole::Body, cx).child("Grasp servers"))
|
||||
.child(div().typeset(TextRole::Caption, cx).child("Grasp servers"))
|
||||
.child(
|
||||
Switch::new("grasp-servers-toggle")
|
||||
.checked(servers_enabled)
|
||||
.on_change(move |checked, _, cx| {
|
||||
Button::new("toggle-grasp-servers")
|
||||
.icon(Icon::named(if servers_enabled {
|
||||
IconRole::ChevronRight
|
||||
} else {
|
||||
IconRole::ChevronDown
|
||||
}))
|
||||
.small()
|
||||
.variant(ButtonVariant::Ghost)
|
||||
.tooltip(Tooltip::text(if servers_enabled {
|
||||
"Hide grasp servers"
|
||||
} else {
|
||||
"Show grasp servers"
|
||||
}))
|
||||
.on_click(move |_, _, cx| {
|
||||
toggle_state.update(cx, |state, cx| {
|
||||
state.servers_enabled = checked;
|
||||
state.servers_enabled = !state.servers_enabled;
|
||||
cx.notify();
|
||||
});
|
||||
}),
|
||||
@@ -150,13 +161,13 @@ fn render_server_row(
|
||||
.gap_1()
|
||||
.items_center()
|
||||
.child(
|
||||
div()
|
||||
h_flex()
|
||||
.flex_1()
|
||||
.h_8()
|
||||
.px_2()
|
||||
.bg(cx.theme().colors.muted)
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.typeset(TextRole::Body, cx)
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.rounded(cx.theme().radius.control)
|
||||
.child(server_host(relay)),
|
||||
)
|
||||
|
||||
@@ -13,11 +13,13 @@ use ui::button::{Button, ButtonSide, ButtonVariant};
|
||||
use ui::common::{Sizable as _, h_flex, v_flex};
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::kbd::Kbd;
|
||||
use ui::popover::Popover;
|
||||
use ui::separator::Separator;
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset};
|
||||
use ui::tooltip::Tooltip;
|
||||
|
||||
use super::{CreateRepository, REPOSITORY_KEY_CONTEXT, SwitchRepository};
|
||||
use crate::shared::log_dropped;
|
||||
|
||||
type OpenHandler = Rc<dyn Fn(usize, &mut Window, &mut App)>;
|
||||
@@ -158,6 +160,11 @@ impl Render for RepositorySwitcher {
|
||||
let list_weak = row_weak.clone();
|
||||
let list_on_open = on_open.clone();
|
||||
let list_scroll_handle = scroll_handle.clone();
|
||||
let create_hint = Kbd::binding_for_action(
|
||||
&CreateRepository,
|
||||
Some(REPOSITORY_KEY_CONTEXT),
|
||||
window,
|
||||
);
|
||||
|
||||
v_flex()
|
||||
.w(px(380.))
|
||||
@@ -190,12 +197,16 @@ impl Render for RepositorySwitcher {
|
||||
uniform_list(
|
||||
"repo-switcher-list",
|
||||
visible.len(),
|
||||
move |range, _, cx| {
|
||||
move |range, window, cx| {
|
||||
range
|
||||
.filter_map(|row| {
|
||||
let entry = list_entries.get(row)?;
|
||||
let shortcut = repository_shortcut(entry.index);
|
||||
let index = entry.index;
|
||||
let shortcut = Kbd::binding_for_action(
|
||||
&SwitchRepository { index },
|
||||
Some(REPOSITORY_KEY_CONTEXT),
|
||||
window,
|
||||
);
|
||||
let weak = list_weak.clone();
|
||||
let on_open = list_on_open.clone();
|
||||
|
||||
@@ -218,15 +229,7 @@ impl Render for RepositorySwitcher {
|
||||
.child(entry.label.clone()),
|
||||
)
|
||||
.when_some(shortcut, |row, shortcut| {
|
||||
row.child(
|
||||
div()
|
||||
.text_color(
|
||||
theme
|
||||
.colors
|
||||
.muted_foreground,
|
||||
)
|
||||
.child(shortcut),
|
||||
)
|
||||
row.child(shortcut)
|
||||
})
|
||||
.cursor_pointer()
|
||||
.on_click(move |_, window, cx| {
|
||||
@@ -257,11 +260,7 @@ impl Render for RepositorySwitcher {
|
||||
.full_width(true)
|
||||
.icon(Icon::named(IconRole::CirclePlus))
|
||||
.child(div().flex_1().child("Create Repository"))
|
||||
.child(
|
||||
div()
|
||||
.text_color(theme.colors.muted_foreground)
|
||||
.child(create_shortcut()),
|
||||
)
|
||||
.when_some(create_hint, |button, hint| button.child(hint))
|
||||
.on_click(move |_, window, cx| {
|
||||
log_dropped(create_weak.update(cx, |this, cx| {
|
||||
this.close(cx);
|
||||
@@ -287,23 +286,3 @@ impl Render for RepositorySwitcher {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// The shortcut hint for a repository row, matching its key binding.
|
||||
fn repository_shortcut(index: usize) -> Option<SharedString> {
|
||||
(index < 9).then(|| {
|
||||
let label = if cfg!(target_os = "macos") {
|
||||
format!("⌘{}", index + 1)
|
||||
} else {
|
||||
format!("Ctrl+{}", index + 1)
|
||||
};
|
||||
SharedString::from(label)
|
||||
})
|
||||
}
|
||||
|
||||
fn create_shortcut() -> SharedString {
|
||||
if cfg!(target_os = "macos") {
|
||||
SharedString::from("⌘N")
|
||||
} else {
|
||||
SharedString::from("Ctrl+N")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user