Implemented colored refresh indicator for ListView pull-to-refresh (#2961)
* Implemented colored spinner for ListView pull-to-refresh * Added back default spinner color * Renamed away from "spinner" and did some default value magic Color.Default reinstated, but also added the default black color in the iOS `UpdateRefreshControlColor` method. Seeing this also happens for the seperator color this is something that is necessary. If not, the spinner is invisible. * Implemented default color on iOS and right property name on Android For iOS, when the new `RefreshControlColor` has the default color, the `TintColor` for iOS is set to null, causing the color to be the default one. Forgot to refactor the new name in the Android renderer, whoops * Reinstated coloring on listview gallry page * Implemented colored spinner for ListView pull-to-refresh * Added back default spinner color * Renamed away from "spinner" and did some default value magic Color.Default reinstated, but also added the default black color in the iOS `UpdateRefreshControlColor` method. Seeing this also happens for the seperator color this is something that is necessary. If not, the spinner is invisible. * Implemented default color on iOS and right property name on Android For iOS, when the new `RefreshControlColor` has the default color, the `TintColor` for iOS is set to null, causing the color to be the default one. Forgot to refactor the new name in the Android renderer, whoops * Reinstated coloring on listview gallry page * Added documentation for new property * Fixed merge boo-boos
This commit is contained in:
Родитель
43eb6b37db
Коммит
0d08fd8254
|
@ -4,8 +4,8 @@ using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms.CustomAttributes;
|
using Xamarin.Forms.CustomAttributes;
|
||||||
using System.Threading;
|
|
||||||
using Xamarin.Forms.Internals;
|
using Xamarin.Forms.Internals;
|
||||||
|
|
||||||
using Xamarin.Forms.PlatformConfiguration;
|
using Xamarin.Forms.PlatformConfiguration;
|
||||||
|
@ -267,6 +267,16 @@ namespace Xamarin.Forms.Controls
|
||||||
fastScrollItemContainer.View.On<Android>().SetIsFastScrollEnabled(true);
|
fastScrollItemContainer.View.On<Android>().SetIsFastScrollEnabled(true);
|
||||||
fastScrollItemContainer.View.ItemsSource = viewModel.CategorizedEmployees;
|
fastScrollItemContainer.View.ItemsSource = viewModel.CategorizedEmployees;
|
||||||
|
|
||||||
|
var refreshControlColorContainer = new ViewContainer<ListView>(Test.ListView.RefreshControlColor, new ListView());
|
||||||
|
InitializeElement(refreshControlColorContainer.View);
|
||||||
|
refreshControlColorContainer.View.RefreshControlColor = Color.Red;
|
||||||
|
refreshControlColorContainer.View.IsPullToRefreshEnabled = true;
|
||||||
|
refreshControlColorContainer.View.Refreshing += async (object sender, EventArgs e) => {
|
||||||
|
await Task.Delay(2000);
|
||||||
|
refreshControlColorContainer.View.IsRefreshing = false;
|
||||||
|
};
|
||||||
|
refreshControlColorContainer.View.ItemsSource = viewModel.Employees;
|
||||||
|
|
||||||
var scrollbarVisibilityContainer = new ViewContainer<ListView>(Test.ListView.ScrollBarVisibility, new ListView());
|
var scrollbarVisibilityContainer = new ViewContainer<ListView>(Test.ListView.ScrollBarVisibility, new ListView());
|
||||||
InitializeElement(scrollbarVisibilityContainer.View);
|
InitializeElement(scrollbarVisibilityContainer.View);
|
||||||
scrollbarVisibilityContainer.View.HorizontalScrollBarVisibility = ScrollBarVisibility.Never;
|
scrollbarVisibilityContainer.View.HorizontalScrollBarVisibility = ScrollBarVisibility.Never;
|
||||||
|
@ -287,6 +297,7 @@ namespace Xamarin.Forms.Controls
|
||||||
Add(rowHeightContainer);
|
Add(rowHeightContainer);
|
||||||
Add(selectedItemContainer);
|
Add(selectedItemContainer);
|
||||||
Add(fastScrollItemContainer);
|
Add(fastScrollItemContainer);
|
||||||
|
Add(refreshControlColorContainer);
|
||||||
Add(scrollbarVisibilityContainer);
|
Add(scrollbarVisibilityContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,8 @@ namespace Xamarin.Forms
|
||||||
|
|
||||||
public static readonly BindableProperty SeparatorColorProperty = BindableProperty.Create("SeparatorColor", typeof(Color), typeof(ListView), Color.Default);
|
public static readonly BindableProperty SeparatorColorProperty = BindableProperty.Create("SeparatorColor", typeof(Color), typeof(ListView), Color.Default);
|
||||||
|
|
||||||
|
public static readonly BindableProperty RefreshControlColorProperty = BindableProperty.Create(nameof(RefreshControlColor), typeof(Color), typeof(ListView), Color.Default);
|
||||||
|
|
||||||
public static readonly BindableProperty HorizontalScrollBarVisibilityProperty = BindableProperty.Create(nameof(HorizontalScrollBarVisibility), typeof(ScrollBarVisibility), typeof(ListView), ScrollBarVisibility.Default);
|
public static readonly BindableProperty HorizontalScrollBarVisibilityProperty = BindableProperty.Create(nameof(HorizontalScrollBarVisibility), typeof(ScrollBarVisibility), typeof(ListView), ScrollBarVisibility.Default);
|
||||||
|
|
||||||
public static readonly BindableProperty VerticalScrollBarVisibilityProperty = BindableProperty.Create(nameof(VerticalScrollBarVisibility), typeof(ScrollBarVisibility), typeof(ListView), ScrollBarVisibility.Default);
|
public static readonly BindableProperty VerticalScrollBarVisibilityProperty = BindableProperty.Create(nameof(VerticalScrollBarVisibility), typeof(ScrollBarVisibility), typeof(ListView), ScrollBarVisibility.Default);
|
||||||
|
@ -223,6 +225,12 @@ namespace Xamarin.Forms
|
||||||
set { SetValue(SeparatorColorProperty, value); }
|
set { SetValue(SeparatorColorProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Color RefreshControlColor
|
||||||
|
{
|
||||||
|
get { return (Color)GetValue(RefreshControlColorProperty); }
|
||||||
|
set { SetValue(RefreshControlColorProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
public SeparatorVisibility SeparatorVisibility
|
public SeparatorVisibility SeparatorVisibility
|
||||||
{
|
{
|
||||||
get { return (SeparatorVisibility)GetValue(SeparatorVisibilityProperty); }
|
get { return (SeparatorVisibility)GetValue(SeparatorVisibilityProperty); }
|
||||||
|
|
|
@ -431,6 +431,7 @@ namespace Xamarin.Forms.CustomAttributes
|
||||||
GroupShortNameBinding,
|
GroupShortNameBinding,
|
||||||
ScrollTo,
|
ScrollTo,
|
||||||
FastScroll,
|
FastScroll,
|
||||||
|
RefreshControlColor,
|
||||||
ScrollBarVisibility
|
ScrollBarVisibility
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,7 @@ namespace Xamarin.Forms.Platform.Android
|
||||||
UpdateIsSwipeToRefreshEnabled();
|
UpdateIsSwipeToRefreshEnabled();
|
||||||
UpdateFastScrollEnabled();
|
UpdateFastScrollEnabled();
|
||||||
UpdateSelectionMode();
|
UpdateSelectionMode();
|
||||||
|
UpdateSpinnerColor();
|
||||||
UpdateHorizontalScrollBarVisibility();
|
UpdateHorizontalScrollBarVisibility();
|
||||||
UpdateVerticalScrollBarVisibility();
|
UpdateVerticalScrollBarVisibility();
|
||||||
}
|
}
|
||||||
|
@ -217,6 +218,8 @@ namespace Xamarin.Forms.Platform.Android
|
||||||
UpdateFastScrollEnabled();
|
UpdateFastScrollEnabled();
|
||||||
else if (e.PropertyName == ListView.SelectionModeProperty.PropertyName)
|
else if (e.PropertyName == ListView.SelectionModeProperty.PropertyName)
|
||||||
UpdateSelectionMode();
|
UpdateSelectionMode();
|
||||||
|
else if (e.PropertyName == ListView.RefreshControlColorProperty.PropertyName)
|
||||||
|
UpdateSpinnerColor();
|
||||||
else if (e.PropertyName == ScrollView.HorizontalScrollBarVisibilityProperty.PropertyName)
|
else if (e.PropertyName == ScrollView.HorizontalScrollBarVisibilityProperty.PropertyName)
|
||||||
UpdateHorizontalScrollBarVisibility();
|
UpdateHorizontalScrollBarVisibility();
|
||||||
else if (e.PropertyName == ScrollView.VerticalScrollBarVisibilityProperty.PropertyName)
|
else if (e.PropertyName == ScrollView.VerticalScrollBarVisibilityProperty.PropertyName)
|
||||||
|
@ -419,6 +422,12 @@ namespace Xamarin.Forms.Platform.Android
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateSpinnerColor()
|
||||||
|
{
|
||||||
|
if (_refresh != null)
|
||||||
|
_refresh.SetColorSchemeColors(Element.RefreshControlColor.ToAndroid());
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateHorizontalScrollBarVisibility()
|
void UpdateHorizontalScrollBarVisibility()
|
||||||
{
|
{
|
||||||
if (_defaultHorizontalScrollVisibility == 0)
|
if (_defaultHorizontalScrollVisibility == 0)
|
||||||
|
|
|
@ -249,6 +249,7 @@ namespace Xamarin.Forms.Platform.iOS
|
||||||
UpdateSeparatorColor();
|
UpdateSeparatorColor();
|
||||||
UpdateSeparatorVisibility();
|
UpdateSeparatorVisibility();
|
||||||
UpdateSelectionMode();
|
UpdateSelectionMode();
|
||||||
|
UpdateSpinnerColor();
|
||||||
UpdateVerticalScrollBarVisibility();
|
UpdateVerticalScrollBarVisibility();
|
||||||
UpdateHorizontalScrollBarVisibility();
|
UpdateHorizontalScrollBarVisibility();
|
||||||
|
|
||||||
|
@ -289,6 +290,8 @@ namespace Xamarin.Forms.Platform.iOS
|
||||||
UpdatePullToRefreshEnabled();
|
UpdatePullToRefreshEnabled();
|
||||||
else if (e.PropertyName == Xamarin.Forms.ListView.SelectionModeProperty.PropertyName)
|
else if (e.PropertyName == Xamarin.Forms.ListView.SelectionModeProperty.PropertyName)
|
||||||
UpdateSelectionMode();
|
UpdateSelectionMode();
|
||||||
|
else if (e.PropertyName == Xamarin.Forms.ListView.RefreshControlColorProperty.PropertyName)
|
||||||
|
UpdateSpinnerColor();
|
||||||
else if (e.PropertyName == ScrollView.VerticalScrollBarVisibilityProperty.PropertyName)
|
else if (e.PropertyName == ScrollView.VerticalScrollBarVisibilityProperty.PropertyName)
|
||||||
UpdateVerticalScrollBarVisibility();
|
UpdateVerticalScrollBarVisibility();
|
||||||
else if (e.PropertyName == ScrollView.HorizontalScrollBarVisibilityProperty.PropertyName)
|
else if (e.PropertyName == ScrollView.HorizontalScrollBarVisibilityProperty.PropertyName)
|
||||||
|
@ -682,6 +685,14 @@ namespace Xamarin.Forms.Platform.iOS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateSpinnerColor()
|
||||||
|
{
|
||||||
|
var color = Element.RefreshControlColor;
|
||||||
|
|
||||||
|
if (_tableViewController != null)
|
||||||
|
_tableViewController.UpdateRefreshControlColor(color == Color.Default ? null : color.ToUIColor());
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateVerticalScrollBarVisibility()
|
void UpdateVerticalScrollBarVisibility()
|
||||||
{
|
{
|
||||||
if (_defaultVerticalScrollVisibility == null)
|
if (_defaultVerticalScrollVisibility == null)
|
||||||
|
@ -1463,6 +1474,12 @@ namespace Xamarin.Forms.Platform.iOS
|
||||||
UpdateIsRefreshing(true);
|
UpdateIsRefreshing(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateRefreshControlColor(UIColor color)
|
||||||
|
{
|
||||||
|
if (RefreshControl != null)
|
||||||
|
RefreshControl.TintColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (_disposed)
|
if (_disposed)
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче