[Proposal] StateLayout
See original GitHub issueStateLayout
- Proposed
- Prototype
- Implementation
- iOS Support
- Android Support
- macOS Support
- Windows Support
- Unit Tests
- Sample
- Documentation: https://github.com/MicrosoftDocs/CommunityToolkit/pull/155
Summary
Displaying a specific view when your app is in a specific state is a common pattern throughout any mobile app. Examples range from creating loading views to overlay on the screen, or on a subsection of the screen. Empty state views can be created for when there’s no data to display, and error state views can be displayed when an error occurs.
Detailed Design
StateLayout.shared.cs
public static class StateLayout
{
public static readonly BindableProperty StateViewsProperty;
public static readonly BindableProperty CurrentStateProperty;
public static readonly BindableProperty CurrentCustomStateKeyProperty;
public static readonly BindableProperty AnimateStateChangesProperty;
public static IList<StateView>? GetStateViews(BindableObject b);
public static void SetCurrentState(BindableObject b, LayoutState value);
public static LayoutState GetCurrentState(BindableObject b);
public static void SetCurrentCustomStateKey(BindableObject b, string value);
public static string? GetCurrentCustomStateKey(BindableObject b);
public static void SetAnimateStateChanges(BindableObject b, bool value);
public static bool GetAnimateStateChanges(BindableObject b);
}
Usage Syntax
XAML Usage
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
x:Class="MyLittleApp.MainPage">
<Grid xct:StateLayout.CurrentState="{Binding CurrentState}">
<xct:StateLayout.StateViews>
<xct:StateView StateKey="Loading">
<Grid BackgroundColor="White">
<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
<ActivityIndicator Color="#1abc9c" />
<Label Text="Loading..." HorizontalOptions="Center" />
</StackLayout>
</Grid>
</xct:StateView>
</xct:StateLayout.StateViews>
...
</Grid>
</ContentPage>
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:28 (16 by maintainers)
Top Results From Across the Web
StateLayout is a simple-use Android layout library which ...
StateLayout is a simple-use Android layout library which handles Loading, Content and Error/Info states for the activity/fragment/view. This library is ...
Read more >[Spec] StateLayout · Issue #275 · xamarin/ ...
StateLayout Displaying items when your app is in a specific state is a common pattern throughout any mobile app.
Read more >Xamarin Community Toolkit StateLayout
The StateLayout control enables the user to turn any layout element like a Grid or StackLayout into an individual state-aware element.
Read more >My proposed new state layout for the USA
I like the idea of all airports being in the same area, would make it much simpler and flights would be much shorter...
Read more >STATEMAP Proposal Preparation Webinar
STATEMAP Proposal Preparation Webinar. By National Cooperative Geologic Mapping Program September 26, 2019.
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
Hey @developer9969, Addressing your comments…
I’m 10000000% sure that you can do a great job! I mean, if my code pass the review process anyone can do it as well, and better!
Devs that contributed to this project (during the Xamarin era and now) are still contributing. Devs that donate their feature to us will not create new ones, and still, give us some help improving those features. I’ve no idea why devs want to create their own libs instead of adding those here, maybe they want to rule their releases and how the project goes (?). IMHO this isn’t a bad thing, I really love to see that we aren’t the only lib that provides great components for .NET MAUI.
I agree with this, but this is just part of the picture. So let me expand this a little bit… Yeah, our process now is slower and “bureaucratic” (not sure if this is the best word to describe it), but with this process, we could improve our quality at the highest level. On XCT our docs suck, just a few of our features have docs and that is terrible for new users. Now we make sure to write docs before merging any PR, we demand unit tests (when it’s possible), we have just a few bugs opened and we can track and fix them much more quickly than before. And as you mentioned we do this in our free time (as core team members) and we have soo much responsibility. So we need to review PRs, guide new contributors, review/write docs, triage issues, and do the Standup. And after all, we need to fix bugs and port the features from XCT to here. I mean, we love what we do, but it’s a lot of work and if we don’t have the community helping us we will take a lot of time to port everything from XCT with the most high quality. So at the end of the day, having this process helps us to keep track of all features and make sure everything is in place to provide an amazing package to everyone in the community.
Please do that, and help us to improve this package!
any news about this?