Replies: 3 comments
-
For Snackbar, it seems we could implement it by creating a |
Beta Was this translation helpful? Give feedback.
-
I found code like ToastEffect, and it would be helpful to learn about how to use it. |
Beta Was this translation helpful? Give feedback.
-
Both UiMessage in tivi and UserMessage in Droidkaigi (Which use Rin instead of Circuit) demonstrate approaches for handling Snackbar, but these approaches seem somewhat complicated. It would be helpful to learn about simple methods, and furthermore, discuss ways to implement event handling that has Android platform dependencies." |
Beta Was this translation helpful? Give feedback.
-
Hello, I have a question about the best practice for handling Toast and Snackbar in Circuit.
In the CatchUp project, I noticed the following approach in the codebase:
In SettingsPresenter, Snackbar is directly handled in the Presenter:
By examining the code in project, I confirmed that injecting ApplicationContext into a Presenter does not pose a problem.
If handling UiEvent directly in the Presenter is not aligned with Circuit's patterns, as suggested by the Snackbar code comments, would this implementation be appropriate?
In
SettingsScreen
In
SettingsUi
In the case of Snackbar, since it requires connecting the snackbarHostState to the SnackbarHost Composable function located within the screen (UI), I devised the above method because it was not possible to call it directly from within the Presenter.
In the project below, I'm using the above method, and we were able to verify that the Snackbar is being called normally.
HomeScreen In Bandalart
In the case of using
intent.startActivity
, I found that navigation can be indirectly handled by utilizing methods likerememberAndroidScreenAwareNavigator
, instead of directly calling it from the Presenter.Which approach would be the recommended way to handle Toast and Snackbar in Circuit? Should we avoid handling UIEvent directly in the Presenter?(Furthermore, Include other cases of events with Android platform dependencies)
Thanks for your guidance!
Beta Was this translation helpful? Give feedback.
All reactions