Skip to content

Commit

Permalink
Merge branch 'main' into feat/unified-colors-theming
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 authored Sep 27, 2024
2 parents 8b09791 + 25b3912 commit 8ce58d4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
4 changes: 4 additions & 0 deletions book/src/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ sudo dnf install openssl-devel pkgconf cmake gtk3-devel clang-devel -y
sudo dnf groupinstall "Development Tools" "C Development Tools and Libraries" -y
```

#### NixOS

Copy this [flake.nix](https://github.com/kuba375/freya-flake) into your project root. Then you can enter a dev shell by `nix develop`.

Don't hesitate to contribute so other distros can be added here.

### MacOS
Expand Down
10 changes: 5 additions & 5 deletions crates/components/src/snackbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use freya_hooks::{
/// ```no_run
/// # use freya::prelude::*;
/// fn app() -> Element {
/// let mut show = use_signal(|| false);
/// let mut open = use_signal(|| false);
///
/// rsx!(
/// rect {
Expand All @@ -31,7 +31,7 @@ use freya_hooks::{
/// label { "Open" }
/// }
/// SnackBar {
/// show,
/// open,
/// label {
/// "Hello, World!"
/// }
Expand All @@ -45,8 +45,8 @@ use freya_hooks::{
pub fn SnackBar(
/// Inner children of the SnackBar.
children: Element,
/// Signal to show the snackbar or not.
show: ReadOnlySignal<bool>,
/// Open or not the SnackBar. You can pass a [ReadOnlySignal] as well.
open: ReadOnlySignal<bool>,
/// Theme override.
theme: Option<SnackBarThemeWith>,
) -> Element {
Expand All @@ -60,7 +60,7 @@ pub fn SnackBar(
});

use_effect(move || {
if *show.read() {
if open() {
animation.start();
} else if animation.peek_has_run_yet() {
animation.reverse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Control how the inner elements are positioned inside the element. You can combine it with the `direction` attribute to create complex flows.

Accepted values for both attributes are:
Accepted values for `main_align`:

- `start` (default): At the begining of the axis
- `center`: At the center of the axis
Expand All @@ -11,6 +11,12 @@ Accepted values for both attributes are:
- `space-around` (only for `main_align`): Distributed among the available space with small margins in the sides
- `space-evenly` (only for `main_align`): Distributed among the available space with the same size of margins in the sides and in between the elements.

Accepted values for `cross_align`:

- `start` (default): At the begining of the axis (same as in `main_align`)
- `center`: At the center of the axis (same as in `main_align`)
- `end`: At the end of the axis (same as in `main_align`)

When using the `vertical` direction, `main_align` will be the Y axis and `cross_align` will be the X axis. But when using the `horizontal` direction, the
`main_align` will be the X axis and the `cross_align` will be the Y axis.

Expand Down
4 changes: 3 additions & 1 deletion crates/renderer/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,10 @@ impl<'a, State: Clone> ApplicationHandler<EventMessage> for DesktopRenderer<'a,
app.resize(window);
window.request_redraw();
}
EventMessage::InvalidateArea(area) => {
EventMessage::InvalidateArea(mut area) => {
let fdom = app.sdom.get();
let sf = window.scale_factor() as f32;
area.size *= sf;
let mut compositor_dirty_area = fdom.compositor_dirty_area();
compositor_dirty_area.unite_or_insert(&area)
}
Expand Down
10 changes: 5 additions & 5 deletions examples/snackbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ fn app() -> Element {
let animation = use_animation(move |ctx| {
ctx.with(
AnimNum::new(0., 100.)
.time(1650)
.time(1850)
.ease(Ease::Out)
.function(Function::Sine),
)
});
let progress = animation.get().read().as_f32();
let mut show = use_signal(|| false);
let mut open = use_signal(|| false);

rsx!(
rect {
Expand All @@ -30,8 +30,8 @@ fn app() -> Element {
direction: "horizontal",
Button {
onpress: move |_| {
show.toggle();
if *show.read() {
open.toggle();
if open() {
animation.start();
} else {
animation.reset();
Expand All @@ -40,7 +40,7 @@ fn app() -> Element {
label { "Install" }
}
SnackBar {
show,
open,
ProgressBar {
show_progress: true,
progress: progress
Expand Down

0 comments on commit 8ce58d4

Please sign in to comment.