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

Add Custom Toast Title #19

Merged
merged 2 commits into from
Nov 2, 2020
Merged

Add Custom Toast Title #19

merged 2 commits into from
Nov 2, 2020

Conversation

XiXiongMaoXiong
Copy link
Contributor

Added custom (optional) title for toast, this is needed for situations where localization is used.

Added custom (optional) title for toast, this is needed for situations where localization is used.
Copy link
Owner

@Spikeysanju Spikeysanju left a 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
Copy link
Owner

@Spikeysanju Spikeysanju Oct 25, 2020

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done mate! ^_^

@Spikeysanju Spikeysanju added the enhancement New feature or request label Oct 25, 2020
@Spikeysanju Spikeysanju linked an issue Oct 26, 2020 that may be closed by this pull request
@Spikeysanju Spikeysanju changed the title Custom toast title Add Custom Toast Title Oct 26, 2020
changed title == null check to title.isNullOrBlank()
Copy link
Owner

@Spikeysanju Spikeysanju left a 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 👍

@Spikeysanju Spikeysanju merged commit 844fe35 into Spikeysanju:master Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Localized String for toast title
2 participants