-
Notifications
You must be signed in to change notification settings - Fork 32
Obtain current focused item of CircleListView when scrolling list #339
Comments
Hello @axa88 , I had the same problem but, I have found a workaround for that. Workaround: CustomControl namespace FocusItemListView.Controls
{
public class MyCustomListView : CircleListView
{
public event EventHandler<int> ItemHighlighted;
public void NotifyHighlightedItem(object item, int itemIndex)
{
ItemHighlighted?.Invoke(item, itemIndex);
}
}
} CustomRenderer [assembly: ExportRenderer(typeof(MyCustomListView), typeof(MyCustomListViewRenderer))]
namespace FocusItemListView.Renderers
{
public class MyCustomListViewRenderer : CircleListViewRenderer
{
new MyCustomListView Element => base.Element as MyCustomListView;
protected override void OnElementReady()
{
base.OnElementReady();
Control.ScrollAnimationStopped += OnScrollAnimationStopped;
}
private void OnScrollAnimationStopped(object sender, EventArgs arrgs)
{
GenListItem item = Control.GetItemByPosition(180, 180, out int pos);
if (item.Data is NListView.ItemContext itemContext && pos == 0)
{
var obj = itemContext.Cell.BindingContext;
var index = Element.TemplatedItems.GetGlobalIndexOfItem(obj);
Log.Debug("TEST", $"Item index: {index}");
Element.NotifyHighlightedItem(obj, index);
}
}
protected override void Dispose(bool disposing)
{
if (disposing && Control != null)
{
Control.ScrollAnimationStopped -= OnScrollAnimationStopped;
}
base.Dispose(disposing);
}
}
} |
We does not provide API to get current focused item, but as workaround commented on above, you can get it |
@myroot |
@axa88 Thank you for your suggestion. This is the same one I suggested to Xamarin.Forms two years ago. xamarin/Xamarin.Forms#2181 We'll discuss internally whether to add this to CircularUI by itself. |
Is there any progress on this? |
Hi @Machinero. Thanks for the workaround provided, however I cannot get the following line from the custom renderer to compile:
"NListView" is not being recognized, is that correct? |
Thank you for waiting so long. 🙏 Plus, thanks to @Machinero for providing great idea. ❤️ |
Describe the bug
It doesn't appear possible to get the currently focused item in a
CircleListView
.When rotating the bezel, or scrolling the list, i would like to know which item has been scrolled to.
Example here I would like to obtain the index of this list item that comes into focus:
![image](https://user-images.githubusercontent.com/13371986/85902177-65ab6280-b7d1-11ea-8369-9242b37b7b5e.png)
Item is not selected or tapped so
ItemTapped
orItemSelected
events are irrelevant.Focused
event only is relevant to the EntireListView
not individual items.Scrolled
,ItemAppearing
,ItemDisappearing
event args do not provide information of the focused item.To Reproduce
Steps to reproduce the behavior:
CircleListView
Expected behavior
Be able to obtain the index of the focused item of a
CircleListView
Perhaps a property FocusedItem could be added.
Environment (please complete the following information):
Target Product:
![image](https://user-images.githubusercontent.com/13371986/85902080-2b41c580-b7d1-11ea-99e8-ee8e805dfcf7.png)
Tizen Platform Version [e.g. Tizen 5.5]
Tizen.CircularUI Version [1.4.0 > 1.5.0]
Additional context
Perhaps im ignorant, but i do not see a way to do this.
The text was updated successfully, but these errors were encountered: