-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Implement loading control with sample. #247
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
Changes from 39 commits
bcc05a4
ebd9cce
8836f88
732f0c5
f689df8
002dcff
fa49e92
6148fd1
69697dc
82a7140
75db927
1ebf5d2
601fc9d
84f2bd7
b58aca4
f29401d
e79c07f
5da6ea1
0c6c077
0c2c7d3
4224209
491f2b9
5a94a19
e3c6e22
8dbd4cc
6a88090
dd06da0
7ae1949
a1e170f
ee2c4e8
033716c
1f0a6a4
c45a336
26174a5
dd13fc1
ddedd7d
7585cca
06e9ccb
13aa821
cf09a0b
195a3c1
f78a6a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| <Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.LoadingPage" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
| mc:Ignorable="d"> | ||
|
|
||
| <Page.Resources> | ||
| <ResourceDictionary> | ||
| <DataTemplate x:Key="WaitListTemplate"> | ||
| <StackPanel Orientation="Horizontal" Padding="12"> | ||
| <ProgressRing IsActive="True" Margin="0,0,12,0" Foreground="{StaticResource Brush-Blue-01}" /> | ||
| <TextBlock Text="Loading control with wait ring" VerticalAlignment="Center" /> | ||
| </StackPanel> | ||
| </DataTemplate> | ||
| <DataTemplate x:Key="ProgressBarTemplate"> | ||
| <ProgressBar IsIndeterminate="True" Width="{Binding ElementName=PageName, Path=ActualWidth}" | ||
| Foreground="{StaticResource Brush-Grey-04}" /> | ||
| </DataTemplate> | ||
| <DataTemplate x:Key="LogoTemplate"> | ||
| <StackPanel Orientation="Horizontal" Padding="12"> | ||
| <Image Source="../../Assets/ToolkitLogo.png" Height="50" Margin="0,0,12,0" /> | ||
| <TextBlock Text="Loading control with logo" VerticalAlignment="Center" /> | ||
| </StackPanel> | ||
| </DataTemplate> | ||
|
|
||
| <DataTemplate x:Key="PhotosTemplate"> | ||
| <Grid Background="White" BorderBrush="Black" BorderThickness="1"> | ||
| <Image Source="{Binding Thumbnail}" | ||
| Stretch="UniformToFill" | ||
| HorizontalAlignment="Center" | ||
| VerticalAlignment="Center" /> | ||
| </Grid> | ||
| </DataTemplate> | ||
| </ResourceDictionary> | ||
| </Page.Resources> | ||
|
|
||
| <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
|
||
| <ScrollViewer> | ||
| <StackPanel Margin="20"> | ||
| <RichTextBlock Margin="0,10,0,0" Foreground="{StaticResource Brush-Grey-03}"> | ||
| <Paragraph FontSize="18" FontWeight="Bold">The loading control is for showing an animation with some content when the user should wait in some tasks of the app.</Paragraph> | ||
| <Paragraph /> | ||
| <Paragraph>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</Paragraph> | ||
| <Paragraph /> | ||
| <Paragraph>Expetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.</Paragraph> | ||
| <Paragraph /> | ||
| <Paragraph>His audiam deserunt in, eum ubique voluptatibus te. In reque dicta usu. Ne rebum dissentiet eam, vim omnis deseruisse id. Ullum deleniti vituperata at quo, insolens complectitur te eos, ea pri dico munere propriae. Vel ferri facilis ut, qui paulo ridens praesent ad. Possim alterum qui cu. Accusamus consulatu ius te, cu decore soleat appareat usu.</Paragraph> | ||
| </RichTextBlock> | ||
|
|
||
| <controls:AdaptiveGridView | ||
| Margin="0,12,0,0" | ||
| x:Name="AdaptiveGridViewControl" | ||
| ItemHeight="200" | ||
| DesiredWidth="300" | ||
| SelectionMode="None" | ||
| IsItemClickEnabled="False" | ||
| ItemTemplate="{StaticResource PhotosTemplate}" /> | ||
|
|
||
| </StackPanel> | ||
| </ScrollViewer> | ||
|
|
||
| <controls:Loading x:Name="LoadingControl" HorizontalContentAlignment="@[HorizontalContentAlignment:Enum:HorizontalAlignment.Center:Left.Right.Center.Stretch]" | ||
| VerticalContentAlignment="@[VerticalContentAlignment:Enum:VerticalAlignment.Center:Stretch.Center.Top.Bottom]" | ||
| Background="@[Background:Brush:CadetBlue]" Opacity="@[Opacity:DoubleSlider:0.75:0-1]"> | ||
| <ContentControl x:Name="LoadingContentControl"/> | ||
| </controls:Loading> | ||
| </Grid> | ||
| </Page> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <Page x:Name="PageName" | ||
| x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.LoadingPage" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
| mc:Ignorable="d"> | ||
|
|
||
| <Page.Resources> | ||
| <ResourceDictionary> | ||
| <DataTemplate x:Key="WaitListTemplate"> | ||
| <StackPanel Orientation="Horizontal" Padding="12"> | ||
| <ProgressRing IsActive="True" Margin="0,0,12,0" Foreground="{StaticResource Brush-Blue-01}" /> | ||
| <TextBlock Text="Loading control with wait ring" VerticalAlignment="Center" /> | ||
| </StackPanel> | ||
| </DataTemplate> | ||
| <DataTemplate x:Key="ProgressBarTemplate"> | ||
| <ProgressBar IsIndeterminate="True" Width="{Binding ElementName=PageName, Path=ActualWidth}" | ||
| Foreground="{StaticResource Brush-Grey-04}" /> | ||
| </DataTemplate> | ||
| <DataTemplate x:Key="LogoTemplate"> | ||
| <StackPanel Orientation="Horizontal" Padding="12"> | ||
| <Image Source="../../Assets/ToolkitLogo.png" Height="50" Margin="0,0,12,0" /> | ||
| <TextBlock Text="Loading control with logo" VerticalAlignment="Center" /> | ||
| </StackPanel> | ||
| </DataTemplate> | ||
|
|
||
| <DataTemplate x:Key="PhotosTemplate"> | ||
| <Grid Background="White" BorderBrush="Black" BorderThickness="1"> | ||
| <Image Source="{Binding Thumbnail}" | ||
| Stretch="UniformToFill" | ||
| HorizontalAlignment="Center" | ||
| VerticalAlignment="Center" /> | ||
| </Grid> | ||
| </DataTemplate> | ||
| </ResourceDictionary> | ||
| </Page.Resources> | ||
|
|
||
| <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
|
||
| <ScrollViewer> | ||
| <StackPanel Margin="20"> | ||
| <RichTextBlock Margin="0,10,0,0" Foreground="{StaticResource Brush-Grey-03}"> | ||
| <Paragraph FontSize="18" FontWeight="Bold">The loading control is for showing an animation with some content when the user should wait in some tasks of the app.</Paragraph> | ||
| <Paragraph /> | ||
| <Paragraph>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</Paragraph> | ||
| <Paragraph /> | ||
| <Paragraph>Expetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.</Paragraph> | ||
| <Paragraph /> | ||
| <Paragraph>His audiam deserunt in, eum ubique voluptatibus te. In reque dicta usu. Ne rebum dissentiet eam, vim omnis deseruisse id. Ullum deleniti vituperata at quo, insolens complectitur te eos, ea pri dico munere propriae. Vel ferri facilis ut, qui paulo ridens praesent ad. Possim alterum qui cu. Accusamus consulatu ius te, cu decore soleat appareat usu.</Paragraph> | ||
| </RichTextBlock> | ||
|
|
||
| <controls:AdaptiveGridView | ||
| Margin="0,12,0,0" | ||
| x:Name="AdaptiveGridViewControl" | ||
| ItemHeight="200" | ||
| DesiredWidth="300" | ||
| SelectionMode="None" | ||
| IsItemClickEnabled="False" | ||
| ItemTemplate="{StaticResource PhotosTemplate}" /> | ||
|
|
||
| </StackPanel> | ||
| </ScrollViewer> | ||
|
|
||
| <controls:Loading x:Name="LoadingControl" | ||
| HorizontalContentAlignment="{Binding HorizontalContentAlignment.Value}" | ||
| VerticalContentAlignment="{Binding VerticalContentAlignment.Value}" | ||
| Background="{Binding Background.Value}" | ||
| Opacity="{Binding Opacity.Value}"> | ||
| <ContentControl x:Name="LoadingContentControl" /> | ||
| </controls:Loading> | ||
| </Grid> | ||
| </Page> | ||
|
|
||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // ****************************************************************** | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
| // This code is licensed under the MIT License (MIT). | ||
| // THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
| // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
| // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
| // ****************************************************************** | ||
|
|
||
| using System.Threading.Tasks; | ||
| using Windows.UI; | ||
| using Windows.UI.Xaml; | ||
| using Windows.UI.Xaml.Media; | ||
| using Windows.UI.Xaml.Navigation; | ||
| using Microsoft.Toolkit.Uwp.SampleApp.Models; | ||
| using Microsoft.Toolkit.Uwp.UI.Animations; | ||
|
|
||
| namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages | ||
| { | ||
| /// <summary> | ||
| /// An empty page that can be used on its own or navigated to within a Frame. | ||
| /// </summary> | ||
| public sealed partial class LoadingPage | ||
| { | ||
| public LoadingPage() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| protected override async void OnNavigatedTo(NavigationEventArgs e) | ||
| { | ||
| var propertyDesc = e.Parameter as PropertyDescriptor; | ||
|
|
||
| if (propertyDesc != null) | ||
| { | ||
| DataContext = propertyDesc.Expando; | ||
| } | ||
|
|
||
| AdaptiveGridViewControl.ItemsSource = await new Data.PhotosDataSource().GetItemsAsync(); | ||
|
|
||
| Shell.Current.RegisterNewCommand("Loading control with wait ring", async (sender, args) => | ||
| { | ||
| LoadingContentControl.ContentTemplate = Resources["WaitListTemplate"] as DataTemplate; | ||
| await ShowLoadingDialogAsync(); | ||
| }); | ||
|
|
||
| Shell.Current.RegisterNewCommand("Loading control with progressbar", async (sender, args) => | ||
| { | ||
| LoadingContentControl.ContentTemplate = Resources["ProgressBarTemplate"] as DataTemplate; | ||
| await ShowLoadingDialogAsync(); | ||
| }); | ||
|
|
||
| Shell.Current.RegisterNewCommand("Loading control with logo and bluring when it requested", async (sender, args) => | ||
| { | ||
| LoadingContentControl.ContentTemplate = Resources["LogoTemplate"] as DataTemplate; | ||
| await LoadingContentControl.Blur(10, 1000, 0).StartAsync(); | ||
| await ShowLoadingDialogAsync(); | ||
| }); | ||
|
|
||
| base.OnNavigatedTo(e); | ||
| } | ||
|
|
||
| private async Task ShowLoadingDialogAsync() | ||
| { | ||
| LoadingControl.IsLoading = true; | ||
| await Task.Delay(3000); | ||
| LoadingControl.IsLoading = false; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,6 +117,14 @@ | |
| "Icon": "/SamplePages/DropShadowPanel/DropShadowPanel.png", | ||
| "BadgeUpdateVersionRequired": "/Assets/Badges/windows10_anniversary.png" | ||
| }, | ||
| { | ||
| "Name": "Loading", | ||
| "Type": "LoadingPage", | ||
| "About": "Loading control helps to show any xaml content with animation to the user while the app is doing some calculation.", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "LoadingControl helps to show content with animation to the user while the app is doing some calculation." |
||
| "CodeUrl": "https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/Loading", | ||
| "XamlCodeFile": "LoadingCode.bind", | ||
| "Icon": "/SamplePages/Loading/Loading.png" | ||
| }, | ||
| { | ||
| "Name": "TextBoxMask", | ||
| "Type": "TextBoxMaskPage", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // ****************************************************************** | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
| // This code is licensed under the MIT License (MIT). | ||
| // THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
| // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
| // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
| // ****************************************************************** | ||
|
|
||
| using System; | ||
| using Windows.UI.Xaml; | ||
| using Windows.UI.Xaml.Controls; | ||
|
|
||
| namespace Microsoft.Toolkit.Uwp.UI.Controls | ||
| { | ||
| /// <summary> | ||
| /// Loading control allows to show an loading animation with some xaml in it. | ||
| /// </summary> | ||
| public partial class Loading | ||
| { | ||
| /// <summary> | ||
| /// Identifies the <see cref="IsLoading"/> dependency property. | ||
| /// </summary> | ||
| public static readonly DependencyProperty IsLoadingProperty = DependencyProperty.Register( | ||
| nameof(IsLoading), typeof(bool), typeof(Loading), new PropertyMetadata(default(bool), IsLoadingPropertyChanged)); | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a value indicating whether isLoading. | ||
|
||
| /// </summary> | ||
| public bool IsLoading | ||
| { | ||
| get { return (bool)GetValue(IsLoadingProperty); } | ||
| set { SetValue(IsLoadingProperty, value); } | ||
| } | ||
|
|
||
| private static void IsLoadingPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | ||
| { | ||
| var control = d as Loading; | ||
| control?.Update(); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // ****************************************************************** | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
| // This code is licensed under the MIT License (MIT). | ||
| // THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
| // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
| // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
| // ****************************************************************** | ||
|
|
||
| using System; | ||
| using Windows.UI.Xaml; | ||
| using Windows.UI.Xaml.Controls; | ||
|
|
||
| namespace Microsoft.Toolkit.Uwp.UI.Controls | ||
| { | ||
| /// <summary> | ||
| /// Loading control allows to show an loading animation with some xaml in it. | ||
| /// </summary> | ||
| [TemplateVisualState(Name = "LoadingIn", GroupName = "CommonStates")] | ||
| [TemplateVisualState(Name = "LoadingOut", GroupName = "CommonStates")] | ||
| public partial class Loading : ContentControl | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="Loading"/> class. | ||
| /// </summary> | ||
| public Loading() | ||
| { | ||
| DefaultStyleKey = typeof(Loading); | ||
| } | ||
|
|
||
| protected override void OnApplyTemplate() | ||
| { | ||
| base.OnApplyTemplate(); | ||
|
|
||
| Update(); | ||
| } | ||
|
|
||
| private void Update() | ||
| { | ||
| VisualStateManager.GoToState(this, IsLoading ? "LoadingIn" : "LoadingOut", true); | ||
| } | ||
| } | ||
| } |
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.
Revert this change