Move FillItem property from GridView to TypeGridViewCell 24/125624/4
authorSungHyun Min <shyun.min@samsung.com>
Mon, 17 Apr 2017 07:44:47 +0000 (16:44 +0900)
committerSungHyun Min <shyun.min@samsung.com>
Tue, 25 Apr 2017 01:55:08 +0000 (10:55 +0900)
Change-Id: Ib7f95e800e76a8746785d0aa18e092cd2cc3c5ec
Signed-off-by: SungHyun Min <shyun.min@samsung.com>
Tizen.Xamarin.Forms.Extension.Renderer/Cells/GridViewTypeCellRenderer.cs
Tizen.Xamarin.Forms.Extension.Renderer/GridViewRenderer.cs
Tizen.Xamarin.Forms.Extension/Cells/GridViewCell.cs
Tizen.Xamarin.Forms.Extension/GridView.cs

index ee726db..2dd051c 100644 (file)
@@ -23,7 +23,7 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
 
         protected override Span OnGetText(Cell cell, string part)
         {
-            TCell type1Cell = cell as TCell;
+            TCell type1Cell = (TCell)cell;
             return new Span()
             {
                 Text = type1Cell.Text,
@@ -35,15 +35,16 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
         {
             if (part == IconPart)
             {
-                TCell typeCell = cell as TCell;
+                TCell typeCell = (TCell)cell;
                 var image = new NImage(TForms.Context.MainWindow);
+                image.IsFixedAspect = !typeCell.FillItem;
                 var task = image.LoadFromImageSourceAsync(ImageSource.FromFile(typeCell.Content));
                 return image;
             }
 
             if (part == EndPart)
             {
-                TCell typeCell = cell as TCell;
+                TCell typeCell = (TCell)cell;
                 if (typeCell.IsBadgeVisible)
                 {
                     var badge = new ElmSharp.Layout(TForms.Context.MainWindow);
@@ -63,7 +64,7 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
             }
             else if (property == TypeGridViewCell.BadgeCountProperty.PropertyName || property == TypeGridViewCell.IsBadgeVisibleProperty.PropertyName)
             {
-                var typeCell = cell as TCell;
+                var typeCell = (TCell)cell;
                 EvasObject badge;
                 realizedView.TryGetValue(EndPart, out badge);
                 if (badge == null)
@@ -83,11 +84,21 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
             else if (property == TypeGridViewCell.ContentProperty.PropertyName)
             {
                 EvasObject img;
-                var typeCell = cell as TCell;
+                var typeCell = (TCell)cell;
                 realizedView.TryGetValue(IconPart, out img);
                 (img as NImage)?.LoadFromImageSourceAsync(typeCell.Content);
                 return false;
             }
+            else if (property == TypeGridViewCell.FillItemProperty.PropertyName)
+            {
+                EvasObject img;
+                var typeCell = (TCell)cell;
+                realizedView.TryGetValue(IconPart, out img);
+                var nativeImg = img as NImage;
+                if (nativeImg != null)
+                    nativeImg.IsFixedAspect = !typeCell.FillItem;
+                return false;
+            }
             return false;
         }
     }
@@ -105,5 +116,4 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
         {
         }
     }
-
 }
\ No newline at end of file
index 4edcc71..70e9df0 100644 (file)
@@ -40,7 +40,6 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
             RegisterPropertyHandler(GridView.SelectionModeProperty, UpdateSelectionMode);
             RegisterPropertyHandler(GridView.CanSelectionMultipleProperty, UpdateSelectionMultiple);
             RegisterPropertyHandler(GridView.IsHighlightEffectEnabledProperty, UpdateHighlight);
-            RegisterPropertyHandler(GridView.FillItemsProperty, UpdateFillItem);
             RegisterPropertyHandler(GridView.OrientationProperty, UpdateOrientation);
             RegisterPropertyHandler(GridView.ItemsSourceProperty, UpdateSource);
             RegisterPropertyHandler(GridView.ScrollBarVisiblePolicyProperty, UpdateScrollBarVisiblePolicy);
@@ -139,11 +138,6 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
             Control.IsHighlight = Element.IsHighlightEffectEnabled;
         }
 
-        void UpdateFillItem()
-        {
-            Control.FillItems = Element.FillItems;
-        }
-
         void UpdateOrientation()
         {
             Control.IsHorizontal = (Element.Orientation == GridViewOrientation.Horizontal);
index c23bc55..a85c00d 100644 (file)
@@ -61,13 +61,15 @@ namespace Tizen.Xamarin.Forms.Extension
     /// </remarks>
     public abstract class TypeGridViewCell : Cell, IGridVeiwCell
     {
-        public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(GridViewCell), "");
+        public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(TypeGridViewCell), "");
 
-        public static readonly BindableProperty ContentProperty = BindableProperty.Create("Content", typeof(string), typeof(GridViewCell), "");
+        public static readonly BindableProperty ContentProperty = BindableProperty.Create("Content", typeof(string), typeof(TypeGridViewCell), "");
 
-        public static readonly BindableProperty IsBadgeVisibleProperty = BindableProperty.Create("IsBadgeVisible", typeof(bool), typeof(GridViewCell), false);
+        public static readonly BindableProperty IsBadgeVisibleProperty = BindableProperty.Create("IsBadgeVisible", typeof(bool), typeof(TypeGridViewCell), false);
 
-        public static readonly BindableProperty BadgeCountProperty = BindableProperty.Create("BadgeCount", typeof(int), typeof(GridViewCell), default(int));
+        public static readonly BindableProperty BadgeCountProperty = BindableProperty.Create("BadgeCount", typeof(int), typeof(TypeGridViewCell), default(int));
+
+        public static readonly BindableProperty FillItemProperty = BindableProperty.Create("FillItem", typeof(bool), typeof(TypeGridViewCell), false);
 
         /// <summary>
         /// Gets or sets the the Text displayed as the content of Item.
@@ -104,7 +106,17 @@ namespace Tizen.Xamarin.Forms.Extension
             get { return (int)GetValue(BadgeCountProperty); }
             set { SetValue(BadgeCountProperty, value); }
         }
+
+        /// <summary>
+        /// Gets or sets a value to indicate whether the content fill to the item.
+        /// </summary>
+        public bool FillItem
+        {
+            get { return (bool)GetValue(FillItemProperty); }
+            set { SetValue(FillItemProperty, value); }
+        }
     }
+
     /// <summary>
     /// Type1GridViewCell is a class inherited from a TypeGridViewCell.
     /// </summary>
index 974b1eb..570ea26 100644 (file)
@@ -118,11 +118,6 @@ namespace Tizen.Xamarin.Forms.Extension
         public static readonly BindableProperty IsHighlightEffectEnabledProperty = BindableProperty.Create("IsHighlight", typeof(bool), typeof(GridView), true);
 
         /// <summary>
-        /// BindableProperty. Identifies the FillItems bindable property.
-        /// </summary>
-        public static readonly BindableProperty FillItemsProperty = BindableProperty.Create("FillItems", typeof(bool), typeof(GridView), default(bool));
-
-        /// <summary>
         /// BindableProperty. Identifies the Orientation bindable property.
         /// </summary>
         public static readonly BindableProperty OrientationProperty = BindableProperty.Create("Orientation", typeof(GridViewOrientation), typeof(GridView), GridViewOrientation.Vertical);
@@ -164,16 +159,6 @@ namespace Tizen.Xamarin.Forms.Extension
         }
 
         /// <summary>
-        /// Gets or sets a value that indicates whether the content fills the area for item.
-        /// By default, this value is false, the item's grid is not filled and the content is centered with the alignment.
-        /// </summary>
-        public bool FillItems
-        {
-            get { return (bool)GetValue(FillItemsProperty); }
-            set { SetValue(FillItemsProperty, value); }
-        }
-
-        /// <summary>
         /// Gets or sets a value that indicates whether the multiple selection is allowed.
         /// By default, the value is false.
         /// </summary>