Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Merge branch '5.0.0' into flyout_sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed Dec 3, 2020
2 parents 2145fd6 + 0b74649 commit 999a072
Show file tree
Hide file tree
Showing 29 changed files with 759 additions and 311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected override void Init()
Grid.SetRow(btn, 1);
Grid.SetColumn(btn, 0);

btnAdd.Clicked += OnAddlicked;
btnAdd.Clicked += OnAddClicked;
Grid.SetRow(btnAdd, 1);
Grid.SetColumn(btnAdd, 1);

Expand All @@ -129,6 +129,7 @@ void Callback(Page page)
var index = Items.IndexOf(carousel.CurrentItem as ModelIssue10300);
System.Diagnostics.Debug.WriteLine($"Delete {index}");
Items.RemoveAt(index);
MessagingCenter.Instance.Unsubscribe<Page>(this, "Delete");
}

public ObservableCollection<ModelIssue10300> Items { get; set; }
Expand All @@ -139,7 +140,7 @@ async void OnDeleteClicked(object sender, EventArgs e)
await Navigation.PushModalAsync(new ModalPage());
}

void OnAddlicked(object sender, EventArgs e)
void OnAddClicked(object sender, EventArgs e)
{
Items.Insert(0, new ModelIssue10300("0", Color.PaleGreen));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System;
using System;
using System.Diagnostics;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.UITest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public class Issue12574 : TestContentPage
ViewModelIssue12574 viewModel;
CarouselView _carouselView;
Button _btn;
Button _btn2;
string carouselAutomationId = "carouselView";
string btnRemoveAutomationId = "btnRemove";
string btnRemoveAllAutomationId = "btnRemoveAll";

protected override void Init()
{
Expand All @@ -35,8 +37,15 @@ protected override void Init()
Text = "Remove Last",
AutomationId = btnRemoveAutomationId
};
_btn.SetBinding(Button.CommandProperty, "RemoveItemsCommand");
// Initialize ui here instead of ctor
_btn.SetBinding(Button.CommandProperty, "RemoveLastItemCommand");

_btn2 = new Button
{
Text = "Remove All",
AutomationId = btnRemoveAllAutomationId
};
_btn2.SetBinding(Button.CommandProperty, "RemoveAllItemsCommand");

_carouselView = new CarouselView
{
AutomationId = carouselAutomationId,
Expand Down Expand Up @@ -64,9 +73,12 @@ protected override void Init()

var layout = new Grid();
layout.RowDefinitions.Add(new RowDefinition { Height = 100 });
layout.RowDefinitions.Add(new RowDefinition { Height = 100 });
layout.RowDefinitions.Add(new RowDefinition());
Grid.SetRow(_carouselView, 1);
Grid.SetRow(_btn2, 1);
Grid.SetRow(_carouselView, 2);
layout.Children.Add(_btn);
layout.Children.Add(_btn2);
layout.Children.Add(_carouselView);

BindingContext = viewModel = new ViewModelIssue12574();
Expand All @@ -81,7 +93,6 @@ protected override void OnAppearing()

#if UITEST
[Test]
[Ignore("Ignore while fix is not ready")]
public void Issue12574Test()
{
RunningApp.WaitForElement("0 item");
Expand All @@ -102,31 +113,58 @@ public void Issue12574Test()
RunningApp.WaitForElement("1 item");

rightX = rect.X + rect.Width - 1;
RunningApp.DragCoordinates(centerX, rect.CenterY, rightX, rect.CenterY);
RunningApp.DragCoordinates(rect.X, rect.CenterY, rightX, rect.CenterY);

RunningApp.WaitForElement("0 item");
}

[Test]
public void RemoveItemsQuickly()
{
RunningApp.WaitForElement("0 item");
RunningApp.Tap(btnRemoveAllAutomationId);

// If we haven't crashed, then the other button should be here
RunningApp.WaitForElement(btnRemoveAutomationId);
}
#endif
}

[Preserve(AllMembers = true)]
class ViewModelIssue12574 : BaseViewModel1
{
public ObservableCollection<ModelIssue12574> Items { get; set; }
public Command LoadItemsCommand { get; set; }
public Command RemoveItemsCommand { get; set; }
public Command RemoveAllItemsCommand { get; set; }
public Command RemoveLastItemCommand { get; set; }

public ViewModelIssue12574()
{
Title = "CarouselView Looping";
Items = new ObservableCollection<ModelIssue12574>();
LoadItemsCommand = new Command(() => ExecuteLoadItemsCommand());
RemoveItemsCommand = new Command(() => ExecuteRemoveItemsCommand());
RemoveAllItemsCommand = new Command(() => ExecuteRemoveItemsCommand(), () => Items.Count > 0);
RemoveLastItemCommand = new Command(() => ExecuteRemoveLastItemCommand(), () => Items.Count > 0);
}

void ExecuteRemoveItemsCommand()
{
while (Items.Count > 0)
{
Items.Remove(Items.Last());
Items.Remove(Items.Last());
Items.Remove(Items.Last());
}
RemoveAllItemsCommand.ChangeCanExecute();
RemoveLastItemCommand.ChangeCanExecute();
}

void ExecuteRemoveLastItemCommand()
{
Items.Remove(Items.Last());
RemoveAllItemsCommand.ChangeCanExecute();
RemoveLastItemCommand.ChangeCanExecute();
}

void ExecuteLoadItemsCommand()
{
IsBusy = true;
Expand All @@ -146,6 +184,8 @@ void ExecuteLoadItemsCommand()
finally
{
IsBusy = false;
RemoveAllItemsCommand.ChangeCanExecute();
RemoveLastItemCommand.ChangeCanExecute();
}
}

Expand All @@ -156,7 +196,6 @@ public void OnAppearing()
}
}

[Preserve(AllMembers = true)]
class ModelIssue12574
{
public string Id { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
namespace Xamarin.Forms.Controls.Issues
{

#if APP
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github5000)]
#endif
[Preserve (AllMembers = true)]
[Issue (IssueTracker.Github, 2447, "Force label text direction", PlatformAffected.Android)]
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 2447, "Force label text direction", PlatformAffected.Android)]
public partial class Issue2447 : ContentPage
{
public Issue2447 ()
#if APP
public Issue2447()
{
InitializeComponent();
}
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Xamarin.Forms.Controls.Issues.Issue2448"
FlowDirection="MatchParent">
<StackLayout>
<Button
Clicked="AlertNoFlow_Clicked"
HorizontalOptions="CenterAndExpand"
Text="Display Alert No Flow Direction"
VerticalOptions="CenterAndExpand" />
<Button
Clicked="AlertMatchParent_Clicked"
HorizontalOptions="CenterAndExpand"
Text="Display Alert Flow Direction Match Parent"
VerticalOptions="CenterAndExpand" />
<Button
Clicked="AlertRTL_Clicked"
HorizontalOptions="CenterAndExpand"
Text="Display Alert Flow Direction RTL"
VerticalOptions="CenterAndExpand" />
<Button
Clicked="AlertLTR_Clicked"
HorizontalOptions="CenterAndExpand"
Text="Display Alert Flow Direction LTR"
VerticalOptions="CenterAndExpand" />
<Button
Clicked="ActionsheetNoFlow_Clicked"
HorizontalOptions="CenterAndExpand"
Text="Display ActionSheet No Flow Direction"
VerticalOptions="CenterAndExpand" />
<Button
Clicked="ActionsheetMatchParent_Clicked"
HorizontalOptions="CenterAndExpand"
Text="Display ActionSheet Flow Direction Match Parent"
VerticalOptions="CenterAndExpand" />
<Button
Clicked="ActionsheetRTL_Clicked"
HorizontalOptions="CenterAndExpand"
Text="Display ActionSheet Flow Direction RTL"
VerticalOptions="CenterAndExpand" />
<Button
Clicked="ActionsheetLTR_Clicked"
HorizontalOptions="CenterAndExpand"
Text="Display ActionSheet Flow Direction LTR"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Xaml;

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 2448, "Setting FlowDirection of Alerts and ActionSheets", PlatformAffected.iOS | PlatformAffected.Android)]
#if APP
[XamlCompilation(XamlCompilationOptions.Compile)]
#endif
public partial class Issue2448 : ContentPage
{
public Issue2448()
{
#if APP
InitializeComponent();
#endif
}

#if APP
void AlertNoFlow_Clicked(object sender, EventArgs args)
{
var alert = DisplayAlert("Alert", "You have been alerted", "OK");
}

void AlertMatchParent_Clicked(object sender, EventArgs args)
{
var alert = DisplayAlert("Alert", "You have been alerted", "OK", FlowDirection.MatchParent);
}

void AlertRTL_Clicked(object sender, EventArgs args)
{
var alert = DisplayAlert("Alert", "You have been alerted", "OK", FlowDirection.RightToLeft);
}

void AlertLTR_Clicked(object sender, EventArgs args)
{
var alert = DisplayAlert("Alert", "You have been alerted", "OK", FlowDirection.LeftToRight);
}

void ActionsheetNoFlow_Clicked(object sender, EventArgs args)
{
var alert = DisplayActionSheet("ActionSheet: SavePhoto?", "Cancel", "Delete", "Photo Roll", "Email");
}

void ActionsheetMatchParent_Clicked(object sender, EventArgs args)
{
var alert = DisplayActionSheet("ActionSheet: SavePhoto?", "Cancel", "Delete", FlowDirection.MatchParent, "Photo Roll", "Email");
}

void ActionsheetRTL_Clicked(object sender, EventArgs args)
{
var alert = DisplayActionSheet("ActionSheet: SavePhoto?", "Cancel", "Delete", FlowDirection.RightToLeft, "Photo Roll", "Email");
}

void ActionsheetLTR_Clicked(object sender, EventArgs args)
{
var alert = DisplayActionSheet("ActionSheet: SavePhoto?", "Cancel", "Delete", FlowDirection.LeftToRight, "Photo Roll", "Email");
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue12246.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue12652.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue12714.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue2447.xaml.cs">
<DependentUpon>Issue2447.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Issue2448.xaml.cs">
<DependentUpon>Issue2448.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Issue8613.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue9137.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue8691.cs" />
Expand Down Expand Up @@ -2501,4 +2507,14 @@
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue2447.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue2448.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,12 @@
ItemsSource="{Binding Items}"
SelectionMode="Single"
SelectedItem="{Binding SelectedItem}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame
HasShadow="False"
Margin="10"
BackgroundColor="LightBlue"
CornerRadius="20">
<StackLayout>
<Image
Source="{Binding Image}"
HeightRequest="50" />
<Label
Text="{Binding Caption}"></Label>
</StackLayout>

<VisualStateManager.VisualStateGroups>
<CollectionView.Resources>
<ResourceDictionary>
<Style TargetType="Frame">
<Setter Property="VisualStateManager.VisualStateGroups">

<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
Expand All @@ -63,7 +53,27 @@
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>

</Setter>
</Style>
</ResourceDictionary>

</CollectionView.Resources>

<CollectionView.ItemTemplate>
<DataTemplate>
<Frame
HasShadow="False"
Margin="10"
BackgroundColor="LightBlue"
CornerRadius="20">
<StackLayout>
<Image
Source="{Binding Image}"
HeightRequest="50" />
<Label
Text="{Binding Caption}"></Label>
</StackLayout>

</Frame>
</DataTemplate>
Expand Down
Loading

0 comments on commit 999a072

Please sign in to comment.