Ejemplo n.º 1
0
        public static void UpdateTitleIcon(this AToolbar nativeToolbar, Toolbar toolbar)
        {
            _ = nativeToolbar.Context ?? throw new ArgumentNullException(nameof(nativeToolbar.Context));
            _ = toolbar?.Handler?.MauiContext ?? throw new ArgumentNullException(nameof(toolbar.Handler.MauiContext));

            ImageSource source = toolbar.TitleIcon;

            if (source == null || source.IsEmpty)
            {
                if (nativeToolbar.GetChildAt(0) is ToolbarTitleIconImageView existingImageView)
                {
                    nativeToolbar.RemoveView(existingImageView);
                }

                return;
            }

            var iconView = new ToolbarTitleIconImageView(nativeToolbar.Context);

            nativeToolbar.AddView(iconView, 0);
            iconView.SetImageResource(global::Android.Resource.Color.Transparent);

            source.LoadImage(toolbar.Handler.MauiContext, (result) =>
            {
                iconView.SetImageDrawable(result?.Value);
                AutomationPropertiesProvider.AccessibilitySettingsChanged(iconView, source);
            });
        }
        void UpdateTitleIcon()
        {
            Page currentPage = CurrentPage;

            if (currentPage == null)
            {
                return;
            }

            ImageSource source = NavigationPage.GetTitleIconImageSource(currentPage);

            if (source == null || source.IsEmpty)
            {
                Toolbar.RemoveView(_titleIconView);
                _titleIconView?.Dispose();
                _titleIconView = null;
                _imageSource   = null;
                return;
            }

            if (_titleIconView == null)
            {
                _titleIconView = new Android.Widget.ImageView(NavigationLayout.Context);
                Toolbar.AddView(_titleIconView, 0);
            }

            if (_imageSource != source)
            {
                _imageSource = source;
                _titleIconView.SetImageResource(global::Android.Resource.Color.Transparent);

                ImageSourceLoader.LoadImage(source, MauiContext, (result) =>
                {
                    _titleIconView.SetImageDrawable(result.Value);
                    AutomationPropertiesProvider.AccessibilitySettingsChanged(_titleIconView, source);
                });
            }
        }
Ejemplo n.º 3
0
        void OnTabLayoutChange(object sender, AView.LayoutChangeEventArgs e)
        {
            if (_disposed)
            {
                return;
            }

            var items = SectionController.GetItems();

            for (int i = 0; i < _tablayout.TabCount; i++)
            {
                if (items.Count <= i)
                {
                    break;
                }

                var tab = _tablayout.GetTabAt(i);

                if (tab.View != null)
                {
                    AutomationPropertiesProvider.AccessibilitySettingsChanged(tab.View, items[i]);
                }
            }
        }