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

Implement loading control with sample. #247

Merged
merged 42 commits into from
Jan 25, 2017
Merged

Implement loading control with sample. #247

merged 42 commits into from
Jan 25, 2017

Conversation

soydachi
Copy link
Contributor

@soydachi soydachi commented Aug 26, 2016

The loading control is for showing an animation with some content when the user should wait in some tasks of the app.

There is a sample on Microsoft.Toolkit.Uwp.SampleApp/SamplePages where we can change all the properties and content to see how easy it is.

uwpwindowstoolkit

An example of how we can build the loading control.

<controls:Loading x:Name="LoadingControl" LoadingHorizontalAlignment="{Binding LoadingContentHorizontalAlignment.Value}" 
                    LoadingVerticalAlignment="{Binding LoadingContentVerticalAlignment.Value}"
                    LoadingBackground="{Binding LoadingBackground.Value}" LoadingOpacity="{Binding OpacityForLoadingControl.Value}">
    <ContentControl x:Name="LoadingContentControl"/>
</controls:Loading>
  • LoadingHorizontalAlignment and LoadingVerticalAlignment are responsible to align the custom content of the control. It aligns what we create inside as a ContentPresenter.
  • LoadingBackground and LoadingOpacity are for the panel who appears and disappears behind our custom control.
  • ContentControl could be everything done with xaml. For example:
<controls:Loading x:Name="LoadingControl" LoadingHorizontalAlignment="{Binding LoadingContentHorizontalAlignment.Value}" 
                    LoadingVerticalAlignment="{Binding LoadingContentVerticalAlignment.Value}"
                    LoadingBackground="{Binding LoadingBackground.Value}" LoadingOpacity="{Binding OpacityForLoadingControl.Value}">
    <StackPanel Orientation="Horizontal" Padding="12">
        <Grid Margin="0,0,8,0">
            <Image Source="../../Assets/ToolkitLogo.png" Height="50" />
            <ProgressRing IsActive="True" Foreground="Blue" />
        </Grid>
        <TextBlock Text="It's ok, we are working on it :)" Foreground="Black" VerticalAlignment="Center" />
    </StackPanel>
</controls:Loading>

Finally that the loading control appears, we must set the IsLoading property to true

LoadingControl.IsLoading = true;

@msftclas
Copy link

Hi @dachibox, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

@msftclas
Copy link

@dachibox, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, MSBOT;

@ScottIsAFool
Copy link
Contributor

Can you provide more information on what this Pull Request is including. You also need to resync with dev and resolve the conflicts.

public sealed partial class Loading
{
public static readonly DependencyProperty LoadingVerticalAlignmentProperty = DependencyProperty.Register(
"LoadingVerticalAlignment", typeof(VerticalAlignment), typeof(Loading), new PropertyMetadata(default(VerticalAlignment)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Use nameof() instead of strings for property names

@soydachi
Copy link
Contributor Author

Great @ScottIsAFool, let me revise all this and wait for a resync. Thanks'!

@deltakosh
Copy link
Contributor

deltakosh commented Aug 26, 2016

We should think about this control in way that almost all waiting screen can be doable with it.

Can I use it to display a fullscreen semi transparent rectangle with a waiting ring in the middle?
Can I use it to display a minimal bar on top or at the bottom of the screen?

I like the idea of this control but it has to be really versatile (and easy to use of course :))

@@ -277,7 +278,9 @@
<Content Include="Assets\Prettify\prettify.js" />
<Content Include="Assets\Prettify\run_prettify.js" />
<Content Include="SamplePages\RangeSelector\RangeSelectorCode.bind" />
<Content Include="SamplePages\AdaptiveGridView\AdaptiveGridViewCode.bind" />
<Content Include="SamplePages\AdaptiveGridView\AdaptiveGridViewCode.bind">
<SubType>Designer</SubType>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not true (As there are our binding commands inside)

@@ -292,6 +295,9 @@
<Content Include="SamplePages\BladeControl\BladeCode.bind" />
<Content Include="SamplePages\FadeHeader\FadeHeaderBehaviorCode.bind" />
<Content Include="SamplePages\FadeHeader\FadeHeaderBehaviorXaml.bind" />
<Content Include="SamplePages\Loading\LoadingCode.bind">
<SubType>Designer</SubType>
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be designer here either

@soydachi
Copy link
Contributor Author

soydachi commented Aug 29, 2016

@deltakosh Yes of course, you can try the sample that exist on SampleApp. There you can change some properties and look and feel.

uwpwindowstoolkit

The default template it's a must, so will start to finish this control with that. Thank's for all the help!

@soydachi
Copy link
Contributor Author

@ScottIsAFool @deltakosh @dotMorten @pedrolamas I just updated the description and the project. Maybe now it's a little bit better :)

Thank's!

@AuroraDysis
Copy link

@skendrot My idea is more similar to #614

Conflicts:
	Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml
Conflicts:
	Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj
	Microsoft.Toolkit.Uwp.SampleApp/SamplePages/PrintHelper/PrintHelperPage.xaml.cs
	Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json
@soydachi
Copy link
Contributor Author

soydachi commented Dec 7, 2016

@skendrot I just updated this control with some improvements. Let see it all is in the right way. Thank's!

@skendrot
Copy link
Contributor

Still many namespace changes to files not related to this PR. I do not disagree with the changes, but they should not be part of this PR. Can you please revert the files not associated with this PR.

Conflicts:
	Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj
	Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml
@soydachi
Copy link
Contributor Author

@skendrot happy new year! :) This should almost be done now. Greetings!

An example of how we can build the loading control.

``` xaml
<controls:Loading x:Name="LoadingControl" HorizontalAlignment="{Binding HorizontalAlignment.Value}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove the alignment, background and opacity bindings for the documentation. Add in a binding for IsLoading

@@ -10,9 +10,9 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using Microsoft.Windows.Toolkit.SampleApp.Models;
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert this change

@@ -118,6 +118,14 @@
"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.",
Copy link
Contributor

Choose a reason for hiding this comment

The 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."

nameof(IsLoading), typeof(bool), typeof(Loading), new PropertyMetadata(default(bool), IsLoadingPropertyChanged));

/// <summary>
/// Gets or sets a value indicating whether isLoading.
Copy link
Contributor

Choose a reason for hiding this comment

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

"Gets or sets a value indicating whether the control is in the loading state."

<Border x:Name="RootGrid" HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Background="{TemplateBinding Background}"
Opacity="{TemplateBinding Opacity}">
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to bind opacity

<Setter.Value>
<ControlTemplate TargetType="controls:Loading">
<Border x:Name="RootGrid" HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to bind horizontal and vertical alignment. You should bind border properties like BorderBrush, BorderThinkness

<ContentControl x:Name="LoadingContentControl"/>
</controls:Loading>
```
- **HorizontalAlignment** and **VerticalAlignment** are responsible to align the custom content of the control. It aligns what we create inside as a ContentPresenter.
Copy link
Contributor

Choose a reason for hiding this comment

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

These can be removed. Nothing unique about these properties for this control

```
- **HorizontalAlignment** and **VerticalAlignment** are responsible to align the custom content of the control. It aligns what we create inside as a ContentPresenter.
- **Background** and **Opacity** are for the panel who appears and disappears behind our custom control.
- **ContentControl** could be everything done with xaml. For example:
Copy link
Contributor

Choose a reason for hiding this comment

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

Good to still show an example of putting content in the control, but no need to point out ContentControl. Perhaps "Use the LoadingControl to show specialized content"

@skendrot
Copy link
Contributor

Almost there!!!

@soydachi
Copy link
Contributor Author

@skendrot so I hope that now is almost done 😅

@soydachi
Copy link
Contributor Author

@skendrot updated to the last upstream/dev

@skendrot
Copy link
Contributor

WooHoo! Thanks for sticking with it @dachibox

@soydachi
Copy link
Contributor Author

Hooray!! 😃

Thank you for staying with me all the time @skendrot and UWPCommunityToolkit Team!!

@hermitdave
Copy link
Contributor

@dachibox @deltakosh this is a progress overlay that can contain anything including progress bar / indicators / messages right ? Coding4Fun toolkit called it ProgressOverlay and should we stick with that name ?

@soydachi
Copy link
Contributor Author

The control is thought for showing very simple the loading or progress status of the app. But yes, you can put anything you want in the control.

I think that for messages, there is better with an MessageDialog or ContentDialog.
And indicators I think is in the same context as Loading.

What you think guys? @deltakosh @skendrot @hermitdave

@skendrot
Copy link
Contributor

skendrot commented Jan 25, 2017

I would not rename it. If anything it would be good to merge with #828 to have a generic progress control that could have any content. If it was merged to one control then it would warrant being renamed.

@hermitdave
Copy link
Contributor

I agree that would be for the next phase though.. this looks good so I will merge it now

@hermitdave hermitdave merged commit 0012aee into CommunityToolkit:dev Jan 25, 2017
@hermitdave
Copy link
Contributor

@dachibox congratulations!! this along with #828 will be cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants