NotifyPropertyChanged();
}
}
-
- /// <summary>
- /// for the case of ContentPage, it sets key focus on AppBar's NavigationContent
- /// </summary>
- protected internal override void RestoreKeyFocus()
- {
- if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
- {
- if (base.LastFocusedView)
- {
- FocusManager.Instance.SetCurrentFocusView(this.LastFocusedView);
- }
- else
- {
- if (AppBar != null && AppBar.NavigationContent != null && AppBar.NavigationContent.Focusable)
- {
- FocusManager.Instance.SetCurrentFocusView(AppBar.NavigationContent);
- }
- else
- {
- FocusManager.Instance.ClearFocus();
- }
- }
- }
- }
-
private View InternalContent
{
get
page.InvokeAppearing();
curTop.InvokeDisappearing();
- curTop.SaveKeyFocus();
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // curTop.LastFocusedView = FocusManager.Instance.GetCurrentFocusView();
+ // if(page.LastFocusedView)
+ // {
+ // FocusManager.Instance.SetCurrentFocusView(page.LastFocusedView);
+ // }
+ // else
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // }
+ // }
//TODO: The following transition codes will be replaced with view transition.
InitializeAnimation();
page.InvokeAppeared();
NotifyAccessibilityStatesChangeOfPages(curTop, page);
- page.RestoreKeyFocus();
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // //FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // }
+
};
newAnimation.Play();
}
else
{
ShowContentOfPage(page);
- page.RestoreKeyFocus();
}
+
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // }
}
/// <summary>
//Invoke Page events
newTop.InvokeAppearing();
curTop.InvokeDisappearing();
- curTop.SaveKeyFocus();
+
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // curTop.LastFocusedView = FocusManager.Instance.GetCurrentFocusView();
+ // if(newTop.LastFocusedView)
+ // {
+ // FocusManager.Instance.SetCurrentFocusView(newTop.LastFocusedView);
+ // }
+ // else
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // }
+ // }
//TODO: The following transition codes will be replaced with view transition.
InitializeAnimation();
//Invoke Page events
newTop.InvokeAppeared();
- newTop.RestoreKeyFocus();
+
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // //FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // }
+
+
};
newAnimation.Play();
}
Remove(curTop);
}
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // if(newTop.LastFocusedView)
+ // {
+ // FocusManager.Instance.SetCurrentFocusView(newTop.LastFocusedView);
+ // }
+ // }
+
+ // //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // }
+
return curTop;
}
return instance.InternalDisappearingTransition;
});
- protected internal BaseComponents.View LastFocusedView = null;
+ internal BaseComponents.View LastFocusedView = null;
private Navigator navigator = null;
{
Disappeared?.Invoke(this, new PageDisappearedEventArgs());
}
-
- /// <summary>
- /// works only when DefaultAlgorithm is enabled.
- /// to save the currentl focused View when disappeared.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected internal virtual void SaveKeyFocus()
- {
- if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
- {
- var currentFocusedView = FocusManager.Instance.GetCurrentFocusView();
- if (currentFocusedView)
- {
- var findChild = this.FindDescendantByID(currentFocusedView.ID);
- if (findChild)
- {
- this.LastFocusedView = findChild;
- return;
- }
- }
- this.LastFocusedView = null;
- }
- }
-
- /// <summary>
- /// works only when DefaultAlgorithm is enabled.
- /// to set key focused View when showing.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected internal virtual void RestoreKeyFocus()
- {
- if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
- {
- if (this.LastFocusedView)
- {
- FocusManager.Instance.SetCurrentFocusView(this.LastFocusedView);
- }
- else
- {
- var temp = new Tizen.NUI.BaseComponents.View()
- {
- Size = new Size(0.1f, 0.1f, 0.0f),
- Position = new Position(0, 0, 0),
- Focusable = true,
- };
- this.Add(temp);
- temp.LowerToBottom();
- FocusManager.Instance.SetCurrentFocusView(temp);
- var focused = FocusManager.Instance.GetNearestFocusableActor(this, temp, Tizen.NUI.BaseComponents.View.FocusDirection.Down);
- if (focused)
- {
- FocusManager.Instance.SetCurrentFocusView(focused);
- }
- else
- {
- FocusManager.Instance.ClearFocus();
- }
- temp.Unparent();
- temp.Dispose();
- }
- }
-
- }
-
}
}
/// TimeChangedEventArgs default constructor.
/// <param name="time">time value of TimePicker.</param>
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public TimeChangedEventArgs(DateTime time)
{
Time = time;
/// <since_tizen> 9 </since_tizen>
public TimePicker()
{
- SetKeyboardNavigationSupport(true);
}
/// <summary>
/// <since_tizen> 9 </since_tizen>
public TimePicker(string style) : base(style)
{
- SetKeyboardNavigationSupport(true);
}
/// <summary>
/// <since_tizen> 9 </since_tizen>
public TimePicker(TimePickerStyle timePickerStyle) : base(timePickerStyle)
{
- SetKeyboardNavigationSupport(true);
}
/// <summary>
else hourPicker.CurrentValue = currentTime.Hour - 12;
ampmPicker.CurrentValue = 2;
}
- else
+ else
{
isAm = true;
if (currentTime.Hour == 0) hourPicker.CurrentValue = 12;
hourPicker.MaxValue = 23;
hourPicker.CurrentValue = currentTime.Hour;
}
- else
+ else
{
hourPicker.MinValue = 1;
hourPicker.MaxValue = 12;
{
MinValue = 1,
MaxValue = 12,
- Focusable = true,
};
hourPicker.ValueChanged += OnHourValueChanged;
{
MinValue = 0,
MaxValue = 59,
- Focusable = true,
};
minutePicker.ValueChanged += OnMinuteValueChanged;
{
MinValue = 1,
MaxValue = 2,
- Focusable = true,
};
ampmPicker.ValueChanged += OnAmpmValueChanged;
//Apply CellPadding.
if (timePickerStyle?.CellPadding != null && Layout != null)
((LinearLayout)Layout).CellPadding = new Size2D(timePickerStyle.CellPadding.Width, timePickerStyle.CellPadding.Height);
-
+
//Apply Internal Pickers style.
if (timePickerStyle?.Pickers != null && hourPicker != null && minutePicker != null && ampmPicker != null)
{
ampmPicker.ApplyStyle(timePickerStyle.Pickers);
}
}
-
- /// <summary>
- /// ToDo : only key navigation is enabled, but value editing is not yet added. for example, after enter key and up/down key the value need be changed.
- /// </summary>
- /// <param name="currentFocusedView"></param>
- /// <param name="direction"></param>
- /// <param name="loopEnabled"></param>
- /// <returns></returns>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
- {
- if (currentFocusedView == hourPicker)
- {
- if (direction == View.FocusDirection.Right)
- {
- return minutePicker;
- }
- else if (direction == View.FocusDirection.Left)
- {
- return null;
- }
- }
- else if (currentFocusedView == minutePicker)
- {
- if (direction == View.FocusDirection.Right)
- {
- return ampmPicker;
- }
- else if (direction == View.FocusDirection.Left)
- {
- return hourPicker;
- }
- }
- else if (currentFocusedView == ampmPicker)
- {
- if (direction == View.FocusDirection.Right)
- {
- return null;
- }
- else if (direction == View.FocusDirection.Left)
- {
- return minutePicker;
- }
- }
-
- Tizen.Log.Fatal("NUITEST", $"type={currentFocusedView.GetType()}, direction={direction}");
-
- return null;
- }
-
-
+
[SuppressMessage("Microsoft.Reliability",
"CA2000:DisposeObjectsBeforeLosingScope",
Justification = "The CellPadding will be dispose when the time picker disposed")]
{
HeightSpecification = LayoutParamPolicies.MatchParent;
- Layout = new LinearLayout()
- {
+ Layout = new LinearLayout() {
LinearOrientation = LinearLayout.Orientation.Horizontal,
};
Console.WriteLine("initialize");
if (!is24HourView)
{
- if (isAm)
+ if (isAm)
{
if (e.Value == 12) ChangeTime(0, 0, true);
else ChangeTime(e.Value, 0, true);
}
- else
+ else
{
if (e.Value == 12) ChangeTime(12, 0, true);
else ChangeTime(e.Value + 12, 0, true);
}
else
ChangeTime(e.Value, 0, true);
-
+
OnTimeChanged();
}
private void OnMinuteValueChanged(object sender, ValueChangedEventArgs e)
- {
+ {
if (currentTime.Minute == e.Value) return;
ChangeTime(0, e.Value, false);
}
private void OnAmpmValueChanged(object sender, ValueChangedEventArgs e)
- {
+ {
if ((isAm && e.Value == 1) || (!isAm && e.Value == 2)) return;
if (e.Value == 1)
isAm = true;
}
- else
+ else
{ //PM
if (currentTime.Hour == 0) ChangeTime(12, 0, true);
else ChangeTime(currentTime.Hour + 12, 0, true);
}
private void OnTimeChanged()
- {
+ {
TimeChangedEventArgs eventArgs = new TimeChangedEventArgs(currentTime);
TimeChanged?.Invoke(this, eventArgs);
}
String timePattern = timeFormatInfo.ShortTimePattern;
String[] timePatternArray = timePattern.Split(' ', ':');
- foreach (String format in timePatternArray)
- {
- if (format.IndexOf("H") != -1 || format.IndexOf("h") != -1) Add(hourPicker);
+ foreach (String format in timePatternArray) {
+ if (format.IndexOf("H") != -1|| format.IndexOf("h") != -1) Add(hourPicker);
else if (format.IndexOf("M") != -1 || format.IndexOf("m") != -1) Add(minutePicker);
- else if (format.IndexOf("t") != -1)
+ else if (format.IndexOf("t") != -1)
{
is24HourView = false;
ampmForceSet = false;
//FIXME: There is no localeChanged Event for Component now
// AMPM text has to update when system locale changed.
CultureInfo info = CultureInfo.CurrentCulture;
- ampmText = new string[] { info.DateTimeFormat.AMDesignator, info.DateTimeFormat.PMDesignator };
+ ampmText = new string[] {info.DateTimeFormat.AMDesignator, info.DateTimeFormat.PMDesignator};
ampmPicker.DisplayedValues = new ReadOnlyCollection<string>(ampmText);
}
}
+++ /dev/null
-/*
- * Copyright(c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-using System;
-using System.ComponentModel;
-using Tizen.NUI;
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Components;
-
-namespace Tizen.NUI.StyleGuide
-{
- // IExample inehrited class will be automatically added in the main examples list.
- internal class PickerExample : ContentPage, IExample
- {
- private Window window;
- private View rootContent;
- private TimePicker timePicker;
- private TextLabel label;
- private Button button;
-
- public void Activate()
- {
- }
- public void Deactivate()
- {
- window = null;
- }
-
- /// Modify this method for adding other examples.
- public PickerExample() : base()
- {
- WidthSpecification = LayoutParamPolicies.MatchParent;
- HeightSpecification = LayoutParamPolicies.MatchParent;
-
- // Navigator bar title is added here.
- AppBar = new AppBar()
- {
- Title = "Picker Default Style",
- };
-
- // Example root content view.
- // you can decorate, add children on this view.
- rootContent = new View()
- {
- WidthSpecification = LayoutParamPolicies.MatchParent,
- HeightSpecification = LayoutParamPolicies.MatchParent,
-
- Layout = new LinearLayout()
- {
- LinearOrientation = LinearLayout.Orientation.Vertical,
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Center,
- CellPadding = new Size2D(10, 20),
- },
- };
-
- // Picker style examples.
- timePicker = new TimePicker()
- {
- WidthSpecification = LayoutParamPolicies.MatchParent,
- Time = DateTime.Now
- };
- rootContent.Add(timePicker);
-
-
- label = new TextLabel
- {
- WidthSpecification = LayoutParamPolicies.MatchParent,
- Text = $"Time: {timePicker.Time.ToString()}"
- };
- rootContent.Add(label);
-
- button = new Tizen.NUI.Components.Button
- {
- WidthSpecification = LayoutParamPolicies.MatchParent,
- Text = "set time"
- };
- rootContent.Add(button);
-
- button.Clicked += (s, e) =>
- {
- label.Text = $"Time: {timePicker.Time.ToString()}";
- };
-
- Content = rootContent;
- }
- }
-}