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.
- Loading branch information
Showing
4 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1760.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.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 1760, "Content set after an await is not visible", PlatformAffected.Android)] | ||
public class Issue1760 : TestMasterDetailPage | ||
{ | ||
const string Before = "Before"; | ||
const string After = "After"; | ||
const int Wait = 3; | ||
|
||
protected override void Init() | ||
{ | ||
Master = new _1760Master(); | ||
Detail = new _1760TestPage(); | ||
IsPresented = true; | ||
} | ||
|
||
[Preserve(AllMembers = true)] | ||
public class _1760Master : ContentPage | ||
{ | ||
public _1760Master() | ||
{ | ||
var instructions = new Label { Text = $"Select one of the menu items. The detail page text should change to {Before}. After {Wait} seconds the text should change to {After}." }; | ||
|
||
var menuView = new ListView(ListViewCachingStrategy.RetainElement) | ||
{ | ||
ItemsSource = new List<string> { "Test Page 1", "Test Page 2" } | ||
}; | ||
|
||
menuView.ItemSelected += OnMenuClicked; | ||
|
||
Content = new StackLayout{Children = { instructions, menuView }}; | ||
Title = "GH 1760 Test App"; | ||
} | ||
|
||
void OnMenuClicked(object sender, SelectedItemChangedEventArgs e) | ||
{ | ||
var mainPage = (MasterDetailPage)Parent; | ||
mainPage.Detail = new _1760TestPage(); | ||
mainPage.IsPresented = false; | ||
} | ||
} | ||
|
||
[Preserve(AllMembers = true)] | ||
public class _1760TestPage : ContentPage | ||
{ | ||
public async Task DisplayPage() | ||
{ | ||
IsBusy = true; | ||
HeaderPageContent = new Label {Text = Before, TextColor = Color.Black}; | ||
|
||
await Task.Delay(Wait * 1000); | ||
|
||
HeaderPageContent = new Label { Text = After, TextColor = Color.Black}; | ||
IsBusy = false; | ||
} | ||
|
||
ContentView _headerPageContent; | ||
public View HeaderPageContent | ||
{ | ||
set => _headerPageContent.Content = value; | ||
} | ||
|
||
public _1760TestPage() | ||
{ | ||
CreateHeaderPage(); | ||
DisplayPage(); | ||
} | ||
|
||
void CreateHeaderPage() | ||
{ | ||
|
||
_headerPageContent = new ContentView | ||
{ | ||
Content = new Label { Text = "_1760 Test Page Content" }, | ||
BackgroundColor = Color.White, | ||
Margin = 40 | ||
}; | ||
|
||
Title = "_1760 Test Page"; | ||
|
||
Content = new ScrollView | ||
{ | ||
Content = _headerPageContent | ||
}; | ||
} | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2595.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,90 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Timers; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 2595, "ScrollView.Content is not re-layouted on Android", PlatformAffected.Android)] | ||
public class Issue2595 : TestMasterDetailPage | ||
{ | ||
protected override void Init() | ||
{ | ||
Master = new _2595Master(); | ||
Detail = new _2595ScrollPage(); | ||
IsPresented = true; | ||
} | ||
|
||
[Preserve(AllMembers = true)] | ||
public class _2595Master : ContentPage | ||
{ | ||
public _2595Master() | ||
{ | ||
var instructions = new Label { Text = $"Select one of the menu items. The detail page text should " | ||
+ $"display a label which disappears after 1 second and is" | ||
+ $" replaced by an updating list of labels which grows vertically." }; | ||
|
||
var menuView = new ListView(ListViewCachingStrategy.RetainElement) | ||
{ | ||
ItemsSource = new List<string> { "Test Page 1", "Test Page 2" } | ||
}; | ||
|
||
menuView.ItemSelected += OnMenuClicked; | ||
|
||
Content = new StackLayout{Children = { instructions, menuView }}; | ||
Title = "GH 2595 Test App"; | ||
} | ||
|
||
void OnMenuClicked(object sender, SelectedItemChangedEventArgs e) | ||
{ | ||
var mainPage = (MasterDetailPage)Parent; | ||
mainPage.Detail = new _2595ScrollPage (); | ||
mainPage.IsPresented = false; | ||
} | ||
} | ||
|
||
[Preserve(AllMembers = true)] | ||
public class _2595ScrollPage : ContentPage | ||
{ | ||
readonly Timer _timer = new Timer(1000); | ||
protected Label Label; | ||
|
||
public _2595ScrollPage() { | ||
Content = new ScrollView { | ||
|
||
BackgroundColor = Color.Red, | ||
|
||
Content = new StackLayout { | ||
BackgroundColor = Color.BlueViolet, | ||
Children = { | ||
(Label = new Label { | ||
Text = "this text should disappear after 1 sec", | ||
BackgroundColor = Color.LightBlue, | ||
HorizontalOptions = LayoutOptions.StartAndExpand, | ||
}) | ||
} | ||
} | ||
}; | ||
} | ||
|
||
protected StackLayout ScrollContent { | ||
get => (Content as ScrollView).Content as StackLayout; | ||
set => (Content as ScrollView).Content = value; | ||
} | ||
|
||
protected override void OnAppearing() { | ||
base.OnAppearing(); | ||
_timer.Elapsed += (s, e) => Device.BeginInvokeOnMainThread(OnTimerElapsed); | ||
|
||
_timer.Start(); | ||
} | ||
|
||
void OnTimerElapsed() { | ||
Label.Text = $"{ DateTime.Now.ToString() }: expecting {ScrollContent?.Children.Count} dates to show up."; | ||
ScrollContent.Children.Add(new Label { Text = DateTime.Now.ToString() }); | ||
} | ||
} | ||
} | ||
} |
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