Skip to content

Commit

Permalink
Merge pull request #20 from xtuzy/Modify
Browse files Browse the repository at this point in the history
main update some anim api
  • Loading branch information
xtuzy authored Jun 29, 2022
2 parents 4fb3b48 + a5c3d7e commit 432c2ed
Show file tree
Hide file tree
Showing 15 changed files with 494 additions and 157 deletions.
2 changes: 1 addition & 1 deletion SharpConstraintLayout.Maui.Example/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Shell.FlyoutBehavior="Disabled">

<ShellContent
Title="Hello, World!"
Title="SharpConstraintLayout"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

Expand Down
21 changes: 14 additions & 7 deletions SharpConstraintLayout.Maui.Example/Pages/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,22 @@ void FlowPerformanceTest(ConstraintLayout page)
void CircleConstraintTest(ConstraintLayout page)
{
(Button FirstButton, Button SecondButton, ContentView ThirdCanvas, Label FouthTextBlock, Entry FifthTextBox, Editor SixthRichTextBlock) = CreateControls();

FirstButton.Text = "0°";
SecondButton.Text = "60°";
FouthTextBlock.Text = "180°";
FifthTextBox.Text = "240°";
SixthRichTextBlock.Text = "300°";
var centerButton = new Button() { Text = "Center" };
var layout = page;
layout.AddElement(FirstButton, SecondButton, FouthTextBlock);
layout.AddElement(centerButton,FirstButton, SecondButton,ThirdCanvas, FouthTextBlock,FifthTextBox,SixthRichTextBlock);
using (var layoutSet = new FluentConstraintSet())
{
layoutSet.Clone(layout);
layoutSet.Select(FirstButton).CenterTo()
.Select(SecondButton, FouthTextBlock)
.CircleTo(FirstButton, new[] { 100, 100 }, new[] { 60f, 240 });
layoutSet.Select(centerButton).CenterTo()
.Select(FirstButton,SecondButton, ThirdCanvas, FouthTextBlock, FifthTextBox, SixthRichTextBlock)
.CircleTo(centerButton, new[] { 100, 120,140,160,180,200 }, new[] { 0f,60, 120,180,240,300})
.Select(ThirdCanvas).Width(30).Height(30)
;
layoutSet.ApplyTo(layout);
}

Expand All @@ -116,9 +123,9 @@ void CircleConstraintTest(ConstraintLayout page)
UIThread.Invoke(() =>
{
//The distance between SecondButton center and FirstButton center should equal to 50
SimpleTest.AreEqual(Math.Abs(SecondButton.GetBounds().Center.Y - FirstButton.GetBounds().Center.Y) * 2, 100, nameof(CircleConstraintTest), "The distence between SecondButton center and FirstButton center should equal to 100");
SimpleTest.AreEqual(Math.Abs(SecondButton.GetBounds().Center.Y - centerButton.GetBounds().Center.Y) * 2, 100, nameof(CircleConstraintTest));
//The distance between FouthTextBlock center and FirstButton center should equal to 50
SimpleTest.AreEqual(Math.Abs(FouthTextBlock.GetBounds().Center.Y - FirstButton.GetBounds().Center.Y) * 2, 100, nameof(CircleConstraintTest), "The distence between FouthTextBlock center and FirstButton center should equal to 100");
SimpleTest.AreEqual(Math.Abs(FouthTextBlock.GetBounds().Center.Y - centerButton.GetBounds().Center.Y) * 2, 180, nameof(CircleConstraintTest));
}, page);

index++;
Expand Down
1 change: 1 addition & 0 deletions SharpConstraintLayout.Maui.Example/Pages/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</Grid.RowDefinitions>
<ScrollView Grid.Row="0" Orientation="Horizontal">
<HorizontalStackLayout>
<Label x:Name="fpsLabel" Text="FPS" WidthRequest="50" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" BackgroundColor="Brown"></Label>
<Button
x:Name="BaseAlign"
Clicked="BaseAlign_Clicked"
Expand Down
16 changes: 16 additions & 0 deletions SharpConstraintLayout.Maui.Example/Pages/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ namespace SharpConstraintLayout.Maui.Example;

public partial class MainPage : ContentPage
{

#if WINDOWS || __ANDROID__ || __IOS__
BlogFrameRate.FrameRateCalculator fr;
#endif
public MainPage()
{
InitializeComponent();
Expand All @@ -22,6 +26,18 @@ public MainPage()
App.WindowWidth = (int)(sender as Page).Bounds.Width;
};
TempButton_Clicked(null, null);

#if WINDOWS || __ANDROID__ || __IOS__
if (fr == null)
{
fr = new BlogFrameRate.FrameRateCalculator();
fr.FrameRateUpdated += (value) =>
{
this.Dispatcher.Dispatch(() => fpsLabel.Text = value.Frames.ToString());
};
fr.Start();
}
#endif
}

private (Button FirstButton, Button SecondButton, ContentView ThirdCanvas, Label FouthTextBlock, Entry FifthTextBox, Editor SixthRichTextBlock) CreateControls()
Expand Down
14 changes: 13 additions & 1 deletion SharpConstraintLayout.Maui.Example/Pages/ShowAnimationView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,16 @@
x:Class="SharpConstraintLayout.Maui.Example.Pages.ShowAnimationView"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:constraint="clr-namespace:SharpConstraintLayout.Maui.Widget;assembly=SharpConstraintLayout.Maui" />
xmlns:constraint="clr-namespace:SharpConstraintLayout.Maui.Widget;assembly=SharpConstraintLayout.Maui" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<HorizontalStackLayout>
<Button Text="BasisAnim" x:Name="BasisAnim"></Button>
<Button Text="AnimPro" x:Name="AnimPro"></Button>
</HorizontalStackLayout>
<Grid Grid.Row="1" x:Name="animContent"></Grid>
</Grid>
</ContentView>
Loading

0 comments on commit 432c2ed

Please sign in to comment.