public void SetAppearance(Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance) { toolbar.SetBackgroundColor(Android.Graphics.Color.Green); var viewParent = (Android.Support.Design.Widget.AppBarLayout)toolbar.Parent; viewParent.SetElevation(0.0f); }
void Destroy() { ((IShellController)_shellContext.Shell).RemoveAppearanceObserver(this); if (_shellContent != null) { ((IShellContentController)_shellContent).RecyclePage(_page); _page.ClearValue(AppCompat.Platform.RendererProperty); _page = null; } if (_shellPageContainer != null) { _shellPageContainer.RemoveAllViews(); if (_root is ViewGroup vg) { vg.RemoveView(_shellPageContainer); } } _renderer?.Dispose(); _root?.Dispose(); _toolbarTracker?.Dispose(); _appearanceTracker?.Dispose(); _appearanceTracker = null; _toolbarTracker = null; _toolbar = null; _root = null; _renderer = null; _shellContent = null; }
void Destroy() { if (_rootView != null) { UnhookEvents(); _viewPager.RemoveOnPageChangeListener(this); var adapter = _viewPager.Adapter; _viewPager.Adapter = null; adapter.Dispose(); _tablayout.LayoutChange -= OnTabLayoutChange; _toolbarAppearanceTracker.Dispose(); _tabLayoutAppearanceTracker.Dispose(); _toolbarTracker.Dispose(); _tablayout.Dispose(); _toolbar.Dispose(); _viewPager.Dispose(); _rootView.Dispose(); } _toolbarAppearanceTracker = null; _tabLayoutAppearanceTracker = null; _toolbarTracker = null; _tablayout = null; _toolbar = null; _viewPager = null; _rootView = null; }
protected virtual void SetColors(Toolbar toolbar, IShellToolbarTracker toolbarTracker, Color foreground, Color background, Color title) { var titleArgb = title.ToAndroid(ShellRenderer.DefaultTitleColor).ToArgb(); if (_titleTextColor != titleArgb) { toolbar.SetTitleTextColor(titleArgb); _titleTextColor = titleArgb; } var newColor = background.ToAndroid(ShellRenderer.DefaultBackgroundColor); if (!(toolbar.Background is ColorDrawable cd) || cd.Color != newColor) { using (var colorDrawable = new ColorDrawable(background.ToAndroid(ShellRenderer.DefaultBackgroundColor))) toolbar.SetBackground(colorDrawable); } var newTintColor = foreground.IsDefault ? ShellRenderer.DefaultForegroundColor : foreground; if (toolbarTracker.TintColor != newTintColor) { toolbarTracker.TintColor = newTintColor; } }
// Use OnDestroy instead of OnDestroyView because OnDestroyView will be // called before the animation completes. This causes tons of tiny issues. public override void OnDestroy() { base.OnDestroy(); if (_rootView != null) { UnhookEvents(); var adapter = _viewPager.Adapter; _viewPager.Adapter = null; adapter.Dispose(); _toolbarAppearanceTracker.Dispose(); _tabLayoutAppearanceTracker.Dispose(); _viewPager.RemoveOnPageChangeListener(this); _rootView.Dispose(); _toolbarTracker.Dispose(); _tablayout.Dispose(); _toolbar.Dispose(); _viewPager.Dispose(); _rootView.Dispose(); } _toolbarAppearanceTracker = null; _tabLayoutAppearanceTracker = null; _toolbarTracker = null; _toolbar = null; _tablayout = null; _rootView = null; _viewPager = null; }
void Destroy() { if (_rootView != null) { UnhookEvents(); _shellContext?.Shell?.Toolbar?.Handler?.DisconnectHandler(); //_viewPager.RemoveOnPageChangeListener(this); var adapter = _viewPager.Adapter; _viewPager.Adapter = null; adapter.Dispose(); _tablayout.LayoutChange -= OnTabLayoutChange; _toolbarAppearanceTracker.Dispose(); _tabLayoutAppearanceTracker.Dispose(); _toolbarTracker.Dispose(); _tablayout.Dispose(); _toolbar.Dispose(); _viewPager.Dispose(); _rootView.Dispose(); } _toolbarAppearanceTracker = null; _tabLayoutAppearanceTracker = null; _toolbarTracker = null; _tablayout = null; _toolbar = null; _viewPager = null; _rootView = null; }
public override void SetAppearance(Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance) { base.SetAppearance(toolbar, toolbarTracker, appearance); toolbar.SetPadding(0, -16, 0, 0); //toolbar.LayoutParameters = new AppBarLayout.LayoutParams((toolbar.Parent as AppBarLayout) // .LayoutParameters) { ScrollFlags = 0 }; }
// Use OnDestroy instead of OnDestroyView because OnDestroyView will be // called before the animation completes. This causes tons of tiny issues. public override void OnDestroy() { base.OnDestroy(); _shellPageContainer.RemoveAllViews(); _renderer?.Dispose(); _root?.Dispose(); _toolbarTracker.Dispose(); _appearanceTracker.Dispose(); ((IShellController)_shellContext.Shell).RemoveAppearanceObserver(this); if (_shellContent != null) { ((IShellContentController)_shellContent).RecyclePage(_page); _page.ClearValue(Platform.RendererProperty); _page = null; } _appearanceTracker = null; _toolbar = null; _toolbarTracker = null; _root = null; _renderer = null; }
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (_shellContent != null) { _page = ((IShellContentController)_shellContent).GetOrCreateContent(); } _root = inflater.Inflate(Resource.Layout.ShellContent, null).JavaCast <CoordinatorLayout>(); var scrollview = _root.FindViewById <NestedScrollView>(Resource.Id.shellcontent_scrollview); _toolbar = _root.FindViewById <Toolbar>(Resource.Id.shellcontent_toolbar); _renderer = Platform.CreateRenderer(_page, Context); Platform.SetRenderer(_page, _renderer); _shellPageContainer = new ShellPageContainer(Context, _renderer); scrollview.AddView(_shellPageContainer); _toolbarTracker = _shellContext.CreateTrackerForToolbar(_toolbar); _toolbarTracker.Page = _page; // this is probably not the most ideal way to do that _toolbarTracker.CanNavigateBack = _shellContent == null; _appearanceTracker = _shellContext.CreateToolbarAppearanceTracker(); ((IShellController)_shellContext.Shell).AddAppearanceObserver(this, _page); return(_root); }
void Destroy() { ((IShellController)_shellContext.Shell).RemoveAppearanceObserver(this); if (_shellContent != null) { ((IShellContentController)_shellContent).RecyclePage(_page); _page.Handler = null; } if (_shellPageContainer != null) { _shellPageContainer.RemoveAllViews(); if (_root is ViewGroup vg) { vg.RemoveView(_shellPageContainer); } _shellPageContainer.Dispose(); } _root?.Dispose(); _toolbarTracker?.Dispose(); _appearanceTracker?.Dispose(); _appearanceTracker = null; _toolbarTracker = null; _toolbar = null; _root = null; _viewhandler = null; _shellContent = null; _shellPageContainer = null; }
public virtual void SetAppearance(Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance) { var foreground = appearance.ForegroundColor; var background = appearance.BackgroundColor; var titleColor = appearance.TitleColor; SetColors(toolbar, toolbarTracker, foreground, background, titleColor); }
protected virtual void SetColors(Toolbar toolbar, IShellToolbarTracker toolbarTracker, Color foreground, Color background, Color title) { var titleArgb = title.ToAndroid(ShellRenderer.DefaultTitleColor).ToArgb(); toolbar.SetTitleTextColor(titleArgb); using (var colorDrawable = new ColorDrawable(background.ToAndroid(ShellRenderer.DefaultBackgroundColor))) toolbar.SetBackground(colorDrawable); toolbarTracker.TintColor = foreground.IsDefault ? ShellRenderer.DefaultForegroundColor : foreground; }
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var shellSection = ShellSection; if (shellSection == null) { return(null); } var root = inflater.Inflate(Resource.Layout.RootLayout, null).JavaCast <CoordinatorLayout>(); _toolbar = root.FindViewById <Toolbar>(Resource.Id.main_toolbar); var scrollview = root.FindViewById <NestedScrollView>(Resource.Id.main_scrollview); _tablayout = root.FindViewById <TabLayout>(Resource.Id.main_tablayout); _viewPager = new FormsViewPager(Context) { LayoutParameters = new LP(LP.MatchParent, LP.MatchParent), }; _viewPager.AddOnPageChangeListener(this); _viewPager.Id = Platform.GenerateViewId(); _viewPager.Adapter = new ShellFragmentPagerAdapter(shellSection, ChildFragmentManager); _viewPager.OverScrollMode = OverScrollMode.Never; _tablayout.SetupWithViewPager(_viewPager); var currentPage = ((IShellContentController)shellSection.CurrentItem).GetOrCreateContent(); var currentIndex = ShellSection.Items.IndexOf(ShellSection.CurrentItem); _toolbarTracker = _shellContext.CreateTrackerForToolbar(_toolbar); _toolbarTracker.Page = currentPage; _viewPager.CurrentItem = currentIndex; scrollview.AddView(_viewPager); if (shellSection.Items.Count == 1) { _tablayout.Visibility = ViewStates.Gone; } _tabLayoutAppearanceTracker = _shellContext.CreateTabLayoutAppearanceTracker(ShellSection); _toolbarAppearanceTracker = _shellContext.CreateToolbarAppearanceTracker(); HookEvents(); scrollview.Dispose(); return(_rootView = root); }
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var shellSection = ShellSection; if (shellSection == null) { return(null); } if (shellSection.CurrentItem == null) { throw new InvalidOperationException($"Content not found for active {shellSection}. Title: {shellSection.Title}. Route: {shellSection.Route}."); } var root = inflater.Inflate(Resource.Layout.RootLayout, null).JavaCast <CoordinatorLayout>(); _toolbar = root.FindViewById <Toolbar>(Resource.Id.main_toolbar); _viewPager = root.FindViewById <FormsViewPager>(Resource.Id.main_viewpager); _tablayout = root.FindViewById <TabLayout>(Resource.Id.main_tablayout); _viewPager.EnableGesture = false; _viewPager.AddOnPageChangeListener(this); _viewPager.Id = Platform.GenerateViewId(); _viewPager.Adapter = new ShellFragmentPagerAdapter(shellSection, ChildFragmentManager); _viewPager.OverScrollMode = OverScrollMode.Never; _tablayout.SetupWithViewPager(_viewPager); var currentPage = ((IShellContentController)shellSection.CurrentItem).GetOrCreateContent(); var currentIndex = SectionController.GetItems().IndexOf(ShellSection.CurrentItem); _toolbarTracker = _shellContext.CreateTrackerForToolbar(_toolbar); _toolbarTracker.Page = currentPage; _viewPager.CurrentItem = currentIndex; if (SectionController.GetItems().Count == 1) { _tablayout.Visibility = ViewStates.Gone; } _tabLayoutAppearanceTracker = _shellContext.CreateTabLayoutAppearanceTracker(ShellSection); _toolbarAppearanceTracker = _shellContext.CreateToolbarAppearanceTracker(); HookEvents(); return(_rootView = root); }
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (_shellContent != null) { _page = ((IShellContentController)_shellContent).GetOrCreateContent(); } _root = inflater.Inflate(Controls.Resource.Layout.shellcontent, null).JavaCast <CoordinatorLayout>(); var shellContentMauiContext = MauiContext.MakeScoped(layoutInflater: inflater, fragmentManager: ChildFragmentManager); Maui.IElement parentElement = (_shellContent as Maui.IElement) ?? _page; var shellToolbar = new Toolbar(parentElement); ShellToolbarTracker.ApplyToolbarChanges(_shellContext.Shell.Toolbar, shellToolbar); _toolbar = (AToolbar)shellToolbar.ToPlatform(shellContentMauiContext); var appBar = _root.FindViewById <AppBarLayout>(Resource.Id.shellcontent_appbar); appBar.AddView(_toolbar); _viewhandler = _page.ToHandler(shellContentMauiContext); _shellPageContainer = new ShellPageContainer(Context, _viewhandler); if (_root is ViewGroup vg) { vg.AddView(_shellPageContainer); } _toolbarTracker = _shellContext.CreateTrackerForToolbar(_toolbar); _toolbarTracker.SetToolbar(shellToolbar); _toolbarTracker.Page = _page; // this is probably not the most ideal way to do that _toolbarTracker.CanNavigateBack = _shellContent == null; _appearanceTracker = _shellContext.CreateToolbarAppearanceTracker(); ((IShellController)_shellContext.Shell).AddAppearanceObserver(this, _page); if (_shellPageContainer.LayoutParameters is CoordinatorLayout.LayoutParams layoutParams) { layoutParams.Behavior = new AppBarLayout.ScrollingViewBehavior(); } return(_root); }
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (_shellContent != null) { _page = ((IShellContentController)_shellContent).GetOrCreateContent(); } _root = inflater.Inflate(Resource.Layout.ShellContent, null).JavaCast <CoordinatorLayout>(); _toolbar = _root.FindViewById <Toolbar>(Resource.Id.shellcontent_toolbar); _renderer = AppCompat.Platform.CreateRenderer(_page, Context); AppCompat.Platform.SetRenderer(_page, _renderer); _shellPageContainer = new ShellPageContainer(Context, _renderer); if (_root is ViewGroup vg) { vg.AddView(_shellPageContainer); } _toolbarTracker = _shellContext.CreateTrackerForToolbar(_toolbar); _toolbarTracker.Page = _page; // this is probably not the most ideal way to do that _toolbarTracker.CanNavigateBack = _shellContent == null; _appearanceTracker = _shellContext.CreateToolbarAppearanceTracker(); ((IShellController)_shellContext.Shell).AddAppearanceObserver(this, _page); if (_shellPageContainer.LayoutParameters is CoordinatorLayout.LayoutParams layoutParams) { layoutParams.Behavior = new AppBarLayout.ScrollingViewBehavior(); } return(_root); }
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var shellSection = ShellSection; if (shellSection == null) { return(null); } if (shellSection.CurrentItem == null) { throw new InvalidOperationException($"Content not found for active {shellSection}. Title: {shellSection.Title}. Route: {shellSection.Route}."); } var root = inflater.Inflate(Resource.Layout.shellrootlayout, null).JavaCast <CoordinatorLayout>(); _toolbar = root.FindViewById <Toolbar>(Resource.Id.maui_toolbar); if (Context.GetActivity() is AppCompatActivity aca) { aca.SetSupportActionBar(_toolbar); } _viewPager = root.FindViewById <ViewPager2>(Resource.Id.main_viewpager); _tablayout = root.FindViewById <TabLayout>(Resource.Id.main_tablayout); //_viewPager.EnableGesture = false; //_viewPager.AddOnPageChangeListener(this); _viewPager.Id = AView.GenerateViewId(); _viewPager.Adapter = new ShellFragmentStateAdapter(shellSection, ChildFragmentManager, MauiContext); _viewPager.OverScrollMode = OverScrollMode.Never; new TabLayoutMediator(_tablayout, _viewPager, this) .Attach(); //_tablayout.SetupWithViewPager(_viewPager); Page currentPage = null; int currentIndex = -1; var currentItem = ShellSection.CurrentItem; while (currentIndex < 0 && SectionController.GetItems().Count > 0 && ShellSection.CurrentItem != null) { currentItem = ShellSection.CurrentItem; currentPage = ((IShellContentController)shellSection.CurrentItem).GetOrCreateContent(); // current item hasn't changed if (currentItem == shellSection.CurrentItem) { currentIndex = SectionController.GetItems().IndexOf(currentItem); } } _toolbarTracker = _shellContext.CreateTrackerForToolbar(_toolbar); _toolbarTracker.Page = currentPage; _viewPager.CurrentItem = currentIndex; if (SectionController.GetItems().Count == 1) { UpdateTablayoutVisibility(); } _tablayout.LayoutChange += OnTabLayoutChange; _tabLayoutAppearanceTracker = _shellContext.CreateTabLayoutAppearanceTracker(ShellSection); _toolbarAppearanceTracker = _shellContext.CreateToolbarAppearanceTracker(); HookEvents(); return(_rootView = root); }
public virtual void ResetAppearance(Toolbar toolbar, IShellToolbarTracker toolbarTracker) { SetColors(toolbar, toolbarTracker, ShellRenderer.DefaultForegroundColor, ShellRenderer.DefaultBackgroundColor, ShellRenderer.DefaultTitleColor); }
public override void SetAppearance(Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance) { base.SetAppearance(toolbar, toolbarTracker, appearance); toolbar.SetBackgroundColor(Android.Graphics.Color.Transparent); }
protected override void SetColors(Toolbar toolbar, IShellToolbarTracker toolbarTracker, Color foreground, Color background, Color title) { var bg = Color.Red; base.SetColors(toolbar, toolbarTracker, foreground, bg, title); }
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var shellSection = ShellSection; if (shellSection == null) { return(null); } if (shellSection.CurrentItem == null) { throw new InvalidOperationException($"Content not found for active {shellSection}. Title: {shellSection.Title}. Route: {shellSection.Route}."); } var context = Context; var root = PlatformInterop.CreateShellCoordinatorLayout(context); var appbar = PlatformInterop.CreateShellAppBar(context, Resource.Attribute.appBarLayoutStyle, root); int actionBarHeight = context.GetActionBarHeight(); _toolbar = PlatformInterop.CreateShellToolbar(context, appbar, actionBarHeight, Resource.Style.ThemeOverlay_AppCompat_Light); _tablayout = PlatformInterop.CreateShellTabLayout(context, appbar, actionBarHeight); var pagerContext = MauiContext.MakeScoped(layoutInflater: inflater, fragmentManager: ChildFragmentManager); var adapter = new ShellFragmentStateAdapter(shellSection, ChildFragmentManager, pagerContext); var pageChangedCallback = new ViewPagerPageChanged(this); _viewPager = PlatformInterop.CreateShellViewPager(context, root, _tablayout, this, adapter, pageChangedCallback); Page currentPage = null; int currentIndex = -1; var currentItem = shellSection.CurrentItem; var items = SectionController.GetItems(); while (currentIndex < 0 && items.Count > 0 && shellSection.CurrentItem != null) { currentItem = shellSection.CurrentItem; currentPage = ((IShellContentController)shellSection.CurrentItem).GetOrCreateContent(); // current item hasn't changed if (currentItem == shellSection.CurrentItem) { currentIndex = items.IndexOf(currentItem); } } _toolbarTracker = _shellContext.CreateTrackerForToolbar(_toolbar); _toolbarTracker.Page = currentPage; _viewPager.CurrentItem = currentIndex; if (items.Count == 1) { UpdateTablayoutVisibility(); } _tablayout.LayoutChange += OnTabLayoutChange; _tabLayoutAppearanceTracker = _shellContext.CreateTabLayoutAppearanceTracker(ShellSection); _toolbarAppearanceTracker = _shellContext.CreateToolbarAppearanceTracker(); HookEvents(); return(_rootView = root); }
protected virtual void SetColors(AToolbar toolbar, IShellToolbarTracker toolbarTracker, Color foreground, Color background, Color title) { _shellContext.Shell.Toolbar.BarTextColor = title ?? ShellRenderer.DefaultTitleColor; _shellContext.Shell.Toolbar.BarBackground = new SolidColorBrush(background ?? ShellRenderer.DefaultBackgroundColor); _shellContext.Shell.Toolbar.IconColor = foreground ?? ShellRenderer.DefaultForegroundColor; }
public override void SetAppearance(Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance) { base.SetAppearance(toolbar, toolbarTracker, appearance); }
public void SetAppearance(Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance) { //toolbar.SetBackgroundResource(Resource.Drawable.custom_gradient); }
public void ResetAppearance(Toolbar toolbar, IShellToolbarTracker toolbarTracker) { }
public override void SetAppearance(Android.Support.V7.Widget.Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance) { base.SetAppearance(toolbar, toolbarTracker, appearance); toolbar.SetBackgroundColor(new Android.Graphics.Color(Context.AndroidContext.GetColor(Resource.Color.BackgroundGradientStart))); toolbar.Elevation = 0F; toolbar.TranslationZ = 0F; }
public void ResetAppearance(Android.Support.V7.Widget.Toolbar toolbar, IShellToolbarTracker toolbarTracker) { }
public void ResetAppearance(Android.Support.V7.Widget.Toolbar toolbar, IShellToolbarTracker toolbarTracker) { throw new NotImplementedException(); }
public void SetAppearance(Android.Support.V7.Widget.Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance) { toolbar.SetBackgroundResource(Resource.Drawable.gradient); }
public void SetAppearance(Android.Support.V7.Widget.Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance) { mytoolbar = toolbar; mytoolbar.SetBackgroundColor(Color.FromHex("#181818").ToAndroid()); }