mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-24 03:24:21 +01:00
refactor: collapse client label settings; drop CLI/settings toggles
The "top vs bottom" client label setting was cluttering the UI and
codebase with toggles that added little value. This consolidates client
label handling into one option, removes unused CLI/settings knobs, and
makes NoteView’s API consistent and fluent. Result: fewer knobs, less
branching, and a clearer, more predictable UI.
Now client labels are only shown in one place: selected notes.
- Drop `--show-client` arg in notedeck and `--show-note-client=top|bottom`
args in notedeck_columns
- Remove `NotedeckOptions::ShowClient` and related CLI parsing
- Delete `ShowSourceClientOption` enum, settings UI, and
`SettingsAction::SetShowSourceClient`
- Collapse `NoteOptions::{ClientNameTop, ClientNameBottom}` into a single
`NoteOptions::ClientName`
- Add `NoteOptions::{Framed, UnreadIndicator}`
- Move “framed” and unread indicator into flags (no more ad‑hoc bools)
- Add new NoteView builder methods: `.client_name()`, `.frame()`,
`.unread_indicator()`, and `.selected_style()`
- CLI flags for showing client labels have been removed
- `ClientNameTop`/`ClientNameBottom` replaced with `ClientName`
- API using `framed` or `show_unread_indicator` booleans must now use
the new flag setters
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -124,8 +124,6 @@ impl Args {
|
|||||||
res.options.set(NotedeckOptions::UseKeystore, true);
|
res.options.set(NotedeckOptions::UseKeystore, true);
|
||||||
} else if arg == "--relay-debug" {
|
} else if arg == "--relay-debug" {
|
||||||
res.options.set(NotedeckOptions::RelayDebug, true);
|
res.options.set(NotedeckOptions::RelayDebug, true);
|
||||||
} else if arg == "--show-client" {
|
|
||||||
res.options.set(NotedeckOptions::ShowClient, true);
|
|
||||||
} else if arg == "--notebook" {
|
} else if arg == "--notebook" {
|
||||||
res.options.set(NotedeckOptions::FeatureNotebook, true);
|
res.options.set(NotedeckOptions::FeatureNotebook, true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ bitflags! {
|
|||||||
/// Use keystore?
|
/// Use keystore?
|
||||||
const UseKeystore = 1 << 4;
|
const UseKeystore = 1 << 4;
|
||||||
|
|
||||||
/// Show client on notes?
|
|
||||||
const ShowClient = 1 << 5;
|
|
||||||
|
|
||||||
/// Simulate is_compiled_as_mobile ?
|
/// Simulate is_compiled_as_mobile ?
|
||||||
const Mobile = 1 << 6;
|
const Mobile = 1 << 6;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use crate::{
|
|||||||
subscriptions::{SubKind, Subscriptions},
|
subscriptions::{SubKind, Subscriptions},
|
||||||
support::Support,
|
support::Support,
|
||||||
timeline::{self, kind::ListKind, thread::Threads, TimelineCache, TimelineKind},
|
timeline::{self, kind::ListKind, thread::Threads, TimelineCache, TimelineKind},
|
||||||
ui::{self, DesktopSidePanel, ShowSourceClientOption, SidePanelAction},
|
ui::{self, DesktopSidePanel, SidePanelAction},
|
||||||
view_state::ViewState,
|
view_state::ViewState,
|
||||||
Result,
|
Result,
|
||||||
};
|
};
|
||||||
@@ -591,17 +591,6 @@ fn get_note_options(args: ColumnsArgs, settings_handler: &mut SettingsHandler) -
|
|||||||
NoteOptions::HideMedia,
|
NoteOptions::HideMedia,
|
||||||
args.is_flag_set(ColumnsFlag::NoMedia),
|
args.is_flag_set(ColumnsFlag::NoMedia),
|
||||||
);
|
);
|
||||||
note_options.set(
|
|
||||||
NoteOptions::ClientNameTop,
|
|
||||||
ShowSourceClientOption::Top == settings_handler.show_source_client().into()
|
|
||||||
|| args.is_flag_set(ColumnsFlag::ShowNoteClientTop),
|
|
||||||
);
|
|
||||||
note_options.set(
|
|
||||||
NoteOptions::ClientNameBottom,
|
|
||||||
ShowSourceClientOption::Bottom == settings_handler.show_source_client().into()
|
|
||||||
|| args.is_flag_set(ColumnsFlag::ShowNoteClientBottom),
|
|
||||||
);
|
|
||||||
|
|
||||||
note_options.set(
|
note_options.set(
|
||||||
NoteOptions::RepliesNewestFirst,
|
NoteOptions::RepliesNewestFirst,
|
||||||
settings_handler.show_replies_newest_first(),
|
settings_handler.show_replies_newest_first(),
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ pub enum ColumnsFlag {
|
|||||||
Textmode,
|
Textmode,
|
||||||
Scramble,
|
Scramble,
|
||||||
NoMedia,
|
NoMedia,
|
||||||
ShowNoteClientTop,
|
|
||||||
ShowNoteClientBottom,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ColumnsArgs {
|
pub struct ColumnsArgs {
|
||||||
@@ -54,10 +52,6 @@ impl ColumnsArgs {
|
|||||||
res.clear_flag(ColumnsFlag::SinceOptimize);
|
res.clear_flag(ColumnsFlag::SinceOptimize);
|
||||||
} else if arg == "--scramble" {
|
} else if arg == "--scramble" {
|
||||||
res.set_flag(ColumnsFlag::Scramble);
|
res.set_flag(ColumnsFlag::Scramble);
|
||||||
} else if arg == "--show-note-client=top" {
|
|
||||||
res.set_flag(ColumnsFlag::ShowNoteClientTop);
|
|
||||||
} else if arg == "--show-note-client=bottom" {
|
|
||||||
res.set_flag(ColumnsFlag::ShowNoteClientBottom);
|
|
||||||
} else if arg == "--no-media" {
|
} else if arg == "--no-media" {
|
||||||
res.set_flag(ColumnsFlag::NoMedia);
|
res.set_flag(ColumnsFlag::NoMedia);
|
||||||
} else if arg == "--filter" {
|
} else if arg == "--filter" {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ pub use preview::{Preview, PreviewApp, PreviewConfig};
|
|||||||
pub use profile::ProfileView;
|
pub use profile::ProfileView;
|
||||||
pub use relay::RelayView;
|
pub use relay::RelayView;
|
||||||
pub use settings::SettingsView;
|
pub use settings::SettingsView;
|
||||||
pub use settings::ShowSourceClientOption;
|
|
||||||
pub use side_panel::{DesktopSidePanel, SidePanelAction};
|
pub use side_panel::{DesktopSidePanel, SidePanelAction};
|
||||||
pub use thread::ThreadView;
|
pub use thread::ThreadView;
|
||||||
pub use timeline::TimelineView;
|
pub use timeline::TimelineView;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ use notedeck::{
|
|||||||
SettingsHandler, DEFAULT_NOTE_BODY_FONT_SIZE,
|
SettingsHandler, DEFAULT_NOTE_BODY_FONT_SIZE,
|
||||||
};
|
};
|
||||||
use notedeck_ui::{NoteOptions, NoteView};
|
use notedeck_ui::{NoteOptions, NoteView};
|
||||||
use strum::Display;
|
|
||||||
|
|
||||||
use crate::{nav::RouterAction, Damus, Route};
|
use crate::{nav::RouterAction, Damus, Route};
|
||||||
|
|
||||||
@@ -21,89 +20,9 @@ const MAX_ZOOM: f32 = 3.0;
|
|||||||
const ZOOM_STEP: f32 = 0.1;
|
const ZOOM_STEP: f32 = 0.1;
|
||||||
const RESET_ZOOM: f32 = 1.0;
|
const RESET_ZOOM: f32 = 1.0;
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Display)]
|
|
||||||
pub enum ShowSourceClientOption {
|
|
||||||
Hide,
|
|
||||||
Top,
|
|
||||||
Bottom,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ShowSourceClientOption> for String {
|
|
||||||
fn from(show_option: ShowSourceClientOption) -> Self {
|
|
||||||
match show_option {
|
|
||||||
ShowSourceClientOption::Hide => "hide".to_string(),
|
|
||||||
ShowSourceClientOption::Top => "top".to_string(),
|
|
||||||
ShowSourceClientOption::Bottom => "bottom".to_string(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<NoteOptions> for ShowSourceClientOption {
|
|
||||||
fn from(note_options: NoteOptions) -> Self {
|
|
||||||
if note_options.contains(NoteOptions::ClientNameTop) {
|
|
||||||
ShowSourceClientOption::Top
|
|
||||||
} else if note_options.contains(NoteOptions::ClientNameBottom) {
|
|
||||||
ShowSourceClientOption::Bottom
|
|
||||||
} else {
|
|
||||||
ShowSourceClientOption::Hide
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<String> for ShowSourceClientOption {
|
|
||||||
fn from(s: String) -> Self {
|
|
||||||
match s.to_lowercase().as_str() {
|
|
||||||
"hide" => Self::Hide,
|
|
||||||
"top" => Self::Top,
|
|
||||||
"bottom" => Self::Bottom,
|
|
||||||
_ => Self::Hide, // default fallback
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ShowSourceClientOption {
|
|
||||||
pub fn set_note_options(self, note_options: &mut NoteOptions) {
|
|
||||||
match self {
|
|
||||||
Self::Hide => {
|
|
||||||
note_options.set(NoteOptions::ClientNameTop, false);
|
|
||||||
note_options.set(NoteOptions::ClientNameBottom, false);
|
|
||||||
}
|
|
||||||
Self::Bottom => {
|
|
||||||
note_options.set(NoteOptions::ClientNameTop, false);
|
|
||||||
note_options.set(NoteOptions::ClientNameBottom, true);
|
|
||||||
}
|
|
||||||
Self::Top => {
|
|
||||||
note_options.set(NoteOptions::ClientNameTop, true);
|
|
||||||
note_options.set(NoteOptions::ClientNameBottom, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn label(&self, i18n: &mut Localization) -> String {
|
|
||||||
match self {
|
|
||||||
Self::Hide => tr!(
|
|
||||||
i18n,
|
|
||||||
"Hide",
|
|
||||||
"Option in settings section to hide the source client label in note display"
|
|
||||||
),
|
|
||||||
Self::Top => tr!(
|
|
||||||
i18n,
|
|
||||||
"Top",
|
|
||||||
"Option in settings section to show the source client label at the top of the note"
|
|
||||||
),
|
|
||||||
Self::Bottom => tr!(
|
|
||||||
i18n,
|
|
||||||
"Bottom",
|
|
||||||
"Option in settings section to show the source client label at the bottom of the note"
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum SettingsAction {
|
pub enum SettingsAction {
|
||||||
SetZoomFactor(f32),
|
SetZoomFactor(f32),
|
||||||
SetTheme(ThemePreference),
|
SetTheme(ThemePreference),
|
||||||
SetShowSourceClient(ShowSourceClientOption),
|
|
||||||
SetLocale(LanguageIdentifier),
|
SetLocale(LanguageIdentifier),
|
||||||
SetRepliestNewestFirst(bool),
|
SetRepliestNewestFirst(bool),
|
||||||
SetNoteBodyFontSize(f32),
|
SetNoteBodyFontSize(f32),
|
||||||
@@ -131,11 +50,6 @@ impl SettingsAction {
|
|||||||
ctx.set_zoom_factor(zoom_factor);
|
ctx.set_zoom_factor(zoom_factor);
|
||||||
settings.set_zoom_factor(zoom_factor);
|
settings.set_zoom_factor(zoom_factor);
|
||||||
}
|
}
|
||||||
Self::SetShowSourceClient(option) => {
|
|
||||||
option.set_note_options(&mut app.note_options);
|
|
||||||
|
|
||||||
settings.set_show_source_client(option);
|
|
||||||
}
|
|
||||||
Self::SetTheme(theme) => {
|
Self::SetTheme(theme) => {
|
||||||
ctx.set_theme(theme);
|
ctx.set_theme(theme);
|
||||||
settings.set_theme(theme);
|
settings.set_theme(theme);
|
||||||
@@ -551,35 +465,6 @@ impl<'a> SettingsView<'a> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.horizontal_wrapped(|ui| {
|
|
||||||
ui.label(richtext_small(tr!(
|
|
||||||
self.note_context.i18n,
|
|
||||||
"Source client:",
|
|
||||||
"Label for Source client, others settings section",
|
|
||||||
)));
|
|
||||||
|
|
||||||
for option in [
|
|
||||||
ShowSourceClientOption::Hide,
|
|
||||||
ShowSourceClientOption::Top,
|
|
||||||
ShowSourceClientOption::Bottom,
|
|
||||||
] {
|
|
||||||
let mut current: ShowSourceClientOption =
|
|
||||||
self.settings.show_source_client.clone().into();
|
|
||||||
|
|
||||||
if ui
|
|
||||||
.selectable_value(
|
|
||||||
&mut current,
|
|
||||||
option,
|
|
||||||
RichText::new(option.label(self.note_context.i18n))
|
|
||||||
.text_style(NotedeckTextStyle::Small.text_style()),
|
|
||||||
)
|
|
||||||
.changed()
|
|
||||||
{
|
|
||||||
action = Some(SettingsAction::SetShowSourceClient(option));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
action
|
action
|
||||||
|
|||||||
@@ -279,6 +279,12 @@ enum ThreadNoteType {
|
|||||||
Reply,
|
Reply,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ThreadNoteType {
|
||||||
|
fn is_selected(&self) -> bool {
|
||||||
|
matches!(self, ThreadNoteType::Selected { .. })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct ThreadNotes<'a> {
|
struct ThreadNotes<'a> {
|
||||||
notes: Vec<ThreadNote<'a>>,
|
notes: Vec<ThreadNote<'a>>,
|
||||||
selected_index: usize,
|
selected_index: usize,
|
||||||
@@ -313,6 +319,7 @@ impl<'a> ThreadNote<'a> {
|
|||||||
) -> NoteResponse {
|
) -> NoteResponse {
|
||||||
let inner = notedeck_ui::padding(8.0, ui, |ui| {
|
let inner = notedeck_ui::padding(8.0, ui, |ui| {
|
||||||
NoteView::new(note_context, &self.note, self.options(flags), jobs)
|
NoteView::new(note_context, &self.note, self.options(flags), jobs)
|
||||||
|
.selected_style(self.note_type.is_selected())
|
||||||
.unread_indicator(self.unread_and_have_replies)
|
.unread_indicator(self.unread_and_have_replies)
|
||||||
.show(ui)
|
.show(ui)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -129,11 +129,6 @@ fn render_note_contents(
|
|||||||
options: NoteOptions,
|
options: NoteOptions,
|
||||||
jobs: &mut JobsCache,
|
jobs: &mut JobsCache,
|
||||||
) -> NoteResponse {
|
) -> NoteResponse {
|
||||||
if options.contains(NoteOptions::ClientNameTop) {
|
|
||||||
let before_date = false;
|
|
||||||
render_client_name(ui, note_context.note_cache, note, before_date);
|
|
||||||
}
|
|
||||||
|
|
||||||
let response = render_undecorated_note_contents(ui, note_context, txn, note, options, jobs);
|
let response = render_undecorated_note_contents(ui, note_context, txn, note, options, jobs);
|
||||||
|
|
||||||
ui.horizontal_wrapped(|ui| {
|
ui.horizontal_wrapped(|ui| {
|
||||||
@@ -163,7 +158,7 @@ fn note_bottom_metadata_ui(
|
|||||||
secondary_label(ui, time_format(i18n, note.created_at()));
|
secondary_label(ui, time_format(i18n, note.created_at()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.contains(NoteOptions::ClientNameBottom) {
|
if options.contains(NoteOptions::ClientName) {
|
||||||
render_client_name(ui, note_cache, note, show_full_date);
|
render_client_name(ui, note_cache, note, show_full_date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,10 +39,8 @@ pub struct NoteView<'a, 'd> {
|
|||||||
note_context: &'a mut NoteContext<'d>,
|
note_context: &'a mut NoteContext<'d>,
|
||||||
parent: Option<NoteKey>,
|
parent: Option<NoteKey>,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
framed: bool,
|
|
||||||
flags: NoteOptions,
|
flags: NoteOptions,
|
||||||
jobs: &'a mut JobsCache,
|
jobs: &'a mut JobsCache,
|
||||||
show_unread_indicator: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NoteResponse {
|
pub struct NoteResponse {
|
||||||
@@ -89,13 +87,9 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
note_context: &'a mut NoteContext<'d>,
|
note_context: &'a mut NoteContext<'d>,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
mut flags: NoteOptions,
|
flags: NoteOptions,
|
||||||
jobs: &'a mut JobsCache,
|
jobs: &'a mut JobsCache,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
flags.set(NoteOptions::ActionBar, true);
|
|
||||||
flags.set(NoteOptions::HasNotePreviews, true);
|
|
||||||
|
|
||||||
let framed = false;
|
|
||||||
let parent: Option<NoteKey> = None;
|
let parent: Option<NoteKey> = None;
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@@ -103,9 +97,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
parent,
|
parent,
|
||||||
note,
|
note,
|
||||||
flags,
|
flags,
|
||||||
framed,
|
|
||||||
jobs,
|
jobs,
|
||||||
show_unread_indicator: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,91 +110,121 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
.options_button(true)
|
.options_button(true)
|
||||||
.is_preview(true)
|
.is_preview(true)
|
||||||
.full_date(false)
|
.full_date(false)
|
||||||
|
.client_name(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn selected_style(self, selected: bool) -> Self {
|
||||||
|
self.wide(selected)
|
||||||
|
.full_date(selected)
|
||||||
|
.client_name(selected)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn textmode(mut self, enable: bool) -> Self {
|
pub fn textmode(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::Textmode, enable);
|
self.options_mut().set(NoteOptions::Textmode, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn client_name(mut self, enable: bool) -> Self {
|
||||||
|
self.options_mut().set(NoteOptions::ClientName, enable);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn full_date(mut self, enable: bool) -> Self {
|
pub fn full_date(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::FullCreatedDate, enable);
|
self.options_mut().set(NoteOptions::FullCreatedDate, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn actionbar(mut self, enable: bool) -> Self {
|
pub fn actionbar(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::ActionBar, enable);
|
self.options_mut().set(NoteOptions::ActionBar, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hide_media(mut self, enable: bool) -> Self {
|
pub fn hide_media(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::HideMedia, enable);
|
self.options_mut().set(NoteOptions::HideMedia, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn frame(mut self, enable: bool) -> Self {
|
pub fn frame(mut self, enable: bool) -> Self {
|
||||||
self.framed = enable;
|
self.options_mut().set(NoteOptions::Framed, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn truncate(mut self, enable: bool) -> Self {
|
pub fn truncate(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::Truncate, enable);
|
self.options_mut().set(NoteOptions::Truncate, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn small_pfp(mut self, enable: bool) -> Self {
|
pub fn small_pfp(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::SmallPfp, enable);
|
self.options_mut().set(NoteOptions::SmallPfp, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn medium_pfp(mut self, enable: bool) -> Self {
|
pub fn medium_pfp(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::MediumPfp, enable);
|
self.options_mut().set(NoteOptions::MediumPfp, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn note_previews(mut self, enable: bool) -> Self {
|
pub fn note_previews(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::HasNotePreviews, enable);
|
self.options_mut().set(NoteOptions::HasNotePreviews, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn selectable_text(mut self, enable: bool) -> Self {
|
pub fn selectable_text(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::SelectableText, enable);
|
self.options_mut().set(NoteOptions::SelectableText, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn wide(mut self, enable: bool) -> Self {
|
pub fn wide(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::Wide, enable);
|
self.options_mut().set(NoteOptions::Wide, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn options_button(mut self, enable: bool) -> Self {
|
pub fn options_button(mut self, enable: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::OptionsButton, enable);
|
self.options_mut().set(NoteOptions::OptionsButton, enable);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn unread_indicator(mut self, enable: bool) -> Self {
|
||||||
|
self.options_mut().set(NoteOptions::UnreadIndicator, enable);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn options(&self) -> NoteOptions {
|
pub fn options(&self) -> NoteOptions {
|
||||||
self.flags
|
self.flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn options_mut(&mut self) -> &mut NoteOptions {
|
pub fn options_mut(&mut self) -> &mut NoteOptions {
|
||||||
&mut self.flags
|
&mut self.flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn parent(mut self, parent: NoteKey) -> Self {
|
pub fn parent(mut self, parent: NoteKey) -> Self {
|
||||||
self.parent = Some(parent);
|
self.parent = Some(parent);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn is_preview(mut self, is_preview: bool) -> Self {
|
pub fn is_preview(mut self, is_preview: bool) -> Self {
|
||||||
self.options_mut().set(NoteOptions::IsPreview, is_preview);
|
self.options_mut().set(NoteOptions::IsPreview, is_preview);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unread_indicator(mut self, show_unread_indicator: bool) -> Self {
|
|
||||||
self.show_unread_indicator = show_unread_indicator;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textmode_ui(&mut self, ui: &mut egui::Ui) -> egui::Response {
|
fn textmode_ui(&mut self, ui: &mut egui::Ui) -> egui::Response {
|
||||||
let txn = self.note.txn().expect("todo: implement non-db notes");
|
let txn = self.note.txn().expect("todo: implement non-db notes");
|
||||||
|
|
||||||
@@ -340,7 +362,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
pub fn show(&mut self, ui: &mut egui::Ui) -> NoteResponse {
|
pub fn show(&mut self, ui: &mut egui::Ui) -> NoteResponse {
|
||||||
if self.options().contains(NoteOptions::Textmode) {
|
if self.options().contains(NoteOptions::Textmode) {
|
||||||
NoteResponse::new(self.textmode_ui(ui))
|
NoteResponse::new(self.textmode_ui(ui))
|
||||||
} else if self.framed {
|
} else if self.options().contains(NoteOptions::Framed) {
|
||||||
egui::Frame::new()
|
egui::Frame::new()
|
||||||
.fill(ui.visuals().noninteractive().weak_bg_fill)
|
.fill(ui.visuals().noninteractive().weak_bg_fill)
|
||||||
.inner_margin(egui::Margin::same(8))
|
.inner_margin(egui::Margin::same(8))
|
||||||
@@ -368,7 +390,6 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
i18n: &mut Localization,
|
i18n: &mut Localization,
|
||||||
note: &Note,
|
note: &Note,
|
||||||
profile: &Result<nostrdb::ProfileRecord<'_>, nostrdb::Error>,
|
profile: &Result<nostrdb::ProfileRecord<'_>, nostrdb::Error>,
|
||||||
show_unread_indicator: bool,
|
|
||||||
flags: NoteOptions,
|
flags: NoteOptions,
|
||||||
) {
|
) {
|
||||||
let horiz_resp = ui
|
let horiz_resp = ui
|
||||||
@@ -383,19 +404,17 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
})
|
})
|
||||||
.response;
|
.response;
|
||||||
|
|
||||||
if !show_unread_indicator {
|
if flags.contains(NoteOptions::UnreadIndicator) {
|
||||||
return;
|
let radius = 4.0;
|
||||||
|
let circle_center = {
|
||||||
|
let mut center = horiz_resp.rect.right_center();
|
||||||
|
center.x += radius + 4.0;
|
||||||
|
center
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.painter()
|
||||||
|
.circle_filled(circle_center, radius, crate::colors::PINK);
|
||||||
}
|
}
|
||||||
|
|
||||||
let radius = 4.0;
|
|
||||||
let circle_center = {
|
|
||||||
let mut center = horiz_resp.rect.right_center();
|
|
||||||
center.x += radius + 4.0;
|
|
||||||
center
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.painter()
|
|
||||||
.circle_filled(circle_center, radius, crate::colors::PINK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wide_ui(
|
fn wide_ui(
|
||||||
@@ -426,7 +445,6 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
self.note_context.i18n,
|
self.note_context.i18n,
|
||||||
self.note,
|
self.note,
|
||||||
profile,
|
profile,
|
||||||
self.show_unread_indicator,
|
|
||||||
self.flags,
|
self.flags,
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@@ -515,14 +533,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
let mut note_action: Option<NoteAction> = pfp_resp.into_action(self.note.pubkey());
|
let mut note_action: Option<NoteAction> = pfp_resp.into_action(self.note.pubkey());
|
||||||
|
|
||||||
ui.with_layout(egui::Layout::top_down(egui::Align::LEFT), |ui| {
|
ui.with_layout(egui::Layout::top_down(egui::Align::LEFT), |ui| {
|
||||||
NoteView::note_header(
|
NoteView::note_header(ui, self.note_context.i18n, self.note, profile, self.flags);
|
||||||
ui,
|
|
||||||
self.note_context.i18n,
|
|
||||||
self.note,
|
|
||||||
profile,
|
|
||||||
self.show_unread_indicator,
|
|
||||||
self.flags,
|
|
||||||
);
|
|
||||||
|
|
||||||
ui.horizontal_wrapped(|ui| 's: {
|
ui.horizontal_wrapped(|ui| 's: {
|
||||||
ui.spacing_mut().item_spacing.x = if is_narrow(ui.ctx()) { 1.0 } else { 2.0 };
|
ui.spacing_mut().item_spacing.x = if is_narrow(ui.ctx()) { 1.0 } else { 2.0 };
|
||||||
|
|||||||
@@ -23,13 +23,18 @@ bitflags! {
|
|||||||
/// will end with a ... and a "Show more" button.
|
/// will end with a ... and a "Show more" button.
|
||||||
const Truncate = 1 << 11;
|
const Truncate = 1 << 11;
|
||||||
/// Show note's client in the note content
|
/// Show note's client in the note content
|
||||||
const ClientNameTop = 1 << 12;
|
const ClientName = 1 << 12;
|
||||||
const ClientNameBottom = 1 << 13;
|
|
||||||
|
|
||||||
const RepliesNewestFirst = 1 << 14;
|
const RepliesNewestFirst = 1 << 13;
|
||||||
|
|
||||||
/// Show note's full created at date at the bottom
|
/// Show note's full created at date at the bottom
|
||||||
const FullCreatedDate = 1 << 15;
|
const FullCreatedDate = 1 << 14;
|
||||||
|
|
||||||
|
/// Note has a framed border
|
||||||
|
const Framed = 1 << 15;
|
||||||
|
|
||||||
|
/// Note has a framed border
|
||||||
|
const UnreadIndicator = 1 << 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user