Languages

Menu
Sites
Language
How to display a check in the CircleGenList

Hello,

 

I try to display a list with check button in a Watch App. My App, use ElmSharp (not Xamarin) For that i have try to use the CircleGenList Component.

The displayed list works, but how can i pass the "state" to the append method ?

I don't find a state handler delegate in the GenItemClass, and switch the style between "1text" to "1text.1icon.1" doesn't seems to change anything.

Do you think it's possible to have check item in a list on a S3 App with ElmSharp ? Do i need to switch to the native dev ?

 

 

Thanks, for your answers.

 

Edited by: Fred L on 29 Mar, 2020
View Selected Answer

Responses

3 Replies
Mark as answer
Tizen .NET

Hi,

We are not sure if this is what you want, but please check this out.

BTW, is there any special reason you have to use ElmSharp instead of Xamarin?

using Tizen.Applications;
using ElmSharp;
using ElmSharp.Wearable;
using System;

namespace ElmSharpTest
{
    class App : CoreUIApplication
    {
        protected override void OnCreate()
        {
            base.OnCreate();
            Initialize();
        }

        void Initialize()
        {
            Window window = new Window("ElmSharpApp")
            {
                AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270 | DisplayRotation.Degree_90
            };
            window.BackButtonPressed += (s, e) =>
            {
                Exit();
            };
            window.Show();

            Conformant conformant = new Conformant(window);
            conformant.Show();

            var surface = new CircleSurface(conformant);

            var list = new CircleGenList(conformant, surface)
            {
                Homogeneous = true,
                VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Visible,
            };
            ((IRotaryActionWidget)list).Activate();
            conformant.SetContent(list);

            GenItemClass defaultClass = new GenItemClass("1text.1icon.1")
            {
                GetTextHandler = (obj, part) =>
                {
                    var itemData = obj as ItemData;
                    return string.Format("{0}", (string)(itemData.Text));
                },

                GetContentHandler = (obj, part) =>
                {
                    if (part == "elm.icon")
                    {
                        var check = new Check(window)
                        {
                            AlignmentX = -1,
                            WeightX = 1,
                        };
                        check.RepeatEvents = false;
                        check.PropagateEvents = false;
                        (obj as ItemData).Check = check;

                        return check;
                    }

                    return null;
                },
            };

            for (int i = 0; i < 100; i++)
            {
                var data = new ItemData();
                data.Text = string.Format("{0} Item", i);
                data.Item = list.Append(defaultClass, data);
            }
            list.ItemSelected += List_ItemSelected;

        }

        private void List_ItemSelected(object sender, GenListItemEventArgs e)
        {
            var itemData = e.Item.Data as ItemData;
            Console.WriteLine("{0} Item was selected", (string)(itemData.Text));
            Check check = (Check)itemData.Check;
            check.IsChecked = !check.IsChecked;

            itemData.Item.IsSelected = false;
        }

        static void Main(string[] args)
        {
            Elementary.Initialize();
            Elementary.ThemeOverlay();
            App app = new App();
            app.Run(args);
        }
    }

    public class ItemData
    {
        public object Check;
        public string Text;
        public GenListItem Item;
    }
}

Thanks.

Fred L
Hello,
 
that's what i needed, thank you for your help !

I just use ElmSharp, because i discover Tizen, and i begin with ElmSharp, and Elm seems more simple (for me).

What's Xamarin offer better than ElmSharp. Are there more components, or capacities in Xamarin (for the watch or for the tv) ? or is it just better because, it is more recent.

 

 

 
Alvarez

Xamarin offers an abstraction over what is available with ElmSharp.  So many common things such as lists and buttons and checks are implemented in a more useable way.  Therefore you might lose some fine grained control and im pretty sure not everything is available in ElmSharp is yet abstracted, but it allows you to arguably develop more quickly, especially if already familiar in using Xamarin.

Then using a proper view model, you can arguably better share code between different types of projects. like watch, moble, or tv. Not that wouldnt be possible otherwise.