mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-19 01:24:21 +01:00
move sized_button into ui/widgets as styled_button
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -2,8 +2,8 @@ use core::f32;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use egui::{
|
use egui::{
|
||||||
pos2, vec2, Align, Button, Color32, FontId, Id, ImageSource, Margin, Pos2, Rect, RichText,
|
pos2, vec2, Align, Color32, FontId, Id, ImageSource, Margin, Pos2, Rect, RichText, Separator,
|
||||||
Separator, Ui, Vec2, Widget,
|
Ui, Vec2, Widget,
|
||||||
};
|
};
|
||||||
use enostr::Pubkey;
|
use enostr::Pubkey;
|
||||||
use nostrdb::{Ndb, Transaction};
|
use nostrdb::{Ndb, Transaction};
|
||||||
@@ -20,7 +20,7 @@ use crate::{
|
|||||||
use notedeck::{AppContext, Images, NotedeckTextStyle, UserAccount};
|
use notedeck::{AppContext, Images, NotedeckTextStyle, UserAccount};
|
||||||
use tokenator::{ParseError, TokenParser, TokenSerializable, TokenWriter};
|
use tokenator::{ParseError, TokenParser, TokenSerializable, TokenWriter};
|
||||||
|
|
||||||
use super::{anim::AnimationHelper, padding, ProfilePreview};
|
use super::{anim::AnimationHelper, padding, widgets::styled_button, ProfilePreview};
|
||||||
|
|
||||||
pub enum AddColumnResponse {
|
pub enum AddColumnResponse {
|
||||||
Timeline(TimelineKind),
|
Timeline(TimelineKind),
|
||||||
@@ -554,30 +554,11 @@ impl<'a> AddColumnView<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn find_user_button() -> impl Widget {
|
fn find_user_button() -> impl Widget {
|
||||||
sized_button("Find User")
|
styled_button("Find User", crate::colors::PINK)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_column_button() -> impl Widget {
|
fn add_column_button() -> impl Widget {
|
||||||
sized_button("Add")
|
styled_button("Add", crate::colors::PINK)
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn sized_button(text: &str) -> impl Widget + '_ {
|
|
||||||
move |ui: &mut egui::Ui| -> egui::Response {
|
|
||||||
let painter = ui.painter();
|
|
||||||
let galley = painter.layout(
|
|
||||||
text.to_owned(),
|
|
||||||
NotedeckTextStyle::Body.get_font_id(ui.ctx()),
|
|
||||||
Color32::WHITE,
|
|
||||||
ui.available_width(),
|
|
||||||
);
|
|
||||||
|
|
||||||
ui.add_sized(
|
|
||||||
galley.rect.expand2(vec2(16.0, 8.0)).size(),
|
|
||||||
Button::new(galley)
|
|
||||||
.corner_radius(8.0)
|
|
||||||
.fill(crate::colors::PINK),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ColumnOptionData {
|
struct ColumnOptionData {
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ use notedeck::{Accounts, NotedeckTextStyle};
|
|||||||
|
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use super::add_column::sized_button;
|
|
||||||
use super::padding;
|
use super::padding;
|
||||||
|
use super::widgets::styled_button;
|
||||||
|
|
||||||
pub struct RelayView<'a> {
|
pub struct RelayView<'a> {
|
||||||
accounts: &'a mut Accounts,
|
accounts: &'a mut Accounts,
|
||||||
@@ -197,7 +197,7 @@ fn add_relay_button() -> Button<'static> {
|
|||||||
|
|
||||||
fn add_relay_button2(is_enabled: bool) -> impl egui::Widget + 'static {
|
fn add_relay_button2(is_enabled: bool) -> impl egui::Widget + 'static {
|
||||||
move |ui: &mut egui::Ui| -> egui::Response {
|
move |ui: &mut egui::Ui| -> egui::Response {
|
||||||
let button_widget = sized_button("Add");
|
let button_widget = styled_button("Add", crate::colors::PINK);
|
||||||
ui.add_enabled(is_enabled, button_widget)
|
ui.add_enabled(is_enabled, button_widget)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use egui::{emath::GuiRounding, Pos2, Stroke};
|
use egui::{emath::GuiRounding, Button, Pos2, Stroke, Widget};
|
||||||
|
use notedeck::NotedeckTextStyle;
|
||||||
|
|
||||||
use super::anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE};
|
use super::anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE};
|
||||||
|
|
||||||
@@ -34,3 +35,27 @@ pub fn x_button(rect: egui::Rect) -> impl egui::Widget {
|
|||||||
helper.take_animation_response()
|
helper.take_animation_response()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sized and styled to match the figma design
|
||||||
|
pub fn styled_button(text: &str, fill_color: egui::Color32) -> impl Widget + '_ {
|
||||||
|
move |ui: &mut egui::Ui| -> egui::Response {
|
||||||
|
let painter = ui.painter();
|
||||||
|
let text_color = if ui.visuals().dark_mode {
|
||||||
|
egui::Color32::WHITE
|
||||||
|
} else {
|
||||||
|
egui::Color32::BLACK
|
||||||
|
};
|
||||||
|
|
||||||
|
let galley = painter.layout(
|
||||||
|
text.to_owned(),
|
||||||
|
NotedeckTextStyle::Body.get_font_id(ui.ctx()),
|
||||||
|
text_color,
|
||||||
|
ui.available_width(),
|
||||||
|
);
|
||||||
|
|
||||||
|
ui.add_sized(
|
||||||
|
galley.rect.expand2(egui::vec2(16.0, 8.0)).size(),
|
||||||
|
Button::new(galley).corner_radius(8.0).fill(fill_color),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user