Skip to content

Commit 395da71

Browse files
authored
Merge branch 'main' into dev/TJ/iOS18242
2 parents 5dfccc8 + ad28b65 commit 395da71

File tree

23 files changed

+208
-39
lines changed

23 files changed

+208
-39
lines changed

Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
<!-- Until we get a new enough dotnet -->
7272
<ItemGroup Condition="'$(_MauiTargetPlatformIsWindows)' == 'True'">
73-
<FrameworkReference Update="Microsoft.Windows.SDK.NET.Ref" RuntimeFrameworkVersion="10.0.19041.27" TargetingPackVersion="10.0.19041.27" />
73+
<FrameworkReference Update="Microsoft.Windows.SDK.NET.Ref" RuntimeFrameworkVersion="10.0.19041.31" TargetingPackVersion="10.0.19041.31" />
7474
</ItemGroup>
7575

7676
<!--

docs/design/layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ For example, given this layout...
3636

3737
```
3838
<VerticalStackLayout WidthRequest="400">
39-
<Label Text="Hello" WidthTRequest="100" HorizontalOptions="Fill"/>
39+
<Label Text="Hello" WidthRequest="100" HorizontalOptions="Fill"/>
4040
</VerticalStackLayout>
4141
```
4242

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<!-- emsdk -->
3535
<MicrosoftNETWorkloadEmscriptenPackageVersion>8.0.0</MicrosoftNETWorkloadEmscriptenPackageVersion>
3636
<!-- wasdk -->
37-
<MicrosoftWindowsAppSDKPackageVersion>1.3.230724000</MicrosoftWindowsAppSDKPackageVersion>
37+
<MicrosoftWindowsAppSDKPackageVersion>1.5.240227000</MicrosoftWindowsAppSDKPackageVersion>
3838
<MicrosoftWindowsSDKBuildToolsPackageVersion>10.0.22621.756</MicrosoftWindowsSDKBuildToolsPackageVersion>
3939
<MicrosoftGraphicsWin2DPackageVersion>1.0.5.1</MicrosoftGraphicsWin2DPackageVersion>
4040
<!-- Everything else -->

src/Controls/samples/Controls.Sample.UITests/Concepts/ImageLoadingGalleryPage.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ namespace Maui.Controls.Sample
55
{
66
internal class ImageLoadingGalleryPage : CoreGalleryBasePage
77
{
8+
public ImageLoadingGalleryPage() : base()
9+
{
10+
#if WINDOWS
11+
((ScrollView)Content).VerticalScrollBarVisibility = Microsoft.Maui.ScrollBarVisibility.Never;
12+
#endif
13+
}
14+
815
protected override void Build()
916
{
1017
Add(Test.ImageLoading.FromBundleSvg, ImageSource.FromFile("dotnet_bot.png"));

src/Controls/samples/Controls.Sample.UITests/Issues/Issue18242.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Maui.Controls.Sample.Issues
55
{
66
[XamlCompilation(XamlCompilationOptions.Compile)]
7-
[Issue(IssueTracker.Github, 18242, "Button ImageSource not Scaling as expected", PlatformAffected.iOS)]
7+
[Issue(IssueTracker.Github, 18242, "Button ImageSource not Scaling as expected", PlatformAffected.All)]
88
public partial class Issue18242 : ContentPage
99
{
1010
public Issue18242()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Maui.Controls.Sample.Issues.Issue20439"
5+
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues">
6+
<ShellContent
7+
Title="Home">
8+
<ContentPage>
9+
<StackLayout VerticalOptions="Center">
10+
<Entry AutomationId="entry" Text="Tap here"/>
11+
<Button AutomationId="button" Text="Open the input page" Clicked="Button_Clicked"/>
12+
</StackLayout>
13+
</ContentPage>
14+
</ShellContent>
15+
16+
<ShellContent
17+
Title="Text input page">
18+
<ContentPage>
19+
<Editor VerticalOptions="Center"
20+
AutomationId="editor"
21+
HeightRequest="100"
22+
Text="Potential auto correcting words: -- :-) ... omw \n" />
23+
</ContentPage>
24+
</ShellContent>
25+
</Shell>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Microsoft.Maui.Controls;
2+
using Microsoft.Maui.Controls.Xaml;
3+
4+
namespace Maui.Controls.Sample.Issues
5+
{
6+
[XamlCompilation(XamlCompilationOptions.Compile)]
7+
[Issue(IssueTracker.Github, 20439, "[iOS] Double dash in Entry or Editor crashes the app", PlatformAffected.iOS)]
8+
public partial class Issue20439 : Shell
9+
{
10+
public Issue20439()
11+
{
12+
InitializeComponent();
13+
}
14+
15+
void Button_Clicked(object sender, System.EventArgs e)
16+
{
17+
CurrentItem = Items[1];
18+
}
19+
}
20+
}

src/Controls/src/Core/Platform/iOS/Extensions/TextExtensions.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,26 @@ static void UpdateText(this IUITextInput textInput, InputView inputView, bool is
4141
// position if needed when the text was modified by a Converter.
4242
var textRange = textInput.GetTextRange(textInput.BeginningOfDocument, textInput.EndOfDocument);
4343
var oldText = textInput.TextInRange(textRange) ?? string.Empty;
44+
45+
// We need this variable because in some cases because of the iOS's
46+
// auto correction eg. eg '--' => '—' the actual text in the input might have
47+
// a different length that the one that has been set in the control.
48+
var newTextLength = !string.IsNullOrWhiteSpace(inputView.Text) ? textInput.TextInRange(textRange)?.Length ?? 0 : 0;
49+
4450
var newText = TextTransformUtilites.GetTransformedText(
4551
inputView?.Text,
4652
textInput.GetSecureTextEntry() ? TextTransform.Default : inputView.TextTransform
4753
);
4854

55+
if (!string.IsNullOrWhiteSpace(oldText))
56+
newTextLength = newText.Length;
57+
4958
if (oldText != newText)
5059
{
5160
// Re-calculate the cursor offset position if the text was modified by a Converter.
5261
// but if the text is being set by code, let's just move the cursor to the end.
53-
var cursorOffset = newText.Length - oldText.Length;
54-
var cursorPosition = isEditing ? textInput.GetCursorPosition(cursorOffset) : newText.Length;
62+
var cursorOffset = newTextLength - oldText.Length;
63+
var cursorPosition = isEditing ? textInput.GetCursorPosition(cursorOffset) : newTextLength;
5564

5665
textInput.ReplaceText(textRange, newText);
5766

src/Controls/src/Core/SwipeGestureRecognizer.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,47 @@ bool ISwipeGestureController.DetectSwipe(View sender, SwipeDirection direction)
6565
var detected = false;
6666
var threshold = Threshold;
6767

68+
var detectedDirection = (SwipeDirection)(0);
69+
6870
if (direction.IsLeft())
6971
{
70-
detected |= _totalX < -threshold;
72+
if (_totalX < -threshold)
73+
{
74+
detected = true;
75+
detectedDirection |= SwipeDirection.Left;
76+
}
7177
}
7278

7379
if (direction.IsRight())
7480
{
75-
detected |= _totalX > threshold;
81+
if (_totalX > threshold)
82+
{
83+
detected = true;
84+
detectedDirection |= SwipeDirection.Right;
85+
}
7686
}
7787

7888
if (direction.IsDown())
7989
{
80-
detected |= _totalY > threshold;
90+
if (_totalY > threshold)
91+
{
92+
detected = true;
93+
detectedDirection |= SwipeDirection.Down;
94+
}
8195
}
8296

8397
if (direction.IsUp())
8498
{
85-
detected |= _totalY < -threshold;
99+
if (_totalY < -threshold)
100+
{
101+
detected = true;
102+
detectedDirection |= SwipeDirection.Up;
103+
}
86104
}
87105

88106
if (detected)
89107
{
90-
SendSwiped(sender, direction);
108+
SendSwiped(sender, detectedDirection);
91109
}
92110

93111
return detected;

src/Controls/tests/Core.UnitTests/Gestures/SwipeGestureRecognizerTests.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,39 @@ public void SwipeIgnoredIfBelowThresholdTest()
8383
((ISwipeGestureController)swipe).DetectSwipe(view, SwipeDirection.Up);
8484
Assert.False(detected);
8585
}
86+
87+
[Fact]
88+
public void SwipedEventDirectionMatchesTotalXTestWithFlags()
89+
{
90+
var view = new View();
91+
var swipe = new SwipeGestureRecognizer();
92+
93+
SwipeDirection direction = SwipeDirection.Up;
94+
swipe.Swiped += (object sender, SwipedEventArgs e) =>
95+
{
96+
direction = e.Direction;
97+
};
98+
99+
((ISwipeGestureController)swipe).SendSwipe(view, totalX: -150, totalY: 10);
100+
((ISwipeGestureController)swipe).DetectSwipe(view, SwipeDirection.Left | SwipeDirection.Right);
101+
Assert.Equal(SwipeDirection.Left, direction);
102+
}
103+
104+
[Fact]
105+
public void SwipedEventDirectionMatchesTotalYTestWithFlags()
106+
{
107+
var view = new View();
108+
var swipe = new SwipeGestureRecognizer();
109+
110+
SwipeDirection direction = SwipeDirection.Left;
111+
swipe.Swiped += (object sender, SwipedEventArgs e) =>
112+
{
113+
direction = e.Direction;
114+
};
115+
116+
((ISwipeGestureController)swipe).SendSwipe(view, totalX: 10, totalY: -150);
117+
((ISwipeGestureController)swipe).DetectSwipe(view, SwipeDirection.Up | SwipeDirection.Down);
118+
Assert.Equal(SwipeDirection.Up, direction);
119+
}
86120
}
87121
}

0 commit comments

Comments
 (0)