void Destroy() { if (ShellItem != null) { UnhookEvents(ShellItem); } ((IShellController)ShellContext?.Shell)?.RemoveAppearanceObserver(this); if (_bottomSheetDialog != null) { _bottomSheetDialog.DismissEvent -= OnMoreSheetDismissed; _bottomSheetDialog?.Dispose(); _bottomSheetDialog = null; } _navigationArea?.Dispose(); _appearanceTracker?.Dispose(); _outerLayout?.Dispose(); if (_bottomView != null) { _bottomView?.SetOnNavigationItemSelectedListener(null); _bottomView?.Background?.Dispose(); _bottomView?.Dispose(); } _bottomView = null; _navigationArea = null; _appearanceTracker = null; _outerLayout = null; }
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); _outerLayout = inflater.Inflate(Resource.Layout.BottomTabLayout, null); _bottomView = _outerLayout.FindViewById <BottomNavigationView>(Resource.Id.bottomtab_tabbar); _navigationArea = _outerLayout.FindViewById <FrameLayout>(Resource.Id.bottomtab_navarea); _bottomView.SetBackgroundColor(Color.White.ToAndroid()); _bottomView.SetOnNavigationItemSelectedListener(this); if (ShellItem == null) { throw new ArgumentException("Active Shell Item not set. Have you added any Shell Items to your Shell?", nameof(ShellItem)); } HookEvents(ShellItem); SetupMenu(); _appearanceTracker = ShellContext.CreateBottomNavViewAppearanceTracker(ShellItem); _bottomNavigationTracker = new BottomNavigationViewTracker(); ((IShellController)ShellContext.Shell).AddAppearanceObserver(this, ShellItem); return(_outerLayout); }
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); _outerLayout = inflater.Inflate(Resource.Layout.bottomtablayout, null); _bottomView = _outerLayout.FindViewById <BottomNavigationView>(Resource.Id.bottomtab_tabbar); _navigationArea = _outerLayout.FindViewById <FrameLayout>(Resource.Id.bottomtab_navarea); _bottomView.SetBackgroundColor(Colors.White.ToPlatform()); _bottomView.SetOnItemSelectedListener(this); if (ShellItem == null) { throw new InvalidOperationException("Active Shell Item not set. Have you added any Shell Items to your Shell?"); } if (ShellItem.CurrentItem == null) { throw new InvalidOperationException($"Content not found for active {ShellItem}. Title: {ShellItem.Title}. Route: {ShellItem.Route}."); } HookEvents(ShellItem); SetupMenu(); _appearanceTracker = ShellContext.CreateBottomNavViewAppearanceTracker(ShellItem); _bottomNavigationTracker = new BottomNavigationViewTracker(); ((IShellController)ShellContext.Shell).AddAppearanceObserver(this, ShellItem); return(_outerLayout); }
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); var context = MauiContext.Context; _outerLayout = PlatformInterop.CreateNavigationBarOuterLayout(context); _navigationArea = PlatformInterop.CreateNavigationBarArea(context, _outerLayout); _bottomView = PlatformInterop.CreateNavigationBar(context, Resource.Attribute.bottomNavigationViewStyle, _outerLayout, this); if (ShellItem == null) { throw new InvalidOperationException("Active Shell Item not set. Have you added any Shell Items to your Shell?"); } if (ShellItem.CurrentItem == null) { throw new InvalidOperationException($"Content not found for active {ShellItem}. Title: {ShellItem.Title}. Route: {ShellItem.Route}."); } HookEvents(ShellItem); SetupMenu(); _appearanceTracker = ShellContext.CreateBottomNavViewAppearanceTracker(ShellItem); _bottomNavigationTracker = new BottomNavigationViewTracker(); ((IShellController)ShellContext.Shell).AddAppearanceObserver(this, ShellItem); return(_outerLayout); }
// Use OnDestory become OnDestroyView may fire before events are completed. public override void OnDestroy() { UnhookEvents(ShellItem); if (_bottomView != null) { _bottomView?.SetOnNavigationItemSelectedListener(null); _bottomView?.Background?.Dispose(); _bottomView?.Dispose(); _bottomView = null; _navigationArea?.Dispose(); _navigationArea = null; _appearanceTracker?.Dispose(); _appearanceTracker = null; _outerLayout?.Dispose(); _outerLayout = null; } ((IShellController)ShellContext.Shell).RemoveAppearanceObserver(this); base.OnDestroy(); }