-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add Custom Toast Title #19
Conversation
Added custom (optional) title for toast, this is needed for situations where localization is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left one comment title validation. I'm happy to merge if you make a suggested change. Thank you!
@@ -151,7 +152,7 @@ class MotionToast { | |||
successToastColor | |||
) | |||
) | |||
layout.custom_toast_text.text = TOAST_SUCCESS | |||
layout.custom_toast_text.text = if(title == null) TOAST_SUCCESS else title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @NotNotMarshall, Thanks for making a PR. It looks good to me. It will be better if we use this approach.
Instead of checking title == null
, we can use the extension function title.isNullOrBlank()
Sample code:
layout.custom_toast_text.text = if(title.isNullOrBlank()) TOAST_SUCCESS else title
Reason for this approach 👇
title = " " // title with blank space
println(data.isNullOrBlank()?.toString()) //true
println(data.isNullOrEmpty()?.toString()) //false
Can you please make a change in all states like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done mate! ^_^
changed title == null check to title.isNullOrBlank()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!. Will merge asap 👍
Added custom (optional) title for toast, this is needed for situations where localization is used.