fix: format code
This commit is contained in:
1 parent
a0ffe66a37
commit
e4eb982a36
2 files changed
+10
-18
No files matched your search
+4
-10
@@ -1,4 +1,4 @@
|
|||||||
use dioxus::{events::onmousedown, prelude::*};
|
use dioxus::prelude::*;
|
||||||
use dioxus_desktop::desktop_context::DesktopContext;
|
use dioxus_desktop::desktop_context::DesktopContext;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -12,11 +12,10 @@ fn app(cx: Scope) -> Element {
|
|||||||
|
|
||||||
let drag = desktop.clone();
|
let drag = desktop.clone();
|
||||||
let close = desktop.clone();
|
let close = desktop.clone();
|
||||||
let min = desktop.clone();
|
|
||||||
|
|
||||||
cx.render(rsx!(
|
cx.render(rsx!(
|
||||||
link { href:"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css", rel:"stylesheet" }
|
link { href:"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css", rel:"stylesheet" }
|
||||||
header {
|
header {
|
||||||
class: "text-gray-400 bg-gray-900 body-font",
|
class: "text-gray-400 bg-gray-900 body-font",
|
||||||
onmousedown: move |_| drag.drag_window(),
|
onmousedown: move |_| drag.drag_window(),
|
||||||
div {
|
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",
|
a { class: "flex title-font font-medium items-center text-white mb-4 md:mb-0",
|
||||||
span { class: "ml-3 text-xl", "Dioxus"}
|
span { class: "ml-3 text-xl", "Dioxus"}
|
||||||
}
|
}
|
||||||
nav { class: "md:ml-auto flex flex-wrap items-center text-base justify-center",
|
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"}
|
|
||||||
}
|
|
||||||
button {
|
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",
|
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(),
|
onmousedown: |evt| evt.cancel_bubble(),
|
||||||
onclick: move |_| min.minimize(true),
|
onclick: move |_| desktop.minimize(true),
|
||||||
"Minimize"
|
"Minimize"
|
||||||
}
|
}
|
||||||
button {
|
button {
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ use crate::UserWindowEvent;
|
|||||||
type ProxyType = EventLoopProxy<UserWindowEvent>;
|
type ProxyType = EventLoopProxy<UserWindowEvent>;
|
||||||
|
|
||||||
/// Desktop-Window handle api context
|
/// Desktop-Window handle api context
|
||||||
///
|
///
|
||||||
/// you can use this context control some window event
|
/// you can use this context control some window event
|
||||||
///
|
///
|
||||||
/// you can use `cx.consume_context::<DesktopContext>` to get this context
|
/// you can use `cx.consume_context::<DesktopContext>` to get this context
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// let desktop = cx.consume_context::<DesktopContext>().unwrap();
|
/// let desktop = cx.consume_context::<DesktopContext>().unwrap();
|
||||||
/// ```
|
/// ```
|
||||||
@@ -19,15 +19,14 @@ pub struct DesktopContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DesktopContext {
|
impl DesktopContext {
|
||||||
|
|
||||||
pub(crate) fn new(proxy: ProxyType) -> Self {
|
pub(crate) fn new(proxy: ProxyType) -> Self {
|
||||||
Self { proxy }
|
Self { proxy }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// trigger the drag-window event
|
/// trigger the drag-window event
|
||||||
///
|
///
|
||||||
/// Moves the window with the left mouse button until the button is released.
|
/// Moves the window with the left mouse button until the button is released.
|
||||||
///
|
///
|
||||||
/// you need use it in `onmousedown` event:
|
/// you need use it in `onmousedown` event:
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// onmousedown: move |_| { desktop.drag_window(); }
|
/// onmousedown: move |_| { desktop.drag_window(); }
|
||||||
@@ -50,5 +49,4 @@ impl DesktopContext {
|
|||||||
pub fn close(&self) {
|
pub fn close(&self) {
|
||||||
let _ = self.proxy.send_event(UserWindowEvent::CloseWindow);
|
let _ = self.proxy.send_event(UserWindowEvent::CloseWindow);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
Reference in new issue
Block a user