From e4eb982a367ed588b370e4a28e8cf2a94d0f4b24 Mon Sep 17 00:00:00 2001 From: mrxiaozhuox Date: Mon, 31 Jan 2022 10:11:58 +0800 Subject: [PATCH] fix: format code --- examples/borderless.rs | 14 ++++---------- packages/desktop/src/desktop_context.rs | 14 ++++++-------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/examples/borderless.rs b/examples/borderless.rs index 7f85ff22d..e6cd4eda1 100644 --- a/examples/borderless.rs +++ b/examples/borderless.rs @@ -1,4 +1,4 @@ -use dioxus::{events::onmousedown, prelude::*}; +use dioxus::prelude::*; use dioxus_desktop::desktop_context::DesktopContext; fn main() { @@ -12,11 +12,10 @@ fn app(cx: Scope) -> Element { let drag = desktop.clone(); let close = desktop.clone(); - let min = desktop.clone(); cx.render(rsx!( link { href:"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css", rel:"stylesheet" } - header { + header { class: "text-gray-400 bg-gray-900 body-font", onmousedown: move |_| drag.drag_window(), div { @@ -24,16 +23,11 @@ fn app(cx: Scope) -> Element { a { class: "flex title-font font-medium items-center text-white mb-4 md:mb-0", span { class: "ml-3 text-xl", "Dioxus"} } - nav { class: "md:ml-auto flex flex-wrap items-center text-base justify-center", - // a { class: "mr-5 hover:text-white", "First Link"} - // a { class: "mr-5 hover:text-white", "Second Link"} - // a { class: "mr-5 hover:text-white", "Third Link"} - // a { class: "mr-5 hover:text-white", "Fourth Link"} - } + nav { class: "md:ml-auto flex flex-wrap items-center text-base justify-center" } button { class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0", onmousedown: |evt| evt.cancel_bubble(), - onclick: move |_| min.minimize(true), + onclick: move |_| desktop.minimize(true), "Minimize" } button { diff --git a/packages/desktop/src/desktop_context.rs b/packages/desktop/src/desktop_context.rs index 456dba1c1..0a1fa2b02 100644 --- a/packages/desktop/src/desktop_context.rs +++ b/packages/desktop/src/desktop_context.rs @@ -5,11 +5,11 @@ use crate::UserWindowEvent; type ProxyType = EventLoopProxy; /// Desktop-Window handle api context -/// +/// /// you can use this context control some window event -/// +/// /// you can use `cx.consume_context::` to get this context -/// +/// /// ```rust /// let desktop = cx.consume_context::().unwrap(); /// ``` @@ -19,15 +19,14 @@ pub struct DesktopContext { } impl DesktopContext { - pub(crate) fn new(proxy: ProxyType) -> Self { Self { proxy } } /// trigger the drag-window event - /// + /// /// Moves the window with the left mouse button until the button is released. - /// + /// /// you need use it in `onmousedown` event: /// ```rust /// onmousedown: move |_| { desktop.drag_window(); } @@ -50,5 +49,4 @@ impl DesktopContext { pub fn close(&self) { let _ = self.proxy.send_event(UserWindowEvent::CloseWindow); } - -} \ No newline at end of file +}