public DrawerBox(EvasObject parent) : base(parent)
        {
            _drawerBox = new EBox(this);
            _drawerBox.SetAlignment(-1.0, -1.0);
            _drawerBox.SetWeight(1.0, 1.0);
            _drawerBox.Show();

            _contentBox = new EBox(this);
            _contentBox.SetAlignment(-1.0, -1.0);
            _contentBox.SetWeight(1.0, 1.0);
            _contentBox.Show();

            _dimArea = new EBox(this)
            {
                BackgroundColor = ThemeConstants.Shell.ColorClass.DefaultDrawerDimBackgroundColor,
                Opacity         = ThemeConstants.Shell.Resources.DefaultDrawerDimOpacity
            };

            _gestureOnDimArea = new GestureLayer(_dimArea);
            _gestureOnDimArea.SetTapCallback(GestureType.Tap, GestureLayer.GestureState.Start, OnTapped);
            _gestureOnDimArea.Attach(_dimArea);

            _splitPane = new Panes(this)
            {
                AlignmentX   = -1,
                AlignmentY   = -1,
                WeightX      = 1,
                WeightY      = 1,
                IsFixed      = true,
                IsHorizontal = false,
            };

            _panel = new Panel(this);
            _panel.SetScrollable(_isGestureEnabled);
            _panel.SetScrollableArea(1.0);
            _panel.Direction = PanelDirection.Left;
            _panel.Toggled  += (object?sender, EventArgs e) =>
            {
                if (_panel.IsOpen)
                {
                    _dimArea.Show();
                }

                Toggled?.Invoke(this, EventArgs.Empty);
            };

            _mainWidget = _contentBox;

            ConfigureLayout();
            SetLayoutCallback(OnLayout);
        }
Exemple #2
0
        private void Initialize()
        {
            _outterLayout = new ElmSharp.Layout(TForms.NativeParent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };
            _outterLayout.Show();
            _outterLayout.SetTheme("layout", "application", "default");

            _index = new Index(_outterLayout)
            {
                IsHorizontal = true,
                AutoHide     = false,
            };
            _index.Show();
            _outterLayout.SetPartContent("elm.swallow.content", _index);

            _scroller = new Scroller(_outterLayout);
            _scroller.PageScrolled += OnPageScrolled;

            // Disables the visibility of the scrollbar in both directions:
            _scroller.HorizontalScrollBarVisiblePolicy = ElmSharp.ScrollBarVisiblePolicy.Invisible;
            _scroller.VerticalScrollBarVisiblePolicy   = ElmSharp.ScrollBarVisiblePolicy.Invisible;
            // Sets the limit of scroll to one page maximum:
            _scroller.HorizontalPageScrollLimit = 1;
            _scroller.SetPageSize(1.0, 1.0);
            _scroller.SetAlignment(-1, -1);
            _scroller.SetWeight(1.0, 1.0);
            _scroller.Show();

            _innerContainer = new Box(_outterLayout);
            _innerContainer.SetLayoutCallback(OnInnerLayoutUpdate);
            _innerContainer.SetAlignment(-1, -1);
            _innerContainer.SetWeight(1.0, 1.0);
            _innerContainer.Show();
            _scroller.SetContent(_innerContainer);

            _outterLayout.SetPartContent("elm.swallow.bg", _scroller);
        }
Exemple #3
0
        public ElmSharp.EvasObject GetContent(object data, string part)
        {
            var minimumHeight = PageHeight > 800 ? 96 : 76;

            if (part == "elm.swallow.content")
            {
                DataSource2  itemSource = (DataSource2)data;
                ElmSharp.Box mainBox    = new ElmSharp.Box(Forms.NativeParent);
                mainBox.BackgroundColor = Xamarin.Forms.Color.LightYellow.ToNative();
                mainBox.MinimumHeight   = minimumHeight;
                mainBox.IsHorizontal    = false;
                mainBox.SetAlignment(-1, -1);
                mainBox.Show();

                ElmSharp.Box contentBox = new ElmSharp.Box(Forms.NativeParent);
                contentBox.MinimumHeight = minimumHeight;
                contentBox.IsHorizontal  = true;
                contentBox.SetAlignment(-1, -1);
                contentBox.Show();

                ElmSharp.Box left = new ElmSharp.Box(Forms.NativeParent);
                left.IsHorizontal = false;
                left.Show();
                left.SetWeight(4.0, 1);
                left.SetAlignment(-1, -1);
                contentBox.PackEnd(left);

                ElmSharp.Label titleName = new ElmSharp.Label(Forms.NativeParent);
                left.PackEnd(titleName);
                titleName.Show();
                titleName.Text         = $"<span font_size=34 font_style=italic color=#7F3300>   {itemSource.Name}</span>";
                titleName.MinimumWidth = 250;
                titleName.SetAlignment(-1, -1);

                ElmSharp.Label titleCategory = new ElmSharp.Label(Forms.NativeParent);
                left.PackEnd(titleCategory);
                titleCategory.Show();
                titleCategory.Text = $"<span align=center font_size=24 color=#008000>{itemSource.Category}</span>";
                titleCategory.SetAlignment(-1, -1);

                ElmSharp.Box right = new ElmSharp.Box(Forms.NativeParent);
                right.Show();
                right.MinimumWidth  = 96;
                right.MinimumHeight = minimumHeight;
                right.SetWeight(1, 1);
                right.SetAlignment(-1, 0);

                ElmSharp.Image image;

                if (itemSource.ImageFilename != "")
                {
                    image = new ElmSharp.Image(right);
                    image.Load(global::Tizen.Applications.Application.Current.DirectoryInfo.Resource + itemSource.ImageFilename + ".jpg");
                    image.SetAlignment(0.5, 0.5);
                    image.MinimumHeight = minimumHeight;
                    image.MinimumWidth  = minimumHeight;
                    image.Show();
                    right.PackEnd(image);
                }

                ElmSharp.Rectangle rec = new ElmSharp.Rectangle(left);
                rec.MinimumHeight = 1;
                rec.MinimumWidth  = 400;
                rec.AlignmentX    = -1;
                rec.Color         = ElmSharp.Color.Gray;
                rec.Show();

                contentBox.PackEnd(right);

                mainBox.PackEnd(contentBox);
                mainBox.PackEnd(rec);

                return(mainBox);
            }
            return(null);
        }