{
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create("ListPadding", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create(nameof(ListPadding), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
+ var instance = (DropDown)bindable;
if (newValue != null)
{
- instance.privateListPadding = (Extents)newValue;
+ instance.listPadding.CopyFrom((Extents)newValue);
+ instance.UpdateDropDown();
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateListPadding;
+ var instance = (DropDown)bindable;
+ return instance.listPadding;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ListSizeProperty = BindableProperty.Create("ListSize", typeof(Size), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create(nameof(SelectedItemIndex), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
+ var instance = (DropDown)bindable;
if (newValue != null)
{
- instance.privateListSize = (Size)newValue;
- }
- },
- defaultValueCreator: (bindable) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateListSize;
- });
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create("SelectedItemIndex", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- if (newValue != null)
- {
- instance.privateSelectedItemIndex = (int)newValue;
- }
- },
- defaultValueCreator: (bindable) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateSelectedItemIndex;
- });
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty FocusedItemIndexProperty = BindableProperty.Create("FocusedItemIndex", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- if (newValue != null)
- {
- instance.privateFocusedItemIndex = (int)newValue;
- }
- },
- defaultValueCreator: (bindable) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateFocusedItemIndex;
- });
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ListMarginProperty = BindableProperty.Create("ListMargin", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- if (newValue != null)
- {
- instance.privateListMargin = (Extents)newValue;
+ int selectedItemIndex = (int)newValue;
+ if (selectedItemIndex == instance.selectedItemIndex || instance.adapter == null || selectedItemIndex >= instance.adapter.GetItemCount())
+ {
+ return;
+ }
+ instance.UpdateSelectedItem(selectedItemIndex);
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateListMargin;
+ var instance = (DropDown)bindable;
+ return instance.selectedItemIndex;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create("ListRelativeOrientation", typeof(ListOrientation), typeof(Tizen.NUI.Components.DropDown), ListOrientation.Left, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty ListMarginProperty = BindableProperty.Create(nameof(ListMargin), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
+ var instance = (DropDown)bindable;
if (newValue != null)
{
- instance.privateListRelativeOrientation = (ListOrientation)newValue;
+ instance.listMargin.CopyFrom((Extents)newValue);
+ instance.UpdateDropDown();
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateListRelativeOrientation;
+ var instance = (DropDown)bindable;
+ return instance.listMargin;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty SpaceProperty = BindableProperty.Create("Space", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create(nameof(ListRelativeOrientation), typeof(ListOrientation), typeof(DropDown), ListOrientation.Left, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
+ var instance = (DropDown)bindable;
if (newValue != null)
{
- instance.privateSpace = (Extents)newValue;
+ instance.listRelativeOrientation = (ListOrientation)newValue;
+ instance.UpdateDropDown();
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateSpace;
+ var instance = (DropDown)bindable;
+ return instance.listRelativeOrientation;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create("SpaceBetweenButtonTextAndIcon", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create(nameof(SpaceBetweenButtonTextAndIcon), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
+ var instance = (DropDown)bindable;
if (newValue != null)
{
- instance.privateSpaceBetweenButtonTextAndIcon = (int)newValue;
+ instance.spaceBetweenButtonTextAndIcon = (int)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateSpaceBetweenButtonTextAndIcon;
+ var instance = (DropDown)bindable;
+ return instance.spaceBetweenButtonTextAndIcon;
});
-
#region DropDown
private Button button = null;
private TextLabel headerText = null;
private TextLabel buttonText = null;
private ImageView listBackgroundImage = null;
- private FlexibleView list = null;
+ // Component that scrolls the child added to it.
+ private ScrollableBase scrollableBase = null;
+
+ // The LinearLayout container to house the items in the drop down list.
+ private View dropDownMenuFullList = null;
private DropDownListBridge adapter = new DropDownListBridge();
- private DropDownItemView touchedView = null;
- private int selectedItemIndex = -1;
+ private DropDownItemView selectedItemView = null;
+ private TapGestureDetector tapGestureDetector = null;
- private Extents listPadding = null;
+ private Extents listMargin = new Extents(0, 0, 0, 0);
+ private Extents listPadding = new Extents(0, 0, 0, 0);
+ private ListOrientation listRelativeOrientation = ListOrientation.Left;
+ private int selectedItemIndex = -1;
+ private int spaceBetweenButtonTextAndIcon = 0;
+ private bool itemPressed = false;
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new DropDownStyle Style => ViewStyle as DropDownStyle;
+ static DropDown() { }
/// <summary>
/// Creates a new instance of a DropDown.
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public DropDown() : base()
- {
- }
+ public DropDown() : base() { }
/// <summary>
/// Creates a new instance of a DropDown with style.
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public DropDown(string style) : base(style)
- {
- }
+ public DropDown(string style) : base(style) { }
/// <summary>
/// Creates a new instance of a DropDown with attributes.
public event ClickEventHandler<ItemClickEventArgs> ItemClickEvent;
/// <summary>
- /// List orientation.
+ /// List position in relation to the main button.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
Right,
}
+ /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new DropDownStyle Style => ViewStyle as DropDownStyle;
+
/// <summary>
/// Space between button text and button icon in DropDown.
/// </summary>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
public int SpaceBetweenButtonTextAndIcon
{
- get
- {
- return (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
- }
- set
- {
- SetValue(SpaceBetweenButtonTextAndIconProperty, value);
- }
- }
- private int privateSpaceBetweenButtonTextAndIcon
- {
- get
- {
- return (int)Style.SpaceBetweenButtonTextAndIcon;
- }
- set
- {
- Style.SpaceBetweenButtonTextAndIcon = value;
- RelayoutRequest();
- }
- }
-
- /// <summary>
- /// Left space in DropDown.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- public Extents Space
- {
- get
- {
- return (Extents)GetValue(SpaceProperty);
- }
- set
- {
- SetValue(SpaceProperty, value);
- }
- }
- private Extents privateSpace
- {
- get
- {
- return (Extents)Style.Space;
- }
- set
- {
- Style.Space = value;
- RelayoutRequest();
- }
+ get => (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
+ set => SetValue(SpaceBetweenButtonTextAndIconProperty, value);
}
/// <summary>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
public ListOrientation ListRelativeOrientation
{
- get
- {
- return (ListOrientation)GetValue(ListRelativeOrientationProperty);
- }
- set
- {
- SetValue(ListRelativeOrientationProperty, value);
- }
- }
- private ListOrientation privateListRelativeOrientation
- {
- get
- {
- return (ListOrientation)Style.ListRelativeOrientation;
- }
- set
- {
- Style.ListRelativeOrientation = value;
- RelayoutRequest();
- }
+ get => (ListOrientation)GetValue(ListRelativeOrientationProperty);
+ set => SetValue(ListRelativeOrientationProperty, value);
}
/// <summary>
{
get
{
- return (Extents)GetValue(ListMarginProperty);
- }
- set
- {
- SetValue(ListMarginProperty, value);
- }
- }
- private Extents privateListMargin
- {
- get
- {
- return Style.ListMargin;
- }
- set
- {
- Style.ListMargin = value;
- RelayoutRequest();
- }
- }
-
- /// <summary>
- /// Focused item index in list.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- public int FocusedItemIndex
- {
- get
- {
- return (int)GetValue(FocusedItemIndexProperty);
- }
- set
- {
- SetValue(FocusedItemIndexProperty, value);
- }
- }
- private int privateFocusedItemIndex
- {
- get
- {
- return (int)Style.FocusedItemIndex;
- }
- set
- {
- Style.FocusedItemIndex = value;
- RelayoutRequest();
+ Extents tmp = (Extents)GetValue(ListMarginProperty);
+ return new Extents((ushort start, ushort end, ushort top, ushort bottom) => { ListMargin = new Extents(start, end, top, bottom); }, tmp.Start, tmp.End, tmp.Top, tmp.Bottom);
}
+ set => SetValue(ListMarginProperty, value);
}
/// <summary>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
public int SelectedItemIndex
{
- get
- {
- return (int)GetValue(SelectedItemIndexProperty);
- }
- set
- {
- SetValue(SelectedItemIndexProperty, value);
- }
- }
- private int privateSelectedItemIndex
- {
- get
- {
- return selectedItemIndex;
- }
- set
- {
- if (value == selectedItemIndex || adapter == null || value >= adapter.GetItemCount())
- {
- return;
- }
- UpdateSelectedItem(value);
- }
- }
-
- /// <summary>
- /// List size in DropDown.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- public Size ListSize
- {
- get
- {
- return (Size)GetValue(ListSizeProperty);
- }
- set
- {
- SetValue(ListSizeProperty, value);
- }
- }
- private Size privateListSize
- {
- get
- {
- return Style.ListSize;
- }
- set
- {
- Style.ListSize = value;
- RelayoutRequest();
- }
+ get => (int)GetValue(SelectedItemIndexProperty);
+ set => SetValue(SelectedItemIndexProperty, value);
}
/// <summary>
{
get
{
- return (Extents)GetValue(ListPaddingProperty);
- }
- set
- {
- SetValue(ListPaddingProperty, value);
- }
- }
- private Extents privateListPadding
- {
- get
- {
- return listPadding;
- }
- set
- {
- Style.ListPadding.CopyFrom(value);
-
- if (null == listPadding)
- {
- listPadding = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
- {
- Style.ListPadding.Start = start;
- Style.ListPadding.End = end;
- Style.ListPadding.Top = top;
- Style.ListPadding.Bottom = bottom;
- RelayoutRequest();
- }, value.Start, value.End, value.Top, value.Bottom);
- }
- else
- {
- listPadding.CopyFrom(value);
- }
-
- RelayoutRequest();
+ Extents tmp = (Extents)GetValue(ListPaddingProperty);
+ return new Extents((ushort start, ushort end, ushort top, ushort bottom) => { ListPadding = new Extents(start, end, top, bottom); }, tmp.Start, tmp.End, tmp.Top, tmp.Bottom);
}
+ set => SetValue(ListPaddingProperty, value);
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddItem(DropDownDataItem itemData)
{
- adapter.InsertData(-1, itemData);
+ // Add item to adaptor, will be added to list via AddItemAt during OnUpdate()
+ int insertionPosition = adapter.GetItemCount();
+ adapter.InsertData(insertionPosition, itemData);
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void DeleteItem(int index)
{
- if(index < 0 || index >= adapter.GetItemCount())
- {
- return;
- }
+ if (index < 0 || index >= adapter?.GetItemCount()) return;
+ if (null == dropDownMenuFullList) return;
if (selectedItemIndex == index)
{
selectedItemIndex--;
}
- adapter.RemoveData(index);
+ adapter?.RemoveData(index);
+
+ if(index < dropDownMenuFullList.ChildCount)
+ {
+ View childToRemove = dropDownMenuFullList.GetChildAt((uint)index);
+ if (childToRemove)
+ {
+ childToRemove.TouchEvent -= ListItemTouchEvent;
+ dropDownMenuFullList.Remove(childToRemove);
+ dropDownMenuFullList?.Layout?.RequestLayout();
+ }
+ }
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void AttachScrollBar(ScrollBar scrollBar)
{
- if (list == null)
+ if (scrollableBase == null)
{
return;
}
- list.AttachScrollBar(scrollBar);
+ Tizen.Log.Error("DropDown","Feature unsupported");
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void DetachScrollBar()
{
- if (list == null)
+ if (scrollableBase == null)
{
return;
}
- list.DetachScrollBar();
+ Tizen.Log.Error("DropDown","Feature unsupported");
}
- protected override void RegisterDetectionOfSubstyleChanges()
- {
- base.RegisterDetectionOfSubstyleChanges();
-
- Style.PropertyChanged += DropDownAttributesPropertyChanged;
- Style.HeaderText.PropertyChanged += HeaderTextAttributesPropertyChanged;
- Style.Button.PropertyChanged += ButtonAttributesPropertyChanged;
-
- Style.Button.Icon.PropertyChanged += IconStylePropertyChanged;
- }
-
- private void IconStylePropertyChanged(object sender, PropertyChangedEventArgs e)
+ /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void ApplyStyle(ViewStyle viewStyle)
{
- int iconWidth = 0;
- int buttonTextWidth = 0;
- if (e.PropertyName.Equals(ImageViewStyle.SizeProperty.PropertyName))
- {
- iconWidth = (int)Style.Button.Icon.Size.Width;
- }
+ base.ApplyStyle(viewStyle);
- if (buttonText.NaturalSize2D != null)
+ DropDownStyle dropDownStyle = viewStyle as DropDownStyle;
+ if (null != dropDownStyle)
{
- buttonTextWidth = buttonText.NaturalSize2D.Width;
- }
-
- button.SizeWidth = iconWidth + (int)Style.SpaceBetweenButtonTextAndIcon + buttonTextWidth;
- }
+ CreateHeaderText();
+ CreateButtonText();
+ CreateButton();
- private void DropDownAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName.Equals("Space"))
- {
- button.Position2D.X = (int)Style.Space.Start;
+ CreateListBackgroundImage();
+ if (null == scrollableBase) // scrollableBase used to test of ListContainer Setup invoked already
+ {
+ SetUpListContainer();
+ }
+ button.ApplyStyle(dropDownStyle.Button);
+ headerText.ApplyStyle(dropDownStyle.HeaderText);
+ listBackgroundImage.ApplyStyle(dropDownStyle.ListBackgroundImage);
+ UpdateDropDown();
}
}
- private void ButtonAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
+ /// <summary>
+ /// Update DropDown by attributes.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected void UpdateDropDown()
{
- if (null == button)
- {
- button = new Button()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- IconRelativeOrientation = Components.Button.IconOrientation.Right,
- };
- button.Name = "DropDownButton";
- button.ClickEvent += ButtonClickEvent;
- Add(button);
+ if (null == scrollableBase || null == listBackgroundImage || null == dropDownMenuFullList) return;
+ if (null == Style.ListBackgroundImage.Size) return;
+ // Resize and position scrolling list within the drop down list container. Can be used to position list in relation to the background image.
+ scrollableBase.Size = Style.ListBackgroundImage.Size - new Size((listPadding.Start + listPadding.End), (listPadding.Top + listPadding.Bottom), 0);
+ scrollableBase.Position2D = new Position2D(listPadding.Start, listPadding.Top);
- button.ApplyStyle(Style.Button);
- }
-
- if (null == buttonText)
+ int listBackgroundImageX = 0;
+ int listBackgroundImageY = 0;
+ if (listRelativeOrientation == ListOrientation.Left)
{
- buttonText = new TextLabel()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.UseNaturalSize,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- };
- buttonText.Name = "DropDownButtonText";
- Add(buttonText);
- buttonText.Hide();
+ listBackgroundImageX = (int)listMargin.Start;
+ listBackgroundImageY = (int)listMargin.Top;
}
- }
-
- private void HeaderTextAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (null == headerText)
+ else if (listRelativeOrientation == ListOrientation.Right)
{
- headerText = new TextLabel();
- headerText.Name = "DropDownHeaderText";
- Add(headerText);
-
- headerText.ApplyStyle(Style.HeaderText);
+ listBackgroundImageX = -(int)listMargin.End;
+ listBackgroundImageY = (int)listMargin.Top;
}
+ listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY);
+ dropDownMenuFullList?.Layout?.RequestLayout();
}
/// <summary>
- /// Update DropDown by attributes.
+ /// update.
/// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
protected override void OnUpdate()
{
- if (Style.ListBackgroundImage != null)
+ float iconWidth = 0;
+ float buttonTextWidth = 0;
+ if (null != buttonText)
{
- if (listBackgroundImage == null)
- {
- CreateListBackgroundImage();
- CreateList();
- }
+ buttonText.Text = Style.Button.Text.Text.All;
+ buttonText.PointSize = Style.Button.Text.PointSize?.All ?? 20;
+ buttonTextWidth = buttonText.NaturalSize.Width;
+ }
+ iconWidth = Style.Button.Icon.Size?.Width ?? 48;
+ button.SizeWidth = iconWidth + Style.SpaceBetweenButtonTextAndIcon + buttonTextWidth;
- int temp = (int)Style.FocusedItemIndex;
- list.FocusedItemIndex = temp;
- list.Size = Style.ListSize;
- list.Padding = Style.ListPadding;
+ int numberOfItemsToAdd = adapter.GetItemCount();
- int listBackgroundImageX = 0;
- int listBackgroundImageY = 0;
- if (Style.ListRelativeOrientation == ListOrientation.Left)
- {
- if (Style.ListMargin != null)
- {
- listBackgroundImageX = (int)Style.ListMargin.Start;
- listBackgroundImageY = (int)Style.ListMargin.Top;
- }
- }
- else if (Style.ListRelativeOrientation == ListOrientation.Right)
+ if (adapter.AdapterPurge == true)
+ {
+ adapter.AdapterPurge = false;
+ for (int i = 0; i < numberOfItemsToAdd; i++)
{
- if (Style.ListMargin != null)
- {
- int listWidth = 0;
- if (list.Size2D != null)
- {
- listWidth = list.Size2D.Width;
- }
- listBackgroundImageX = Size2D.Width - listWidth - (int)Style.ListMargin.End;
- listBackgroundImageY = (int)Style.ListMargin.Top;
- }
+ AddItemAt(adapter.GetData(i), i);
}
- listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY);
}
+ // Set selection icon on View
+ UpdateSelectedItem(selectedItemIndex);
}
/// <summary>
if (type == DisposeTypes.Explicit)
{
- if (headerText != null)
- {
- Utility.Dispose(headerText);
- }
+ Utility.Dispose(headerText);
+ Utility.Dispose(buttonText);
+ Utility.Dispose(button);
+ Utility.Dispose(scrollableBase);
+ Utility.Dispose(dropDownMenuFullList);
+ Utility.Dispose(listBackgroundImage);
+ }
- if (buttonText != null)
- {
- Utility.Dispose(buttonText);
- }
+ base.Dispose(type);
+ }
- if (button != null)
- {
- Utility.Dispose(button);
- }
+ /// <summary>
+ /// Get DropDown attribues.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override ViewStyle GetViewStyle()
+ {
+ return new DropDownStyle();
+ }
- if (list != null)
- {
- if (listBackgroundImage != null)
- {
- Utility.Dispose(listBackgroundImage);
- }
+ private void AddItemAt(DropDownDataItem itemData,int index)
+ {
+ ViewHolder viewHolder = adapter.OnCreateViewHolder();
+ if (!viewHolder.IsBound)
+ {
+ adapter.BindViewHolder(viewHolder, index);
+ viewHolder.IsBound = true;
+ }
- Utility.Dispose(list);
- }
+ if (tapGestureDetector == null)
+ {
+ tapGestureDetector = new TapGestureDetector();
+ }
+ View view = viewHolder.ItemView;
+ view.TouchEvent += ListItemTouchEvent;
+ dropDownMenuFullList.Add(view);
+ }
+
+ private void OnClickEvent(object sender, ItemClickEventArgs e)
+ {
+ ItemClickEvent?.Invoke(sender, e);
+ }
+
+ private void CreateHeaderText()
+ {
+ if (null == headerText)
+ {
+ headerText = new TextLabel()
+ {
+ WidthResizePolicy = ResizePolicyType.UseNaturalSize,
+ HeightResizePolicy = ResizePolicyType.UseNaturalSize,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ ParentOrigin = NUI.ParentOrigin.Center,
+ PivotPoint = NUI.ParentOrigin.Center,
+ PositionUsesPivotPoint = true,
+ };
+ headerText.Name = "DropDownHeaderText";
+ Add(headerText);
}
+ }
- base.Dispose(type);
+ private void CreateButtonText()
+ {
+ if (null == buttonText)
+ {
+ buttonText = new TextLabel();
+ }
}
- /// <summary>
- /// Get DropDown attribues.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected override ViewStyle GetViewStyle()
+ private void CreateButton()
{
- return new DropDownStyle();
+ if (null == button)
+ {
+ button = new Button()
+ {
+ ParentOrigin = NUI.ParentOrigin.CenterLeft,
+ PivotPoint = NUI.PivotPoint.CenterLeft,
+ PositionUsesPivotPoint = true,
+ HeightResizePolicy = ResizePolicyType.FitToChildren,
+ IconRelativeOrientation = Button.IconOrientation.Right,
+ };
+ button.Name = "DropDownButton";
+ button.ClickEvent += ButtonClickEvent;
+ Add(button);
+ }
}
- private void OnClickEvent(object sender, ItemClickEventArgs e)
+ private void CreateListBackgroundImage()
{
- ItemClickEvent?.Invoke(sender, e);
+ if (null == listBackgroundImage)
+ {
+ listBackgroundImage = new ImageView
+ {
+ Name = "ListBackgroundImage",
+ PositionUsesPivotPoint = true,
+ ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
+ PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
+ WidthResizePolicy = ResizePolicyType.FitToChildren,
+ HeightResizePolicy = ResizePolicyType.FitToChildren,
+ };
+ Add(listBackgroundImage);
+ }
}
- private void CreateList()
+ private void SetUpListContainer()
{
- list = new FlexibleView();
- list.Name = "DropDownList";
- LinearLayoutManager layoutManager = new LinearLayoutManager(LinearLayoutManager.VERTICAL);
- list.SetLayoutManager(layoutManager);
- list.SetAdapter(adapter);
- list.Focusable = true;
- list.ItemTouchEvent += ListItemTouchEvent;
- list.ItemClickEvent += ListItemClickEvent;
- listBackgroundImage.Add(list);
+ LinearLayout linear = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ };
+
+ dropDownMenuFullList = new View()
+ {
+ Layout = linear,
+ Name = "DropDownMenuList",
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.WrapContent,
+ Focusable = true,
+ };
+
+ scrollableBase = new ScrollableBase()
+ {
+ Name = "Scrollable",
+ };
+ scrollableBase.Add(dropDownMenuFullList);
+
+ listBackgroundImage.Add(scrollableBase);
listBackgroundImage.Hide();
}
- private void ListItemClickEvent(object sender, FlexibleView.ItemClickEventArgs e)
+ private View GetViewFromIndex(uint index)
{
- if (e.ClickedView != null)
+ if ((index < dropDownMenuFullList.ChildCount) && (index >=0) )
{
- UpdateSelectedItem(e.ClickedView.AdapterPosition);
-
- ItemClickEventArgs args = new ItemClickEventArgs();
- args.Index = e.ClickedView.AdapterPosition;
- args.Text = (e.ClickedView.ItemView as DropDownItemView)?.Text;
- OnClickEvent(this, args);
+ return dropDownMenuFullList.GetChildAt(index);
+ }
+ else
+ {
+ return null;
}
+ }
- listBackgroundImage.Hide();
+ private void SetListItemToSelected(DropDownItemView targetItemView)
+ {
+ // Set the DropDownItemView matching the targetItemView to selected.
+ if (selectedItemView!=targetItemView)
+ {
+ if (selectedItemView!=null)
+ {
+ // clear selection status of currently selected item view
+ selectedItemView.IsSelected = false;
+ }
+ // Set target item to selected
+ targetItemView.IsSelected = true;
+ selectedItemView = targetItemView;
+ }
}
- private void ListItemTouchEvent(object sender, FlexibleView.ItemTouchEventArgs e)
+ private bool ListItemTouchEvent(object sender, TouchEventArgs e)
{
PointStateType state = e.Touch.GetState(0);
+ DropDownItemView touchedView = sender as DropDownItemView;;
switch (state)
{
case PointStateType.Down:
- if (e.TouchedView != null)
+ if (touchedView != null && touchedView.BackgroundColorSelector != null)
{
- touchedView = e.TouchedView.ItemView as DropDownItemView;
- if (touchedView != null && touchedView.BackgroundColorSelector != null)
- {
- touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Pressed);
- }
+ touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Pressed);
}
+ itemPressed = true; // if matched with a Up then a click event.
break;
case PointStateType.Motion:
if (touchedView != null && touchedView.BackgroundColorSelector != null)
{
touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Normal);
}
+ itemPressed = false;
break;
case PointStateType.Up:
if (touchedView != null && touchedView.BackgroundColorSelector != null)
{
touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Selected);
+
+ if (itemPressed) // if Down was previously sent without motion (Scrolling) in-between then a clicked event occurred.
+ {
+ // List item clicked
+ Console.WriteLine("Tapped{0}", touchedView.Name);
+ SetListItemToSelected(touchedView);
+ button.Text = touchedView.Text;
+ button.Show();
+ listBackgroundImage.Hide();
+ }
}
break;
default:
break;
}
- }
+ return true;
+ }
private void UpdateSelectedItem(int index)
{
+ if (null == adapter) return;
+ if (null == dropDownMenuFullList) return;
if (selectedItemIndex != -1)
{
DropDownDataItem data = adapter.GetData(selectedItemIndex);
- if(data != null)
+ if(null != data)
{
data.IsSelected = false;
}
- DropDownItemView view = list?.FindViewHolderForAdapterPosition(selectedItemIndex)?.ItemView as DropDownItemView;
- if (view != null)
- {
- view.IsSelected = false;
- }
+ DropDownItemView listItemView = dropDownMenuFullList.GetChildAt((uint)selectedItemIndex) as DropDownItemView;
+
+ SetListItemToSelected(listItemView);
}
if (index != -1)
{
DropDownDataItem data = adapter.GetData(index);
- if (data != null)
+ if (null != data)
{
data.IsSelected = true;
- }
- DropDownItemView view = list?.FindViewHolderForAdapterPosition(index)?.ItemView as DropDownItemView;
- if (view != null)
- {
- view.IsSelected = true;
- button.Style.Text.Text = view.Text;
+ DropDownItemView listItemView = dropDownMenuFullList?.GetChildAt((uint)index) as DropDownItemView;
+ if(listItemView)
+ {
+ SetListItemToSelected(listItemView);
+ }
}
}
selectedItemIndex = index;
- }
-
- private void CreateListBackgroundImage()
- {
- if (null == listBackgroundImage)
- {
- listBackgroundImage = new ImageView
- {
- Name = "ListBackgroundImage",
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.FitToChildren,
- HeightResizePolicy = ResizePolicyType.FitToChildren,
- };
- Add(listBackgroundImage);
- }
+ dropDownMenuFullList?.Layout?.RequestLayout();
}
private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
{
+ button.Hide();
listBackgroundImage.Show();
+ dropDownMenuFullList?.Layout?.RequestLayout();
+ listBackgroundImage.RaiseToTop();
}
- private void CreateHeaderTextAttributes()
- {
- if (Style.HeaderText == null)
- {
- Style.HeaderText = new TextLabelStyle()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.FillToParent,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Center,
- };
- }
- }
-
- private void CreateButtonAttributes()
- {
- if (Style.Button == null)
- {
- Style.Button = new ButtonStyle();
- }
- }
-
- private void CreateButtonTextAttributes()
- {
- CreateButtonAttributes();
-
- if (Style.Button.Text== null)
- {
- Style.Button.Text= new TextLabelStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.UseNaturalSize,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- Position = new Position(0, 0),
- HorizontalAlignment = HorizontalAlignment.Begin,
- VerticalAlignment = VerticalAlignment.Center,
- };
- }
- }
-
- private void CreateButtonIconAttributes()
- {
- CreateButtonAttributes();
-
- if (Style.Button.Icon== null)
- {
- Style.Button.Icon= new ImageViewStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.CenterRight,
- PivotPoint = Tizen.NUI.PivotPoint.CenterRight,
- };
- }
- }
-
- private void CreateListBackgroundAttributes()
- {
- if (Style.ListBackgroundImage == null)
- {
- Style.ListBackgroundImage = new ImageViewStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- };
- }
- }
#endregion
#region ItemClickEventArgs
[EditorBrowsable(EditorBrowsableState.Never)]
public DropDownDataItem()
{
- Initalize();
+ Initialize();
}
/// <summary>
{
if(style != null)
{
- ViewStyle attributes = StyleManager.Instance.GetAttributes(style);
+ ViewStyle attributes = StyleManager.Instance.GetViewStyle(style);
if(attributes == null)
{
throw new InvalidOperationException($"There is no style {style}");
}
itemDataStyle = attributes as DropDownItemStyle;
}
- Initalize();
+ Initialize();
}
/// <summary>
public DropDownDataItem(DropDownItemStyle style)
{
itemDataStyle.CopyFrom(style);
- Initalize();
+ Initialize();
}
/// <summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public Selector<Color> BackgroundColorSelector
+ public Selector<Color> BackgroundColor
{
get
{
}
set
{
- if (itemDataStyle.BackgroundColor == null)
+ if (null == itemDataStyle?.BackgroundColor)
{
itemDataStyle.BackgroundColor = new Selector<Color>();
}
}
set
{
- CreateTextAttributes();
- if (itemDataStyle.Text.Text == null)
+ if (null == itemDataStyle.Text.Text)
{
itemDataStyle.Text.Text = new Selector<string> { All = value };
}
else
{
- itemDataStyle.Text.Text.All = value;
+ itemDataStyle.Text.Text = value;
}
}
}
}
set
{
- CreateTextAttributes();
- if (itemDataStyle.Text.PointSize == null)
+ if (null == itemDataStyle.Text.PointSize)
{
itemDataStyle.Text.PointSize = new Selector<float?> { All = value };
}
else
{
- itemDataStyle.Text.PointSize.All = value;
+ itemDataStyle.Text.PointSize = value;
}
}
}
{
get
{
- return "";
- //return itemDataAttributes.TextAttributes?.FontFamily?.GetValue(State);
+ return itemDataStyle.Text.FontFamily?.All;
}
set
{
- CreateTextAttributes();
- itemDataStyle.Text.FontFamily = value;
+ if (null == itemDataStyle.Text.FontFamily)
+ {
+ itemDataStyle.Text.FontFamily = new Selector<string> { All = value };
+ }
+ else
+ {
+ itemDataStyle.Text.FontFamily = value;
+ }
}
}
}
set
{
- CreateTextAttributes();
itemDataStyle.Text.Position = value;
}
}
}
set
{
- CreateIconAttributes();
- if (itemDataStyle.Icon.ResourceUrl == null)
+ if (null == itemDataStyle.Icon.ResourceUrl)
{
itemDataStyle.Icon.ResourceUrl = new Selector<string> { All = value };
}
else
{
- itemDataStyle.Icon.ResourceUrl.All = value;
+ itemDataStyle.Icon.ResourceUrl = value;
}
}
}
}
set
{
- CreateIconAttributes();
itemDataStyle.Icon.Size = value;
}
}
}
set
{
- CreateIconAttributes();
itemDataStyle.Icon.Position = value;
}
}
}
set
{
- CreateCheckImageAttributes();
- if (itemDataStyle.CheckImage.ResourceUrl == null)
+ if (null == itemDataStyle.CheckImage.ResourceUrl)
{
itemDataStyle.CheckImage.ResourceUrl = new Selector<string> { All = value };
}
else
{
- itemDataStyle.CheckImage.ResourceUrl.All = value;
+ itemDataStyle.CheckImage.ResourceUrl = value;
}
}
}
}
set
{
- CreateCheckImageAttributes();
itemDataStyle.CheckImage.Size = value;
}
}
}
}
- private void Initalize()
+ private void Initialize()
{
if (itemDataStyle == null)
{
- throw new Exception("Button attribute parse error.");
- }
- }
-
- private void CreateTextAttributes()
- {
- if(itemDataStyle.Text== null)
- {
- itemDataStyle.Text= new TextLabelStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.UseNaturalSize,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Begin,
- };
- }
- }
-
- private void CreateIconAttributes()
- {
- if (itemDataStyle.Icon== null)
- {
- itemDataStyle.Icon= new ImageViewStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- };
- }
- }
-
- private void CreateCheckImageAttributes()
- {
- if (itemDataStyle.CheckImage== null)
- {
- itemDataStyle.CheckImage= new ImageViewStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- };
+ throw new Exception("DropDownDataItem style parse error.");
}
}
}
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public DropDownItemView() : base()
- {
- }
+ public DropDownItemView() : base() { }
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public Selector<Color> BackgroundColorSelector
- {
- get;
- set;
- }
+ public Selector<Color> BackgroundColorSelector { get; set; }
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
{
get
{
- if(mText == null)
- {
- return null;
- }
- return mText.Text;
+ return (null == mText) ? null : mText.Text;
}
set
{
{
get
{
- if (mText == null)
- {
- return null;
- }
- return mText.FontFamily;
+ return (null == mText) ? null : mText.FontFamily;
}
set
{
{
get
{
- if (mText == null)
- {
- return 0;
- }
- return mText.PointSize;
+ return (null == mText) ? 0 : mText.PointSize;
}
set
{
{
get
{
- if (mText == null)
- {
- return null;
- }
- return mText.TextColor;
+ return (null == mText) ? null : mText.TextColor;
}
set
{
{
get
{
- if (mText == null)
- {
- return null;
- }
- return mText.Position;
+ return (null == mText) ? null : mText.Position;
}
set
{
{
get
{
- if (mIcon == null)
- {
- return null;
- }
- return mIcon.ResourceUrl;
+ return (null == mIcon) ? null : mIcon.ResourceUrl;
}
set
{
{
get
{
- if (mIcon == null)
- {
- return null;
- }
- return mIcon.Size;
+ return (null == mIcon) ? null : mIcon.Size;
}
set
{
{
get
{
- if (mIcon == null)
- {
- return null;
- }
- return mIcon.Position;
+ return (null == mIcon) ? null : mIcon.Position;
}
set
{
{
get
{
- if (mCheck == null)
- {
- return null;
- }
- return mCheck.ResourceUrl;
+ return (null == mCheck) ? null : mCheck.ResourceUrl;
}
set
{
{
get
{
- if (mCheck == null)
- {
- return null;
- }
- return mCheck.Position;
+ return (null == mCheck) ? null : mCheck.Position;
}
set
{
{
get
{
- if (mCheck == null)
- {
- return null;
- }
- return mCheck.Size;
+ return (null == mCheck) ? null : mCheck.Size;
}
set
{
{
get
{
- if (mCheck == null)
- {
- return false;
- }
- return mCheck.Visibility;
+ return (null == mCheck) ? false : mCheck.Visibility;
}
set
{
PositionUsesPivotPoint = true,
ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
+ Name = "checkedImage",
};
Add(mCheck);
}
#region DropDownListBridge
/// <summary>
- /// DropDownListBridge is bridge to contact item data and item view.
+ /// DropDownListBridge is bridge to connect item data and an item View.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public class DropDownListBridge : FlexibleView.Adapter
+ public class DropDownListBridge
{
- private List<DropDownDataItem> mDatas = new List<DropDownDataItem>();
+ private List<DropDownDataItem> itemDataList = new List<DropDownDataItem>();
+
+ internal bool AdapterPurge {get;set;} = false; // Set to true if adapter content changed since last iteration.
/// <summary>
/// Creates a new instance of a DropDownListBridge.
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public DropDownListBridge()
- {
- }
+ public DropDownListBridge() { }
/// <summary>
/// Insert data. The inserted data will be added to the special position by index automatically.
{
if(position == -1)
{
- position = mDatas.Count;
+ position = itemDataList.Count;
}
- mDatas.Insert(position, data);
- NotifyItemInserted(position);
+ itemDataList.Insert(position, data);
+ AdapterPurge = true;
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void RemoveData(int position)
{
- mDatas.RemoveAt(position);
- NotifyItemRemoved(position);
+ itemDataList.RemoveAt(position);
+ AdapterPurge = true;
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public DropDownDataItem GetData(int position)
{
- return mDatas[position];
+ return itemDataList[position];
}
/// <summary>
/// Get view holder by view type.
/// </summary>
- /// <param name="viewType">Create item view.</param>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public override FlexibleView.ViewHolder OnCreateViewHolder(int viewType)
+ public ViewHolder OnCreateViewHolder()
{
- FlexibleView.ViewHolder viewHolder = new FlexibleView.ViewHolder(new DropDownItemView());
+ ViewHolder viewHolder = new ViewHolder(new DropDownItemView());
return viewHolder;
}
/// <summary>
- /// Binder view holder, it can be override.
+ /// Bind ViewHolder with View.
/// </summary>
/// <param name="holder">View holder.</param>
- /// <param name="position">Position index where will be gotten.</param>
+ /// <param name="position">Position index of source data.</param>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public override void OnBindViewHolder(FlexibleView.ViewHolder holder, int position)
+ public void BindViewHolder(ViewHolder holder, int position)
{
- DropDownDataItem listItemData = mDatas[position];
+ if (null == holder) return;
+ DropDownDataItem listItemData = itemDataList[position];
if(listItemData == null)
{
return;
listItemView.Name = "Item" + position;
if (listItemData.Size != null)
{
- holder.ItemView.Size = listItemData.Size;
+ if (listItemData.Size.Width > 0)
+ {
+ holder.ItemView.WidthSpecification = (int)listItemData.Size.Width;
+ }
+ else
+ {
+ holder.ItemView.WidthSpecification = LayoutParamPolicies.MatchParent;
+ }
+
+ if (listItemData.Size.Height > 0)
+ {
+ holder.ItemView.HeightSpecification = (int)listItemData.Size.Height;
+ }
+ else
+ {
+ holder.ItemView.HeightSpecification = LayoutParamPolicies.MatchParent;
+ }
}
if (listItemView != null)
{
- listItemView.BackgroundColorSelector = listItemData.BackgroundColorSelector;
+ listItemView.BackgroundColorSelector = listItemData.BackgroundColor;
if (listItemData.Text != null)
{
listItemView.Text = listItemData.Text;
if (listItemData.CheckImageResourceUrl != null)
{
listItemView.CheckResourceUrl = listItemData.CheckImageResourceUrl;
- listItemView.CheckImageSize = listItemData.CheckImageSize;
+
+ if (null != listItemData.CheckImageSize)
+ {
+ listItemView.CheckImageSize = listItemData.CheckImageSize;
+ }
+
if (listItemView.CheckImageSize != null)
{
listItemView.CheckPosition = new Position(listItemView.Size2D.Width - listItemData.CheckImageGapToBoundary - listItemView.CheckImageSize.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize.Height) / 2);
}
listItemView.IsSelected = listItemData.IsSelected;
- }
+ }
}
/// <summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public override void OnDestroyViewHolder(FlexibleView.ViewHolder holder)
+ public void OnDestroyViewHolder(ViewHolder holder)
{
+ if (null == holder) return;
if (holder.ItemView != null)
{
holder.ItemView.Dispose();
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public override int GetItemCount()
+ public int GetItemCount()
+ {
+ return itemDataList.Count;
+ }
+ }
+
+ #endregion
+
+ #region ViewHolder
+
+ /// <summary>
+ /// A ViewHolder is a class that holds a View created from DropDownListBridge data.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class ViewHolder
+ {
+ /// <summary>
+ /// ViewHolder constructor.
+ /// </summary>
+ /// <param name="itemView">View</param>
+ /// <since_tizen> 6 </since_tizen>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ViewHolder(View itemView)
{
- return mDatas.Count;
- }
+ if (itemView == null)
+ {
+ throw new ArgumentNullException("itemView may not be null");
+ }
+ this.ItemView = itemView;
+ }
+
+ /// <summary>
+ /// Returns the view.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public View ItemView { get; }
+
+ internal bool IsBound { get; set; }
}
+
#endregion
}
}