Files
notedeck/crates/notedeck_ui/src/note/options.rs
William Casarin ad35547582 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>
2025-08-03 16:16:15 -07:00

67 lines
2.0 KiB
Rust

use crate::ProfilePic;
use bitflags::bitflags;
bitflags! {
// Attributes can be applied to flags types
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NoteOptions: u64 {
const ActionBar = 1 << 0;
const HasNotePreviews = 1 << 1;
const SmallPfp = 1 << 2;
const MediumPfp = 1 << 3;
const Wide = 1 << 4;
const SelectableText = 1 << 5;
const Textmode = 1 << 6;
const OptionsButton = 1 << 7;
const HideMedia = 1 << 8;
/// Scramble text so that its not distracting during development
const ScrambleText = 1 << 9;
/// Is this a note preview?
const IsPreview = 1 << 10;
/// Is the content truncated? If the length is over a certain size it
/// will end with a ... and a "Show more" button.
const Truncate = 1 << 11;
/// Show note's client in the note content
const ClientName = 1 << 12;
const RepliesNewestFirst = 1 << 13;
/// Show note's full created at date at the bottom
const FullCreatedDate = 1 << 14;
/// Note has a framed border
const Framed = 1 << 15;
/// Note has a framed border
const UnreadIndicator = 1 << 16;
}
}
impl Default for NoteOptions {
fn default() -> NoteOptions {
NoteOptions::OptionsButton
| NoteOptions::HasNotePreviews
| NoteOptions::ActionBar
| NoteOptions::Truncate
}
}
impl NoteOptions {
pub fn new(is_universe_timeline: bool) -> Self {
let mut options = NoteOptions::default();
options.set(NoteOptions::HideMedia, is_universe_timeline);
options
}
pub fn pfp_size(&self) -> i8 {
if self.contains(NoteOptions::SmallPfp) {
ProfilePic::small_size()
} else if self.contains(NoteOptions::MediumPfp) {
ProfilePic::medium_size()
} else {
ProfilePic::default_size()
}
}
}