Remove the unused code in NavigationPage (#134)
author윤정현/Common Platform Lab(SR)/Staff Engineer/삼성전자 <jh0506.yun@samsung.com>
Tue, 14 Jan 2020 05:26:44 +0000 (14:26 +0900)
committer유리나/Common Platform Lab(SR)/Staff Engineer/삼성전자 <rina6350.you@samsung.com>
Tue, 14 Jan 2020 05:26:44 +0000 (14:26 +0900)
Xamarin.Forms/Xamarin.Forms.Core/NavigationPage.cs
Xamarin.Forms/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/NavigationPage.cs [deleted file]
Xamarin.Forms/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs

index 10e4cec..aaac21a 100644 (file)
@@ -12,12 +12,8 @@ namespace Xamarin.Forms
        [RenderWith(typeof(_NavigationPageRenderer))]
        public class NavigationPage : Page, IPageContainer<Page>, IBarElement, INavigationPageController, IElementConfiguration<NavigationPage> 
        {
-               public static readonly BindableProperty BackButtonTitleProperty = BindableProperty.CreateAttached("BackButtonTitle", typeof(string), typeof(Page), null);
-
                public static readonly BindableProperty HasNavigationBarProperty = BindableProperty.CreateAttached("HasNavigationBar", typeof(bool), typeof(Page), true);
 
-               public static readonly BindableProperty HasBackButtonProperty = BindableProperty.CreateAttached("HasBackButton", typeof(bool), typeof(NavigationPage), true);
-
                public static readonly BindableProperty BarBackgroundColorProperty = BarElement.BarBackgroundColorProperty;
 
                public static readonly BindableProperty BarTextColorProperty = BarElement.BarTextColorProperty;
@@ -107,18 +103,6 @@ namespace Xamarin.Forms
                        }
                }
 
-               public static string GetBackButtonTitle(BindableObject page)
-               {
-                       return (string)page.GetValue(BackButtonTitleProperty);
-               }
-
-               public static bool GetHasBackButton(Page page)
-               {
-                       if (page == null)
-                               throw new ArgumentNullException("page");
-                       return (bool)page.GetValue(HasBackButtonProperty);
-               }
-
                public static bool GetHasNavigationBar(BindableObject page)
                {
                        return (bool)page.GetValue(HasNavigationBarProperty);
@@ -214,18 +198,6 @@ namespace Xamarin.Forms
 
                public event EventHandler<NavigationEventArgs> Pushed;
 
-               public static void SetBackButtonTitle(BindableObject page, string value)
-               {
-                       page.SetValue(BackButtonTitleProperty, value);
-               }
-
-               public static void SetHasBackButton(Page page, bool value)
-               {
-                       if (page == null)
-                               throw new ArgumentNullException("page");
-                       page.SetValue(HasBackButtonProperty, value);
-               }
-
                public static void SetHasNavigationBar(BindableObject page, bool value)
                {
                        page.SetValue(HasNavigationBarProperty, value);
diff --git a/Xamarin.Forms/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/NavigationPage.cs b/Xamarin.Forms/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/NavigationPage.cs
deleted file mode 100644 (file)
index 3522239..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
-{
-       using FormsElement = Forms.NavigationPage;
-
-       public static class NavigationPage
-       {
-               #region HasBreadCrumbsBar
-               public static readonly BindableProperty HasBreadCrumbsBarProperty
-                       = BindableProperty.CreateAttached("HasBreadCrumbsBar", typeof(bool), typeof(FormsElement), false);
-
-               public static bool GetHasBreadCrumbsBar(BindableObject element)
-               {
-                       return (bool)element.GetValue(HasBreadCrumbsBarProperty);
-               }
-
-               public static void SetHasBreadCrumbsBar(BindableObject element, bool value)
-               {
-                       element.SetValue(HasBreadCrumbsBarProperty, value);
-               }
-
-               public static bool HasBreadCrumbsBar(this IPlatformElementConfiguration<Tizen, FormsElement> config)
-               {
-                       return GetHasBreadCrumbsBar(config.Element);
-               }
-
-               public static IPlatformElementConfiguration<Tizen, FormsElement> SetHasBreadCrumbsBar(this IPlatformElementConfiguration<Tizen, FormsElement> config, bool value)
-               {
-                       SetHasBreadCrumbsBar(config.Element, value);
-                       return config;
-               }
-               #endregion
-       }
-}
index 0f57bd1..f04a1c6 100644 (file)
@@ -3,37 +3,18 @@ using System.Linq;
 using System.Threading.Tasks;
 using System.Collections.Generic;
 using Xamarin.Forms.Internals;
-using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
 using ElmSharp;
-using EButton = ElmSharp.Button;
-using EToolbar = ElmSharp.Toolbar;
-using EToolbarItem = ElmSharp.ToolbarItem;
-using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.NavigationPage;
-using SpecificPage = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Page;
 
 namespace Xamarin.Forms.Platform.Tizen
 {
        public class NavigationPageRenderer : VisualElementRenderer<NavigationPage>
        {
-               enum ToolbarButtonPosition
-               {
-                       Left,
-                       Right
-               };
-
                const string PartTitle = "default";
-               const string PartBackButton = "elm.swallow.prev_btn";
-               const string PartLeftToolbar = "title_left_btn";
-               const string PartRightToolbar = "title_right_btn";
-               const string PartNavigationBar = "navigationbar";
-               const string StyleBackButton = "naviframe/back_btn/default";
-               const string StyleNavigationBar = "navigationbar";
 
                readonly List<Widget> _naviItemContentPartList = new List<Widget>();
                Naviframe _naviFrame = null;
                Page _previousPage = null;
                TaskCompletionSource<bool> _currentTaskSource = null;
-               ToolbarTracker _toolbarTracker = null;
                IDictionary<Page, NaviItem> _naviItemMap;
 
                Page CurrentPage => Element.CurrentPage;
@@ -49,10 +30,6 @@ namespace Xamarin.Forms.Platform.Tizen
                                {
                                        _naviFrame.AnimationFinished -= OnAnimationFinished;
                                }
-                               if (_toolbarTracker != null)
-                               {
-                                       _toolbarTracker.CollectionChanged -= OnToolbarCollectionChanged;
-                               }
                        }
                        base.Dispose(disposing);
                }
@@ -70,12 +47,6 @@ namespace Xamarin.Forms.Platform.Tizen
                                _naviItemMap = new Dictionary<Page, NaviItem>();
                        }
 
-                       if (_toolbarTracker == null)
-                       {
-                               _toolbarTracker = new ToolbarTracker();
-                               _toolbarTracker.CollectionChanged += OnToolbarCollectionChanged;
-                       }
-
                        if (e.OldElement != null)
                        {
                                var navigation = e.OldElement as INavigationPageController;
@@ -98,7 +69,6 @@ namespace Xamarin.Forms.Platform.Tizen
                                navigation.RemovePageRequested += OnRemovePageRequested;
                                navigation.InsertPageBeforeRequested += OnInsertPageBeforeRequested;
 
-                               _toolbarTracker.Target = e.NewElement;
                                _previousPage = e.NewElement.CurrentPage;
                        }
                        base.OnElementChanged(e);
@@ -137,9 +107,6 @@ namespace Xamarin.Forms.Platform.Tizen
                        // Tizen does not support 'Tint', but only 'BarBackgroundColor'
                        else if (e.PropertyName == NavigationPage.BarBackgroundColorProperty.PropertyName)
                                UpdateBarBackgroundColor(CurrentNaviItem);
-                       else if (e.PropertyName == Specific.HasBreadCrumbsBarProperty.PropertyName)
-                               UpdateBreadCrumbsBar(CurrentNaviItem);
-
                }
 
                void OnPageCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
@@ -152,23 +119,13 @@ namespace Xamarin.Forms.Platform.Tizen
                                        page.PropertyChanged += NavigationBarPropertyChangedHandler;
                }
 
-               void OnToolbarCollectionChanged(object sender, EventArgs eventArgs)
-               {
-                       UpdateToolbarItem(Element.CurrentPage);
-               }
-
                void NavigationBarPropertyChangedHandler(object sender, System.ComponentModel.PropertyChangedEventArgs e)
                {
                        // this handler is invoked only for child pages (contained on a navigation stack)
                        if (e.PropertyName == NavigationPage.HasNavigationBarProperty.PropertyName)
                                UpdateHasNavigationBar(sender as Page);
-                       else if (e.PropertyName == NavigationPage.HasBackButtonProperty.PropertyName ||
-                               e.PropertyName == NavigationPage.BackButtonTitleProperty.PropertyName)
-                               UpdateHasBackButton(sender as Page);
                        else if (e.PropertyName == Page.TitleProperty.PropertyName)
                                UpdateTitle(sender as Page);
-                       else if (e.PropertyName == SpecificPage.BreadCrumbProperty.PropertyName)
-                               UpdateBreadCrumbsBar(GetNaviItemForPage(sender as Page));
                }
 
                void UpdateHasNavigationBar(Page page)
@@ -185,39 +142,7 @@ namespace Xamarin.Forms.Platform.Tizen
                                return;
                        }
                        item.TitleBarVisible = (bool)page.GetValue(NavigationPage.HasNavigationBarProperty);
-                       UpdateToolbarItem(page, item);
                        UpdateBarBackgroundColor(item);
-                       UpdateBreadCrumbsBar(item);
-               }
-
-               void UpdateToolbarItem(Page page, NaviItem item = null)
-               {
-                       if (item == null)
-                               item = GetNaviItemForPage(page);
-
-                       if (_naviFrame.NavigationStack.Count == 0 || item == null || item != _naviFrame.NavigationStack.Last())
-                               return;
-
-                       Native.Button rightButton = GetToolbarButton(ToolbarButtonPosition.Right);
-                       item.SetPartContent(PartRightToolbar, rightButton);
-
-                       Native.Button leftButton = GetToolbarButton(ToolbarButtonPosition.Left);
-                       item.SetPartContent(PartLeftToolbar, leftButton);
-                       UpdateHasBackButton(page, item);
-               }
-
-               void UpdateHasBackButton(Page page, NaviItem item = null)
-               {
-                       if (item == null)
-                               item = GetNaviItemForPage(page);
-
-                       EButton button = null;
-
-                       if ((bool)page.GetValue(NavigationPage.HasBackButtonProperty) && _naviFrame.NavigationStack.Count > 1)
-                       {
-                               button = CreateNavigationButton((string)page.GetValue(NavigationPage.BackButtonTitleProperty));
-                       }
-                       item.SetPartContent(PartBackButton, button);
                }
 
                void UpdateTitle(Page page, NaviItem item = null)
@@ -253,37 +178,6 @@ namespace Xamarin.Forms.Platform.Tizen
                        UpdateBarBackgroundColor(item);
                }
 
-               void UpdateBreadCrumbsBar(NaviItem item)
-               {
-                       if (Element.OnThisPlatform().HasBreadCrumbsBar())
-                       {
-                               item.Style = StyleNavigationBar;
-                               item.SetPartContent(PartNavigationBar, GetBreadCrumbsBar());
-                       }
-                       else
-                       {
-                               item.SetPartContent(PartNavigationBar, null, false);
-                       }
-               }
-
-               EButton CreateNavigationButton(string text)
-               {
-                       EButton button = new EButton(Forms.NativeParent);
-                       button.Clicked += (sender, e) =>
-                       {
-                               if (!Element.SendBackButtonPressed())
-                                       Forms.Context.Exit();
-                       };
-
-                       button.Style = StyleBackButton;
-                       button.Text = text;
-
-                       _naviItemContentPartList.Add(button);
-                       button.Deleted += NaviItemPartContentDeletedHandler;
-
-                       return button;
-               }
-
                void NaviItemPartContentDeletedHandler(object sender, EventArgs e)
                {
                        _naviItemContentPartList.Remove(sender as Widget);
@@ -299,53 +193,6 @@ namespace Xamarin.Forms.Platform.Tizen
                        return null;
                }
 
-               Native.Button GetToolbarButton(ToolbarButtonPosition position)
-               {
-                       ToolbarItem item = _toolbarTracker.ToolbarItems.Where(
-                               i => (position == ToolbarButtonPosition.Right && i.Order <= ToolbarItemOrder.Primary)
-                               || (position == ToolbarButtonPosition.Left && i.Order == ToolbarItemOrder.Secondary))
-                               .OrderBy(i => i.Priority).FirstOrDefault();
-
-                       if (item == default(ToolbarItem))
-                               return null;
-
-                       Native.ToolbarItemButton button = new Native.ToolbarItemButton(item);
-                       return button;
-               }
-
-               EToolbar GetBreadCrumbsBar()
-               {
-                       EToolbar toolbar = new EToolbar(Forms.NativeParent)
-                       {
-                               Style = StyleNavigationBar,
-                               ItemAlignment = 0,
-                               Homogeneous = false,
-                               ShrinkMode = ToolbarShrinkMode.Scroll
-                       };
-
-                       foreach (var p in Element.Navigation.NavigationStack)
-                       {
-                               string breadCrumb = p.OnThisPlatform().GetBreadCrumb();
-                               if (!string.IsNullOrEmpty(breadCrumb))
-                               {
-                                       EToolbarItem toolbarItem = toolbar.Append(breadCrumb);
-                                       toolbarItem.Selected += (s, e) =>
-                                       {
-                                               var copyOfStack = Element.Navigation.NavigationStack.Reverse().Skip(1);
-                                               foreach (var lp in copyOfStack)
-                                               {
-                                                       if (lp == p) break;
-                                                       Element.Navigation.RemovePage(lp);
-                                               }
-                                               if (Element.Navigation.NavigationStack.Last() != p)
-                                                       Element.Navigation.PopAsync();
-                                       };
-                               }
-                       }
-
-                       return toolbar;
-               }
-
                void OnPopRequested(object sender, NavigationRequestedEventArgs nre)
                {
                        if ((Element as IPageController).InternalChildren.Count == _naviFrame.NavigationStack.Count)