This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…6992 fixes #11650 fixes #7655 fixes #11657 fixes #10520 fixes #4829 * improved span region calculation on android * Remove unused code * Nit: clean up comments * Wrap in ScrollView for small screen compatibility Co-authored-by: Tim Dittmar <Tim.Dittmar@Exxeta.com> Co-authored-by: Rachel Kang <rachel.j.kang@gmail.com> Co-authored-by: Rachel Kang <rachelkang@microsoft.com>
- Loading branch information
1 parent
6dfd32d
commit ca19c01
Showing
5 changed files
with
221 additions
and
35 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4143.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,105 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<controls:TestContentPage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:controls="clr-namespace:Xamarin.Forms.Controls" | ||
xmlns:system="clr-namespace:System;assembly=mscorlib" | ||
x:Name="This" | ||
x:Class="Xamarin.Forms.Controls.Issues.Issue4143"> | ||
|
||
<ScrollView> | ||
<StackLayout> | ||
<Label | ||
Text="This test is passed if all tappable spans (blue and underlined texts) react to touches by changing its background color. Only the touched span should react and not others."/> | ||
|
||
<Label | ||
Margin="10" | ||
HorizontalOptions="Center" | ||
TextColor="Black" | ||
BackgroundColor="CadetBlue"> | ||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="Two clickable spans in one line: " /> | ||
<Span | ||
x:Name="Link1" | ||
TextDecorations="Underline" | ||
Text="Link1" | ||
TextColor="Blue"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Tapped="OnLink1Tapped"/> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
<Span Text=" " /> | ||
<Span | ||
x:Name="Link2" | ||
Text="Link2 " | ||
TextDecorations="Underline" | ||
TextColor="Blue"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Tapped="OnLink2Tapped" /> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
|
||
<Span Text="Multiline tappable span: " /> | ||
<Span | ||
x:Name="Link3" | ||
TextDecorations="Underline" | ||
Text="Link3_1 Link3_2" | ||
TextColor="Blue"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Tapped="OnLink3Tapped" /> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
|
||
<Label | ||
Margin="10" | ||
HorizontalOptions="Center" | ||
VerticalOptions="CenterAndExpand" | ||
Padding="10,20" | ||
BackgroundColor="CadetBlue"> | ||
|
||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="Clickable Span in a Label with padding: " /> | ||
<Span | ||
x:Name="Link4" | ||
Text="Link4" | ||
TextDecorations="Underline" | ||
TextColor="Blue"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Tapped="OnLink4Tapped"/> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
|
||
<Label | ||
Margin = "10" | ||
FlowDirection="RightToLeft" | ||
TextColor="Black" | ||
BackgroundColor="CadetBlue"> | ||
|
||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي." /> | ||
<Span Text="{x:Static system:Environment.NewLine}"/> | ||
<Span | ||
x:Name="Link5" | ||
Text="و سأعرض مثال حي لهذا، من منا لم يتحمل جهد بدني شاق إلا من أجل الحصول على ميزة أو فائدة؟ ولكن من لديه الحق أن ينتقد شخص ما أراد أن يشعر بالسعادة التي لا تشوبها عواقب أليمة أو آخر أراد أن يتجنب الألم الذي ربما تنجم عنه بعض المتعة ؟ " | ||
TextDecorations="Underline" | ||
TextColor="Blue"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Tapped="OnLink5Tapped" /> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
<Span Text="علي الجانب الآخر نشجب ونستنكر هؤلاء الرجال المفتونون بنشوة اللحظة الهائمون في رغباتهم فلا يدركون ما يعقبها من الألم والأسي المحتم، واللوم كذلك يشمل هؤلاء الذين أخفقوا في واجباتهم نتيجة لضعف إرادتهم فيتساوي مع هؤلاء الذين يتجنبون وينأون عن تحمل الكدح والألم ." /> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
|
||
</StackLayout> | ||
</ScrollView> | ||
</controls:TestContentPage> |
61 changes: 61 additions & 0 deletions
61
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4143.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,61 @@ | ||
using System; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 4143, "Span inaccuracies", PlatformAffected.Android)] | ||
public partial class Issue4143 : TestContentPage | ||
{ | ||
Color[] _colors = new Color[]{ Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.Brown, Color.Purple, Color.Orange, Color.Gray }; | ||
Random _rand = new Random(); | ||
|
||
protected override void Init() | ||
{ | ||
#if APP | ||
InitializeComponent(); | ||
#endif | ||
} | ||
|
||
#if APP | ||
void OnLink1Tapped(object sender, EventArgs e) | ||
{ | ||
SetRandomBackgroundColor(Link1); | ||
} | ||
void OnLink2Tapped(object sender, EventArgs e) | ||
{ | ||
SetRandomBackgroundColor(Link2); | ||
} | ||
void OnLink3Tapped(object sender, EventArgs e) | ||
{ | ||
SetRandomBackgroundColor(Link3); | ||
} | ||
void OnLink4Tapped(object sender, EventArgs e) | ||
{ | ||
SetRandomBackgroundColor(Link4); | ||
} | ||
void OnLink5Tapped(object sender, EventArgs e) | ||
{ | ||
SetRandomBackgroundColor(Link5); | ||
} | ||
#endif | ||
|
||
void SetRandomBackgroundColor(Span span) | ||
{ | ||
var oldColor = span.BackgroundColor; | ||
Color newColor; | ||
do | ||
{ | ||
newColor = _colors[_rand.Next(_colors.Length)]; | ||
} while(oldColor == newColor); | ||
|
||
span.BackgroundColor = newColor; | ||
} | ||
} | ||
} |
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