Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Update renderers for Stepper and DateTimeSelector #296

Merged
merged 1 commit into from
May 13, 2020

Conversation

shyunMin
Copy link
Collaborator

@shyunMin shyunMin commented May 7, 2020

Description of Change

This PR updates CircleStepperRenderer and CircleDateTimeSelector.
It requires an update of Xamarin.Forms.Platform.Tizen.Native in advance.

API Changes

None

Behavioral Changes

None

Comment on lines 47 to 60
if (Control != null)
{
var surface = this.GetSurface();
if (null != surface)
if (Tizen.Common.DotnetUtil.TizenAPIVersion == 4)
{
var spinner = new ESpinner(XForms.NativeParent, surface);
spinner.Style = "circle";

SetNativeControl(spinner);
Control.ValueChanged += OnValueChanged;

if (Tizen.Common.DotnetUtil.TizenAPIVersion == 4)
{
_listShow = new ElmSharp.SmartEvent(Control, "genlist,show");
_listHide = new ElmSharp.SmartEvent(Control, "genlist,hide");
}
else
{
_listShow = new ElmSharp.SmartEvent(Control, "list,show");
_listHide = new ElmSharp.SmartEvent(Control, "list,hide");
}
_listShow.On += OnListShow;
_listHide.On += OnListHide;
_listShow = new ElmSharp.SmartEvent(Control, "genlist,show");
_listHide = new ElmSharp.SmartEvent(Control, "genlist,hide");
}
else
{
throw new CirclePageNotFoundException();
_listShow = new ElmSharp.SmartEvent(Control, "list,show");
_listHide = new ElmSharp.SmartEvent(Control, "list,hide");
}
}

base.OnElementChanged(e);
}

private void OnValueChanged(object sender, EventArgs e)
{
double newValue = Control.Value;
((IElementController)Element).SetValueFromRenderer(Stepper.ValueProperty, newValue);

if (Element.LabelFormat == null)
{
// Determines how many decimal places are there in current Stepper's value.
// The 15 pound characters below correspond to the maximum precision of Double type.
var decimalValue = Decimal.Parse(newValue.ToString("0.###############"));

// GetBits() method returns an array of four 32-bit integer values.
// The third (0-indexing) element of an array contains the following information:
// bits 00-15: unused, required to be 0
// bits 16-23: an exponent between 0 and 28 indicating the power of 10 to divide the integer number passed as a parameter.
// Conversely this is the number of decimal digits in the number as well.
// bits 24-30: unused, required to be 0
// bit 31: indicates the sign. 0 means positive number, 1 is for negative numbers.
//
// The precision information needs to be extracted from bits 16-23 of third element of an array
// returned by GetBits() call. Right-shifting by 16 bits followed by zeroing anything else results
// in a nice conversion of this data to integer variable.
var precision = (Decimal.GetBits(decimalValue)[3] >> 16) & 0x000000FF;

// Sets Stepper's inner label decimal format to use exactly as many decimal places as needed:
Control.LabelFormat = string.Format("%.{0}f", precision);
_listShow.On += OnListShow;
_listHide.On += OnListHide;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just add the event handler here if native control provides events (e.g., WheelAppeared and WheelDisappeared)

Control.WheelAppeared += OnWheelAppeared;
Control.WheelDisappeared += OnWheelDisappeared;

Copy link
Collaborator Author

@shyunMin shyunMin May 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added two events ListShow/ListHide into native control, and update this PR.

}

void UpdateMarkerColor()
{
#pragma warning disable CS0618 // MarkerColor is obsolete
if (null != Control && null != Element && Element.MarkerColor != Color.Default)
if ((Control is CircleSpinner cSpinner) && (Element is CircleStepper cStepper))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is hard to read, I think, we need to sepate a native widght and XF widget
And no need to check a type, Element always CircleStepper because it is CircleStepper renderer, and Control is always CircleSpinner

  new CircleSpinner Control => base.Control as CircleSpinner;
  new CircleStepper Element => base.Element as CircleStepper;

@rookiejava rookiejava marked this pull request as draft May 11, 2020 01:41
@shyunMin shyunMin changed the title Update inheritance of StepperRenderer Update CircleStepperRenderer and CircleDateTimeSelectorRenderer May 12, 2020
@shyunMin shyunMin changed the title Update CircleStepperRenderer and CircleDateTimeSelectorRenderer Update renderers for CircleStepper and CircleDateTimeSelector May 12, 2020
@shyunMin shyunMin changed the title Update renderers for CircleStepper and CircleDateTimeSelector Update renderers for Stepper and DateTimeSelector May 12, 2020
@shyunMin shyunMin changed the base branch from master to 1.5.0 May 13, 2020 07:08
@rookiejava rookiejava marked this pull request as ready for review May 13, 2020 07:14
@rookiejava rookiejava merged commit b9cd500 into Samsung:1.5.0 May 13, 2020
rookiejava pushed a commit to rookiejava/Tizen.CircularUI that referenced this pull request May 17, 2020
rookiejava pushed a commit to rookiejava/Tizen.CircularUI that referenced this pull request May 19, 2020
rookiejava added a commit that referenced this pull request May 19, 2020
* Refactoring CircularShell Renderer

* Update bezel interaction behavior (#299)

* Refactoring CircularShell Renderer

* Update bezel interaction behavior

* Update OnMoreOptionOpened/Closed

* Update CircleScrollViewRenderer (#300)

* Update CircleScrollViewRenderer

* Obsolete BarColor property in CircleScrollView

* Update the CircleScrollViewRenderer (#301)

* Update CircleStepperRenderer and CircleDateTimeSelectorRenderer (#296)

* Update ActiveBezelInteractionElement on Activate bezel interaction (#302)

* Update CircleListViewRenderer (#303)

* Update CircleListViewRenderer

* Apply Review comment

* Update Bezel Intercation behavior on closing dialog (#304)

* Remove unused ListViewCache

* Update Renderer to use disable rotary event on IBezelInteractionRoutor (#305)

* Fix ExportRenderer (#306)

* Fix CheckRendererer to avoid registerPropertyhandler issue

* Fix build error on WearableGallery

Co-authored-by: Seungkeun Lee <sngn.lee@samsung.com>
Co-authored-by: shmin <shyun.min@samsung.com>
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants