зеркало из https://github.com/DeGsoft/maui-linux.git
slider fix (#1756)
This commit is contained in:
Родитель
d68db632f2
Коммит
896508d36f
|
@ -0,0 +1,45 @@
|
|||
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, 1625, "Slider value is not changed for the first position change", PlatformAffected.Android)]
|
||||
public class Github1625 : TestContentPage // or TestMasterDetailPage, etc ...
|
||||
{
|
||||
protected override void Init()
|
||||
{
|
||||
var slider = new Slider();
|
||||
slider.Maximum = 10;
|
||||
slider.Minimum = 1;
|
||||
slider.Value = 5;
|
||||
|
||||
var valueLabel = new Label();
|
||||
var stack = new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 15 };
|
||||
|
||||
valueLabel.SetBinding(Label.TextProperty, new Binding("Value", source: slider));
|
||||
stack.Children.Add(valueLabel);
|
||||
stack.Children.Add(slider);
|
||||
|
||||
var button = new Button
|
||||
{
|
||||
Text = "Set to 7",
|
||||
Command = new Command(() => slider.Value = 7)
|
||||
};
|
||||
stack.Children.Add(button);
|
||||
|
||||
var label = new Label
|
||||
{
|
||||
Text = "On start, slider value should show 5 even though SeekBar is 4.996. Sliding back and forth should update the label and the tracker. Tapping on a slider position should do the same. Tapping on the button should show 7 even though SeekBar is 6.994."
|
||||
};
|
||||
stack.Children.Add(label);
|
||||
|
||||
Content = stack;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -261,6 +261,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)GitHub1331.xaml.cs">
|
||||
<DependentUpon>GitHub1331.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Github1625.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)InputTransparentTests.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1614.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)IsInvokeRequiredRaceCondition.cs" />
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
public class SliderRenderer : ViewRenderer<Slider, SeekBar>, SeekBar.IOnSeekBarChangeListener
|
||||
{
|
||||
double _max, _min;
|
||||
bool _progressChangedOnce;
|
||||
bool _isTrackingChange;
|
||||
|
||||
public SliderRenderer(Context context) : base(context)
|
||||
{
|
||||
|
@ -31,21 +31,18 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
void SeekBar.IOnSeekBarChangeListener.OnProgressChanged(SeekBar seekBar, int progress, bool fromUser)
|
||||
{
|
||||
if (!_progressChangedOnce)
|
||||
{
|
||||
_progressChangedOnce = true;
|
||||
return;
|
||||
}
|
||||
|
||||
((IElementController)Element).SetValueFromRenderer(Slider.ValueProperty, Value);
|
||||
if (_isTrackingChange)
|
||||
((IElementController)Element).SetValueFromRenderer(Slider.ValueProperty, Value);
|
||||
}
|
||||
|
||||
void SeekBar.IOnSeekBarChangeListener.OnStartTrackingTouch(SeekBar seekBar)
|
||||
{
|
||||
_isTrackingChange = true;
|
||||
}
|
||||
|
||||
void SeekBar.IOnSeekBarChangeListener.OnStopTrackingTouch(SeekBar seekBar)
|
||||
{
|
||||
_isTrackingChange = false;
|
||||
}
|
||||
|
||||
protected override SeekBar CreateNativeControl()
|
||||
|
|
Загрузка…
Ссылка в новой задаче