question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Spec] Toast control

See original GitHub issue

Summary

A toaster view that appears on top of the presented page

API Changes

Add the toast control

e.g.

Some feature would be,

    Toaster.Current.FontSize = 13;
    Toaster.Current.TextColor = Color.White;
    Toaster.Current.BackgroundColor = Color.DodgerBlue;
    Toaster.Current.CornerRadius = 8;
    Toaster.Current.Padding = new Thickness(20, 10);
    Toaster.Current.PositionY = 30;
    Toaster.Current.AnimateFor = 500;
    Toaster.Current.HideToastIn = 5;
    Toaster.Current.LineBreakMode = LineBreakMode.TailTruncation;
    Toaster.Current.MaxLines = 1;

    ShowToastCommand = new Command(parameter =>
    {
        Toaster.Current.ToastAction = async () =>
        {
            await Toaster.Current.HideToaster();
        };
        Toaster.Current.Text = parameter.ToString();

        Toaster.Current.ShowToaster();
    });

Intended Use Case

To give users short information about service failures and other similar cases.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
ErlingMKcommented, Jul 30, 2020

Also can we allow adding shadows?

We should include a HasShadow property. For the implementation ; iOS ; bind the frame HasShadow to the same property. Android ; Set VisualElement.Elavation(https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/android/visualelement-elevation) when HasShadow is set

The ideal solution for shadows would be to not use frames. The frame shadow for iOS doesn’t look good at all. Both iOS and Android have platform specific solutions, but they don’t work with Xamarin.Forms frames out of the box.

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/ios/visualelement-drop-shadow <-- Tried using these with a frame before. The default HasShadow property overrides whatever you set here.

1reaction
rizanzakycommented, Jul 28, 2020

to make it simple, would go with this approach,

DisplayToast(string text, ToastOptions toastOptions = null, ToastLayout toastLayout = null);

class ToastOptions {
    Action ToastAction { get; set; }
    Func<ToastView, Task> DisplayAnimation { get; set; }
    Func<ToastView, Task> CloseAnimation { get; set; }
    int HideToastIn { get; set; }
}

class ToastLayout {
    Color BackgroundColor { get; set; }
    float CornerRadius { get; set; }
    string FontFamily { get; set; }
    double FontSize { get; set; }
    bool HasShadow { get; set; }
    LineBreakMode LineBreakMode { get; set; }
    int MaxLines { get; set; }
    Thickness Padding { get; set; }
    double PositionY { get; set; }
    Color TextColor { get; set; }
}

which will avoid conflicts for the properties as also discussed in the comments

Closing the toast would simply be,

CloseToast()

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toast Control - Minecraft Mods
This mod allows you to control what toasts show up in Minecraft. By default, Minecraft shows you all toasts, including toasts for Recipes,...
Read more >
Toast Control and No Recipe Book for Minecraft 1.12.2
Disable Toasts will full control in Minecraft 1.12.2. Toasts are pop up messages on the screen that show advancements and notifications ...
Read more >
Building a toast component - web.dev
A foundational overview of how to build an adaptive and accessible toast component.
Read more >
Toasts
A toast appears in reaction to user action: creating, editing, deleting. For example, a user edits an opportunity via a modal and saves...
Read more >
Toasts | Design for Driving
A toast is a short, informational message that an app displays briefly near the bottom of the screen. Only one toast can be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found