cargo fmt

This commit is contained in:
Mike Dilger 2023-12-19 12:59:32 +13:00
parent e8615f1dc6
commit f23a0a22b1
5 changed files with 22 additions and 50 deletions

View File

@ -1,5 +1,5 @@
use super::theme::FeedProperties;
use super::{GossipUi, Page, widgets};
use super::{widgets, GossipUi, Page};
use eframe::egui;
use egui::{Context, Frame, RichText, Ui, Vec2};
use gossip_lib::FeedKind;
@ -87,12 +87,8 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
ui.add_space(10.0);
ui.label(RichText::new("Include replies").size(11.0));
let size = ui.spacing().interact_size.y * egui::vec2(1.6, 0.8);
if widgets::switch_with_size(
ui,
&mut app.mainfeed_include_nonroot,
size,
)
.clicked()
if widgets::switch_with_size(ui, &mut app.mainfeed_include_nonroot, size)
.clicked()
{
app.set_page(
ctx,
@ -137,12 +133,8 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
ui.add_space(10.0);
ui.label(RichText::new("Everything").size(11.0));
let size = ui.spacing().interact_size.y * egui::vec2(1.6, 0.8);
if widgets::switch_with_size(
ui,
&mut app.inbox_include_indirect,
size,
)
.clicked()
if widgets::switch_with_size(ui, &mut app.inbox_include_indirect, size)
.clicked()
{
app.set_page(
ctx,

View File

@ -123,14 +123,18 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
ui.vertical(|ui| {
ui.heading("New List");
ui.add_space(10.0);
let response = ui.add(text_edit_line!(app, app.new_list_name).hint_text("list name"));
let response =
ui.add(text_edit_line!(app, app.new_list_name).hint_text("list name"));
if app.creating_list_first_run {
response.request_focus();
app.creating_list_first_run = false;
}
ui.add_space(10.0);
ui.horizontal(|ui| {
ui.add(widgets::Switch::onoff(&app.theme, &mut app.new_list_favorite));
ui.add(widgets::Switch::onoff(
&app.theme,
&mut app.new_list_favorite,
));
ui.label("Favorite");
});
ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| {

View File

@ -454,26 +454,14 @@ pub(super) fn configure_list_btn(app: &mut GossipUi, ui: &mut Ui) {
let size = ui.spacing().interact_size.y * egui::vec2(1.6, 0.8);
ui.horizontal(|ui| {
if widgets::switch_with_size(
ui,
&mut app.relays.show_details,
size,
)
.changed()
{
if widgets::switch_with_size(ui, &mut app.relays.show_details, size).changed() {
*is_open = false;
}
ui.label("Show details");
});
ui.add_space(8.0);
ui.horizontal(|ui| {
if widgets::switch_with_size(
ui,
&mut app.relays.show_hidden,
size,
)
.changed()
{
if widgets::switch_with_size(ui, &mut app.relays.show_hidden, size).changed() {
*is_open = false;
}
ui.label("Show hidden relays");

View File

@ -28,7 +28,7 @@ pub use information_popup::ProfilePopup;
mod switch;
pub use switch::Switch;
pub use switch::{switch_custom_at, switch_with_size, switch_simple, switch_with_size_at};
pub use switch::{switch_custom_at, switch_simple, switch_with_size, switch_with_size_at};
use super::GossipUi;

View File

@ -1,4 +1,4 @@
use egui_winit::egui::{Ui, self, Id, Response, Rect, Widget, Color32, Stroke, vec2, Vec2};
use egui_winit::egui::{self, vec2, Color32, Id, Rect, Response, Stroke, Ui, Vec2, Widget};
use crate::ui::Theme;
@ -38,14 +38,16 @@ impl<'a> Widget for Switch<'a> {
fn ui(self, ui: &mut Ui) -> Response {
let (rect, _) = ui.allocate_exact_size(self.size, egui::Sense::hover());
let id = ui.next_auto_id();
switch_custom_at(ui,
switch_custom_at(
ui,
ui.is_enabled(),
self.value,
rect,
id,
self.knob_fill,
self.on_fill,
self.off_fill)
self.off_fill,
)
}
}
@ -62,15 +64,7 @@ pub fn switch_with_size_at(
id: Id,
) -> Response {
let rect = Rect::from_min_size(pos, size);
switch_custom_at(
ui,
ui.is_enabled(),
value,
rect,
id,
None,
None,
None)
switch_custom_at(ui, ui.is_enabled(), value, rect, id, None, None, None)
}
pub fn switch_simple(ui: &mut Ui, on: bool) -> Response {
@ -79,14 +73,8 @@ pub fn switch_simple(ui: &mut Ui, on: bool) -> Response {
let rect = Rect::from_min_size(rect.left_top(), size);
let id = ui.next_auto_id();
let mut value = on;
let mut response = switch_custom_at(ui,
ui.is_enabled(),
&mut value,
rect,
id,
None,
None,
None);
let mut response =
switch_custom_at(ui, ui.is_enabled(), &mut value, rect, id, None, None, None);
if value != on {
response.mark_changed();
}