Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: toast widget #517

Merged
merged 7 commits into from
Jul 2, 2024
Merged

feat: toast widget #517

merged 7 commits into from
Jul 2, 2024

Conversation

wiiznokes
Copy link
Contributor

@wiiznokes wiiznokes commented Jun 27, 2024

Attempt to implement pop-os/cosmic-files#183

I implemented this feature in fan-control. You can see the change i needed to make in this commit.

The duration chosen comes from Android.

There is more just to match the Ui design, but the idea is there. I'm not sure i will implement it as i don't really know where to search for padding, colours, ect..

Capture d’écran du 2024-06-28 00-21-00

@wiiznokes wiiznokes marked this pull request as ready for review June 27, 2024 22:35
@wiiznokes
Copy link
Contributor Author

Should this be moved to core ?

src/widget/toaster/mod.rs Outdated Show resolved Hide resolved
src/widget/toaster/mod.rs Outdated Show resolved Hide resolved
tokio::time::sleep(duration).await;
},
|_| crate::app::Message::App(message.into()),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crate::command::future(async move {
    tokio::time::sleep(duration).await;
    Message::from(message)
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to write

crate::command::future(async move {
            tokio::time::sleep(duration).await;
            crate::app::Message::App(Message::from(message))
        })

@wiiznokes
Copy link
Contributor Author

So, should this be moved to core, like the navbar? @mmstick

@mmstick
Copy link
Member

mmstick commented Jun 29, 2024

Probably

@wiiznokes
Copy link
Contributor Author

With the current impl, it requires Core to be generic over Message, is it ok?

@mmstick
Copy link
Member

mmstick commented Jun 29, 2024

That kind of state should be in the app struct

@wiiznokes
Copy link
Contributor Author

wiiznokes commented Jun 29, 2024

The only idea i have is adding this function in the Application trait fn toast_message(&self, toats_id: u32) -> Message; but it leaks to toasts_id implementation details, and it force the user to keep track of his toasts.

Can you think of a better solution ? Maybe it will be preferable to not include in core afterall

@mmstick
Copy link
Member

mmstick commented Jul 1, 2024

I think it's fine for the app to store the model of the toaster. Similar to what it already does for other widgets.

@wiiznokes wiiznokes requested a review from mmstick July 1, 2024 19:47
src/widget/toaster/mod.rs Outdated Show resolved Hide resolved
src/widget/toaster/mod.rs Outdated Show resolved Hide resolved
src/widget/toaster/mod.rs Outdated Show resolved Hide resolved
src/widget/toaster/mod.rs Outdated Show resolved Hide resolved
@wiiznokes wiiznokes requested a review from mmstick July 2, 2024 15:54
@mmstick mmstick merged commit 4449b29 into pop-os:master Jul 2, 2024
2 of 3 checks passed
@mmstick
Copy link
Member

mmstick commented Jul 2, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants