-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge the fixes on SR4 into main (#21782)
### Description of Change Upstream all the fixes!
- Loading branch information
Showing
19 changed files
with
576 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21711.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[Issue(IssueTracker.Github, 21711, "NullReferenceException from FlexLayout.InitItemProperties", PlatformAffected.iOS)] | ||
public class Issue21711 : TestContentPage | ||
{ | ||
protected override void Init() | ||
{ | ||
FlexLayout flex = null!; | ||
Content = new VerticalStackLayout | ||
{ | ||
new Button | ||
{ | ||
Text = "Add", | ||
AutomationId = "Add", | ||
Command = new Command(() => | ||
{ | ||
flex.Clear(); | ||
flex.Add(NewLabel(0)); | ||
flex.Add(NewLabel(1)); | ||
flex.Clear(); | ||
flex.Add(NewLabel(2)); | ||
flex.Add(NewLabel(3)); | ||
}) | ||
}, | ||
new Button | ||
{ | ||
Text = "Insert", | ||
AutomationId = "Insert", | ||
Command = new Command(() => | ||
{ | ||
flex.Clear(); | ||
flex.Insert(0, NewLabel(1)); | ||
flex.Insert(0, NewLabel(0)); | ||
flex.Clear(); | ||
flex.Insert(0, NewLabel(3)); | ||
flex.Insert(0, NewLabel(2)); | ||
}) | ||
}, | ||
new Button | ||
{ | ||
Text = "Update", | ||
AutomationId = "Update", | ||
Command = new Command(() => | ||
{ | ||
flex.Clear(); | ||
flex.Add(NewLabel(0)); | ||
flex[0] = NewLabel(1); | ||
flex.Clear(); | ||
flex.Add(NewLabel(2)); | ||
flex[0] = NewLabel(3); | ||
}) | ||
}, | ||
new Button | ||
{ | ||
Text = "Remove", | ||
AutomationId = "Remove", | ||
Command = new Command(() => | ||
{ | ||
flex.Clear(); | ||
var label = NewLabel(0); | ||
flex.Add(label); | ||
flex.Remove(label); | ||
flex.Clear(); | ||
label = NewLabel(1); | ||
flex.Add(label); | ||
flex.Remove(label); | ||
flex.Add(NewLabel(2)); | ||
}) | ||
}, | ||
(flex = new FlexLayout { }), | ||
}; | ||
} | ||
|
||
Label NewLabel(int count) => | ||
new Label | ||
{ | ||
Text = $"Item{count}", | ||
AutomationId = $"Item{count}", | ||
Background = Brush.Yellow, | ||
TextType = TextType.Html | ||
}; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Controls/samples/Controls.Sample.UITests/Issues/Issue5354.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue5354"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition/> | ||
</Grid.RowDefinitions> | ||
|
||
<StackLayout Orientation="Vertical" Spacing="5" Grid.Row="0" VerticalOptions="Center"> | ||
<Label x:Name="Label" LineBreakMode="WordWrap" Text="Switch between linear and grid layouts. If layouts appear as expected with proper spacing between items, the test passes." HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/> | ||
<Button AutomationId="Button5354" Text="Switch to grid layout" HorizontalOptions="Center" VerticalOptions="Center" Clicked="ButtonClicked"/> | ||
</StackLayout> | ||
|
||
<CollectionView AutomationId="CollectionView5354" Grid.Row="1" ItemsSource="{Binding Items}"> | ||
<CollectionView.ItemsLayout> | ||
<LinearItemsLayout Orientation="Vertical" ItemSpacing="5"/> | ||
</CollectionView.ItemsLayout> | ||
|
||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<StackLayout Orientation="Vertical" Spacing="10" BackgroundColor="Beige" Padding="10"> | ||
<Image Source="{Binding Source}" HeightRequest="100"/> | ||
<Label Text="{Binding Text}" HorizontalTextAlignment="Center" AutomationId="{Binding AutomationId}"/> | ||
</StackLayout> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
|
||
</CollectionView> | ||
</Grid> | ||
</ContentPage> |
95 changes: 95 additions & 0 deletions
95
src/Controls/samples/Controls.Sample.UITests/Issues/Issue5354.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using Microsoft.Maui.Controls.Internals; | ||
using Microsoft.Maui.Controls.Xaml; | ||
using Microsoft.Maui.Controls; | ||
|
||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[Issue(IssueTracker.None, 5354, "[CollectionView] Updating the ItemsLayout type should refresh the layout", PlatformAffected.All)] | ||
public partial class Issue5354 : ContentPage | ||
{ | ||
int count = 0; | ||
|
||
public Issue5354() | ||
{ | ||
InitializeComponent(); | ||
|
||
BindingContext = new ViewModel5354(); | ||
} | ||
|
||
void ButtonClicked(object sender, EventArgs e) | ||
{ | ||
var button = sender as Button; | ||
var stackLayout = button.Parent as StackLayout; | ||
var grid = stackLayout.Parent as Grid; | ||
var collectionView = grid.Children[1] as CollectionView; | ||
|
||
if (count % 2 == 0) | ||
{ | ||
collectionView.ItemsLayout = new GridItemsLayout(ItemsLayoutOrientation.Vertical) | ||
{ | ||
Span = 2, | ||
HorizontalItemSpacing = 5, | ||
VerticalItemSpacing = 5 | ||
}; | ||
|
||
button.Text = "Switch to linear layout"; | ||
} | ||
else | ||
{ | ||
collectionView.ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Vertical) | ||
{ | ||
ItemSpacing = 5 | ||
}; | ||
|
||
button.Text = "Switch to grid layout"; | ||
} | ||
|
||
++count; | ||
} | ||
} | ||
|
||
[Preserve(AllMembers = true)] | ||
public class ViewModel5354 | ||
{ | ||
public ObservableCollection<Model5354> Items { get; set; } | ||
|
||
public ViewModel5354() | ||
{ | ||
var collection = new ObservableCollection<Model5354>(); | ||
var pageSize = 50; | ||
|
||
for (var i = 0; i < pageSize; i++) | ||
{ | ||
collection.Add(new Model5354 | ||
{ | ||
Text = "Image" + i, | ||
Source = i % 2 == 0 ? | ||
"groceries.png" : | ||
"dotnet_bot.png", | ||
AutomationId = "Image" + i | ||
}); | ||
} | ||
|
||
Items = collection; | ||
} | ||
} | ||
|
||
[Preserve(AllMembers = true)] | ||
public class Model5354 | ||
{ | ||
public string Text { get; set; } | ||
|
||
public string Source { get; set; } | ||
|
||
public string AutomationId { get; set; } | ||
|
||
public Model5354() | ||
{ | ||
|
||
} | ||
} | ||
} |
5 changes: 4 additions & 1 deletion
5
.../ContentPage/HideSoftInputOnTappedChanged/HideSoftInputOnTappedChangedManager.Platform.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.