[Proposal] Snackbar
See original GitHub issueSnackbar
- Proposed
- Prototype
- Implementation
- iOS Support
- Android Support
- macOS Support
- Windows Support
- Unit Tests
- Sample
- Documentation: Not Started
Summary
Adds a snackbar.
It has to use Native Android Snackbar (Google.Android.Material.Snackbar
) internally.
All other platforms implement a default popup container with text and a button.
Detailed Design
Snackbar.shared.cs
namespace CommunityToolkit.Maui.Controls.Snackbar;
public class Snackbar : ISnackbar
{
Action Action { get; set; }
string ActionButtonText { get; set; }
IView? Anchor { get; set; }
TimeSpan Duration { get; set; }
bool IsShown { get; }
string Text { get; set; }
SnackbarOptions VisualOptions { get; set; }
event EventHandler? Dismissed;
event EventHandler<ShownEventArgs>? Shown;
Task Dismiss();
Task Show();
public static ISnackBar Make();
}
public interface Snackbar
{
Action Action { get; }
string ActionButtonText { get; }
IView? Anchor { get; }
TimeSpan Duration { get; }
bool IsShown { get; }
string Text { get; }
SnackbarOptions VisualOptions { get; }
event EventHandler? Dismissed;
event EventHandler<ShownEventArgs>? Shown;
Task Dismiss();
Task Show();
}
public class ShownEventArgs : EventArgs
{
public ShownEventArgs(bool isShown)
{
IsShown = isShown;
}
public bool IsShown { get; }
}
public class SnackbarOptions : ITextStyle
{
public double CharacterSpacing { get; set; } = 0.0d;
public Font Font { get; set; } = Font.SystemFontOfSize(14);
public Color TextColor { get; set; } = Colors.Black;
public Color ActionTextColor { get; set; } = Colors.Black;
public Color BackgroundColor { get; set; } = Colors.LightGray;
public CornerRadius CornerRadius { get; set; } = new CornerRadius(4, 4, 4, 4);
}
Visual with default settings
Android:
Issue Analytics
- State:
- Created 2 years ago
- Comments:34 (8 by maintainers)
Top Results From Across the Web
Request for Proposals for Snack Bar at City of Long Beach ...
The City is soliciting requests for proposals (RFP) to identify qualified vendors interested in operating the snack bar.
Read more >Proposals for Snack Bar Concession at Community Park.
Romanzo LLC offers a competitive Cost Proposal. NOTE: The Review Committee will review their findings and recommendations with the Township.
Read more >City issues RFP for the renovation and operation of ...
The Parks Department has issued a Request for Proposal (RFP) for "the renovation, operation and maintenance" of the snack bar at First Park....
Read more >RFP For Prospect Park Hoftsra Park Concession Stand 2- ...
SNACK BAR CONCESSION STAND. SEALED PROPOSALS MUST BE RECEIVED AT: Borough of Prospect Park. Attention: Intashan Chowdhury, Borough Administrator.
Read more >REQUEST FOR PROPOSAL - Queensbury Parks & Recreation
Concession/Snack Bar Proposals: Queensbury Parks & Recreation is soliciting proposals from foodservice operators to operate the Gurney. Lane Pool Snack Bar.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree with @VladislavAntonyuk.
Google.Android.Material.Snackbar
is a well-known UI control for Android developers andCommunityToolkit.Maui.UI.Views.Snackbar
invokes the expectations that our implementation uses the native Android control.I also recommend mimicking
Google.Android.Material.Snackbar
’s API surface + implementation for theCommunityToolkit.Maui
’sSnackbar
so that developers who are already familiar withGoogle.Android.Material.Snackbar
can use their existing knowledge.Leave a 👍 or 👎 on this comment if you agree/disagree.
I’m happy to update the
Detailed Design
section above to reflect this if we get more 👍 than 👎.You can implement the
set
in the concrete type, but the interface should be read-only… For example: theITextInput
has the MaxLenght property read-only.https://github.com/dotnet/maui/blob/main/src/Core/src/Core/ITextInput.cs#L31
The class that implements that interface also implements the set.
https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/InputView.cs#L31
But the
Text
property in that interface has theset
defined, that happens because you can change the Text value from the native platform (When user types). If I’m not wrong nothing on the native side can change snackbar values.