Esempio n. 1
0
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            var textCell = (TextCell)item;

            var tvc = reusableCell as CellTableViewCell;

            if (tvc == null)
            {
                tvc = new CellTableViewCell(UITableViewCellStyle.Subtitle, item.GetType().FullName);
            }
            else
            {
                tvc.Cell.PropertyChanged -= tvc.HandlePropertyChanged;
            }

            tvc.Cell = textCell;
            textCell.PropertyChanged += tvc.HandlePropertyChanged;
            tvc.PropertyChanged       = HandlePropertyChanged;

            tvc.TextLabel.Text            = textCell.Text;
            tvc.DetailTextLabel.Text      = textCell.Detail;
            tvc.TextLabel.TextColor       = textCell.TextColor.ToUIColor(DefaultTextColor);
            tvc.DetailTextLabel.TextColor = textCell.DetailColor.ToUIColor(DefaultDetailColor);

            WireUpForceUpdateSizeRequested(item, tvc, tv);

            UpdateIsEnabled(tvc, textCell);

            UpdateBackground(tvc, item);

            return(tvc);
        }
Esempio n. 2
0
        public override UITableViewCell GetCell(Xamarin.Forms.Cell item, UITableView tv)
        {
            TextCell textCell = (TextCell)item;
            UITableViewCellStyle style = UITableViewCellStyle.Value1;
            string text = "Xamarin.Forms.TextCell";
            CellTableViewCell cellTableViewCell = tv.DequeueReusableCell(text) as CellTableViewCell;
            if (cellTableViewCell == null)
            {
                cellTableViewCell = new CellTableViewCell(style, text);
            }
            else
            {
                cellTableViewCell.Cell.PropertyChanged -= new PropertyChangedEventHandler(cellTableViewCell.HandlePropertyChanged);
            }
            cellTableViewCell.Cell = textCell;
            textCell.PropertyChanged += new PropertyChangedEventHandler(cellTableViewCell.HandlePropertyChanged);
            cellTableViewCell.PropertyChanged = new Action<object, PropertyChangedEventArgs>(this.HandlePropertyChanged);
            cellTableViewCell.TextLabel.Text = textCell.Text;
            cellTableViewCell.DetailTextLabel.Text = textCell.Detail;
            //cellTableViewCell.TextLabel.TextColor = textCell.TextColor.ToUIColor(TextCellRenderer.DefaultTextColor);
            //cellTableViewCell.DetailTextLabel.TextColor = textCell.DetailColor.ToUIColor(TextCellRenderer.DefaultDetailColor);
            base.UpdateBackground(cellTableViewCell, item);

            cellTableViewCell.Accessory = UITableViewCellAccessory.DisclosureIndicator;

            return cellTableViewCell;
        }
Esempio n. 3
0
		public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
		{
			var textCell = (TextCell)item;

			var tvc = reusableCell as CellTableViewCell;
			if (tvc == null)
				tvc = new CellTableViewCell(UITableViewCellStyle.Subtitle, item.GetType().FullName);
			else
				tvc.Cell.PropertyChanged -= tvc.HandlePropertyChanged;

			tvc.Cell = textCell;
			textCell.PropertyChanged += tvc.HandlePropertyChanged;
			tvc.PropertyChanged = HandlePropertyChanged;

			tvc.TextLabel.Text = textCell.Text;
			tvc.DetailTextLabel.Text = textCell.Detail;
			tvc.TextLabel.TextColor = textCell.TextColor.ToUIColor(DefaultTextColor);
			tvc.DetailTextLabel.TextColor = textCell.DetailColor.ToUIColor(DefaultDetailColor);

			WireUpForceUpdateSizeRequested(item, tvc, tv);

			UpdateIsEnabled(tvc, textCell);

			UpdateBackground(tvc, item);

			return tvc;
		}
Esempio n. 4
0
        async void SetImage(ImageCell cell, CellTableViewCell target)
        {
            var source = cell.ImageSource;

            target.ImageView.Image = null;

            IImageSourceHandler handler;

            if (source != null && (handler = Registrar.Registered.GetHandler <IImageSourceHandler>(source.GetType())) != null)
            {
                UIImage uiimage;
                try
                {
                    uiimage = await handler.LoadImageAsync(source).ConfigureAwait(false);
                }
                catch (TaskCanceledException)
                {
                    uiimage = null;
                }

                NSRunLoop.Main.BeginInvokeOnMainThread(() =>
                {
                    target.ImageView.Image = uiimage;
                    target.SetNeedsLayout();
                });
            }
            else
            {
                target.ImageView.Image = null;
            }
        }
Esempio n. 5
0
		async void SetImage(ImageCell cell, CellTableViewCell target)
		{
			var source = cell.ImageSource;

			target.ImageView.Image = null;

			IImageSourceHandler handler;

			if (source != null && (handler = Registrar.Registered.GetHandler<IImageSourceHandler>(source.GetType())) != null)
			{
				UIImage uiimage;
				try
				{
					uiimage = await handler.LoadImageAsync(source).ConfigureAwait(false);
				}
				catch (TaskCanceledException)
				{
					uiimage = null;
				}

				NSRunLoop.Main.BeginInvokeOnMainThread(() =>
				{
					target.ImageView.Image = uiimage;
					target.SetNeedsLayout();
				});
			}
			else
				target.ImageView.Image = null;
		}
Esempio n. 6
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            var cell = Controller.Model.GetCell(indexPath.Section, indexPath.Row);

            var nativeCell = CellTableViewCell.GetNativeCell(tableView, cell);

            return(nativeCell);
        }
Esempio n. 7
0
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            var textCell = (TextCell)item;

            if (!(reusableCell is CellTableViewCell tvc))
            {
                tvc = new CellTableViewCell(UITableViewCellStyle.Subtitle, item.GetType().FullName);
            }
Esempio n. 8
0
        void UpdateFlowDirection(CellTableViewCell cell, SwitchCell switchCell)
        {
            IVisualElementController controller = switchCell.Parent as View;

            var uiSwitch = cell.AccessoryView as UISwitch;

            uiSwitch.UpdateFlowDirection(controller);
        }
        /// <summary>
        /// Gets the cell.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="reusableCell">The reusable TableView cell.</param>
        /// <param name="tv">The TableView.</param>
        /// <returns>UITableViewCell.</returns>
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
		{
			var extendedCell = (ExtendedTextCell)item;

			TextCell textCell = (TextCell)item;
			UITableViewCellStyle style = UITableViewCellStyle.Subtitle;
			if (extendedCell.DetailLocation == TextCellDetailLocation.Right)
				style = UITableViewCellStyle.Value1;

			string fullName = item.GetType ().FullName;
			CellTableViewCell cell = tv.DequeueReusableCell (fullName) as CellTableViewCell;
			if (cell == null) {
				cell = new CellTableViewCell (style, fullName);
			}
			else {
				cell.Cell.PropertyChanged -= new PropertyChangedEventHandler (cell.HandlePropertyChanged);
			}
			cell.Cell = textCell;
			textCell.PropertyChanged += new PropertyChangedEventHandler (cell.HandlePropertyChanged);
			cell.PropertyChanged = new Action<object, PropertyChangedEventArgs> (HandlePropertyChanged);
			cell.TextLabel.Text = textCell.Text;
			cell.DetailTextLabel.Text = textCell.Detail;
			cell.TextLabel.TextColor = textCell.TextColor.ToUIColor (DefaultTextColor);
			cell.DetailTextLabel.TextColor = textCell.DetailColor.ToUIColor (DefaultDetailColor);

			UpdateBackground (cell, item);

			if (cell != null) {
				cell.BackgroundColor = extendedCell.BackgroundColor.ToUIColor ();
				cell.SeparatorInset = new UIEdgeInsets ((float)extendedCell.SeparatorPadding.Top, (float)extendedCell.SeparatorPadding.Left,
					(float)extendedCell.SeparatorPadding.Bottom, (float)extendedCell.SeparatorPadding.Right);

				if (extendedCell.ShowDisclousure) {
					cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
					if (!string.IsNullOrEmpty (extendedCell.DisclousureImage)) {
						var detailDisclosureButton = UIButton.FromType (UIButtonType.Custom);
						detailDisclosureButton.SetImage (UIImage.FromBundle (extendedCell.DisclousureImage), UIControlState.Normal);
						detailDisclosureButton.SetImage (UIImage.FromBundle (extendedCell.DisclousureImage), UIControlState.Selected);

						detailDisclosureButton.Frame = new CGRect (0f, 0f, 30f, 30f);
						detailDisclosureButton.TouchUpInside += (object sender, EventArgs e) => {
							var index = tv.IndexPathForCell (cell);
							tv.SelectRow (index, true, UITableViewScrollPosition.None);
							tv.Source.AccessoryButtonTapped (tv, index);
						};
						cell.AccessoryView = detailDisclosureButton;
					}
				}
			}

			if(!extendedCell.ShowSeparator)
				tv.SeparatorStyle = UITableViewCellSeparatorStyle.None;

			tv.SeparatorColor = extendedCell.SeparatorColor.ToUIColor();

			return cell;
		}
Esempio n. 10
0
		void UpdateIsEnabled(CellTableViewCell cell, SwitchCell switchCell)
		{
			cell.UserInteractionEnabled = switchCell.IsEnabled;
			cell.TextLabel.Enabled = switchCell.IsEnabled;
			cell.DetailTextLabel.Enabled = switchCell.IsEnabled;
			var uiSwitch = cell.AccessoryView as UISwitch;
			if (uiSwitch != null)
				uiSwitch.Enabled = switchCell.IsEnabled;
		}
 UIView CreateBackgroundView (CellTableViewCell cell, FullScheduleCellViewModel viewModel)
 {
     return new UIView {
         AutoresizingMask = UIViewAutoresizing.FlexibleHeight,
         Frame = cell.Bounds,
         BackgroundColor = ((Xamarin.Forms.Color)new TrackBackgroundColorConverter ()
             .Convert (viewModel.Track, typeof(Xamarin.Forms.Color), 
                 null, CultureInfo.CurrentCulture))
             .ToUIColor ()
         };
 }
 public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
 {
     var tvc = reusableCell as CellTableViewCell;
     if (tvc == null) {
         tvc = new CellTableViewCell (UITableViewCellStyle.Value1, item.GetType().FullName);
     }
     tvc.Cell = item;
     var cell = base.GetCell(item, tvc, tv);
     cell.SetDisclosure(item.StyleId);
     return cell;
 }
Esempio n. 13
0
        void UpdateIsEnabled(CellTableViewCell cell, SwitchCell switchCell)
        {
            cell.UserInteractionEnabled  = switchCell.IsEnabled;
            cell.TextLabel.Enabled       = switchCell.IsEnabled;
            cell.DetailTextLabel.Enabled = switchCell.IsEnabled;
            var uiSwitch = cell.AccessoryView as UISwitch;

            if (uiSwitch != null)
            {
                uiSwitch.Enabled = switchCell.IsEnabled;
            }
        }
        void AddSubviews (FullScheduleCellViewModel viewModel, CellTableViewCell cellTableViewCell)
        {
            var textColor = ((Xamarin.Forms.Color)new TrackTextColorConverter ()
                .Convert (viewModel.Track, typeof(Xamarin.Forms.Color), 
                    null, CultureInfo.CurrentCulture))
                .ToUIColor ();

            cellTableViewCell.AddSubview (CreateBackgroundView (cellTableViewCell, viewModel));
            cellTableViewCell.AddSubview (CreateTitleLabel (viewModel, textColor));
            cellTableViewCell.AddSubview (CreateLocationLabel (viewModel, textColor));
            cellTableViewCell.AddSubview (CreateTrackLabel (viewModel, textColor));

            if (viewModel.IsOptional) cellTableViewCell.AddSubview (
                CreateSelectButton (viewModel, textColor, cellTableViewCell));
        }
Esempio n. 15
0
        void UpdateOnColor(CellTableViewCell cell, SwitchCell switchCell)
        {
            var uiSwitch = cell.AccessoryView as UISwitch;

            if (uiSwitch != null)
            {
                if (switchCell.OnColor == Color.Default)
                {
                    uiSwitch.OnTintColor = _defaultOnColor;
                }
                else
                {
                    uiSwitch.OnTintColor = switchCell.OnColor.ToUIColor();
                }
            }
        }
Esempio n. 16
0
        void OnSwitchValueChanged(object sender, EventArgs eventArgs)
        {
            var view = (UIView)sender;
            var sw   = (UISwitch)view;

            CellTableViewCell realCell = null;

            while (view.Superview != null && realCell == null)
            {
                view     = view.Superview;
                realCell = view as CellTableViewCell;
            }

            if (realCell != null)
            {
                ((SwitchCell)realCell.Cell).On = sw.On;
            }
        }
Esempio n. 17
0
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            var      tvc      = reusableCell as CellTableViewCell;
            UISwitch uiSwitch = null;

            if (tvc == null)
            {
                tvc = new CellTableViewCell(UITableViewCellStyle.Value1, CellName);
            }
            else
            {
                uiSwitch             = tvc.AccessoryView as UISwitch;
                tvc.PropertyChanged -= HandlePropertyChanged;
            }

            SetRealCell(item, tvc);

            if (uiSwitch == null)
            {
                uiSwitch = new UISwitch(new RectangleF());
                uiSwitch.ValueChanged += OnSwitchValueChanged;
                tvc.AccessoryView      = uiSwitch;
            }

            var boolCell = (SwitchCell)item;

            _defaultOnColor = UISwitch.Appearance.OnTintColor;

            tvc.Cell             = item;
            tvc.PropertyChanged += HandlePropertyChanged;
            tvc.AccessoryView    = uiSwitch;
            tvc.TextLabel.Text   = boolCell.Text;

            uiSwitch.On = boolCell.On;

            WireUpForceUpdateSizeRequested(item, tvc, tv);

            UpdateBackground(tvc, item);
            UpdateIsEnabled(tvc, boolCell);
            UpdateFlowDirection(tvc, boolCell);
            UpdateOnColor(tvc, boolCell);

            return(tvc);
        }
Esempio n. 18
0
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                UITableViewCell nativeCell = null;

                var cachingStrategy = Controller.CachingStrategy;

                if (cachingStrategy == ListViewCachingStrategy.RetainElement)
                {
                    var cell = GetCellForPath(indexPath);
                    nativeCell = CellTableViewCell.GetNativeCell(tableView, cell);
                }
                else if (cachingStrategy == ListViewCachingStrategy.RecycleElement)
                {
                    var id = TemplateIdForPath(indexPath);
                    nativeCell = tableView.DequeueReusableCell(ContextActionsCell.Key + id);
                    if (nativeCell == null)
                    {
                        var cell = GetCellForPath(indexPath);
                        nativeCell = CellTableViewCell.GetNativeCell(tableView, cell, true, id.ToString());
                    }
                    else
                    {
                        var             templatedList = TemplatedItemsView.TemplatedItems.GetGroup(indexPath.Section);
                        var             cell          = (Cell)((INativeElementView)nativeCell).Element;
                        ICellController controller    = cell;
                        controller.SendDisappearing();
                        templatedList.UpdateContent(cell, indexPath.Row);
                        controller.SendAppearing();
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }

                var bgColor = tableView.IndexPathForSelectedRow != null && tableView.IndexPathForSelectedRow.Equals(indexPath) ? UIColor.Clear : DefaultBackgroundColor;

                SetCellBackgroundColor(nativeCell, bgColor);

                return(nativeCell);
            }
Esempio n. 19
0
		public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
		{
			var tvc = reusableCell as CellTableViewCell;
			UISwitch uiSwitch = null;
			if (tvc == null)
				tvc = new CellTableViewCell(UITableViewCellStyle.Value1, CellName);
			else
			{
				uiSwitch = tvc.AccessoryView as UISwitch;
				tvc.Cell.PropertyChanged -= OnCellPropertyChanged;
			}

			SetRealCell(item, tvc);

			if (uiSwitch == null)
			{
				uiSwitch = new UISwitch(new RectangleF());
				uiSwitch.ValueChanged += OnSwitchValueChanged;
				tvc.AccessoryView = uiSwitch;
			}

			var boolCell = (SwitchCell)item;

			tvc.Cell = item;
			tvc.Cell.PropertyChanged += OnCellPropertyChanged;
			tvc.AccessoryView = uiSwitch;
			tvc.TextLabel.Text = boolCell.Text;

			uiSwitch.On = boolCell.On;

			WireUpForceUpdateSizeRequested(item, tvc, tv);

			UpdateBackground(tvc, item);
			UpdateIsEnabled(tvc, boolCell);

			return tvc;
		}
Esempio n. 20
0
        async void SetImage(ImageCell cell, CellTableViewCell target)
        {
            var source = cell.ImageSource;

            target.ImageView.Image = null;

            var uiimage = await source.GetNativeImageAsync().ConfigureAwait(false);

            if (uiimage != null)
            {
                NSRunLoop.Main.BeginInvokeOnMainThread(() =>
                {
                    if (target.Cell != null)
                    {
                        target.ImageView.Image = uiimage;
                        target.SetNeedsLayout();
                    }
                    else
                    {
                        uiimage?.Dispose();
                    }
                });
            }
        }
Esempio n. 21
0
		static void UpdateIsEnabled(CellTableViewCell cell, TextCell entryCell)
		{
			cell.UserInteractionEnabled = entryCell.IsEnabled;
			cell.TextLabel.Enabled = entryCell.IsEnabled;
			cell.DetailTextLabel.Enabled = entryCell.IsEnabled;
		}
Esempio n. 22
0
 static void UpdateIsEnabled(CellTableViewCell cell, TextCell entryCell)
 {
     cell.UserInteractionEnabled  = entryCell.IsEnabled;
     cell.TextLabel.Enabled       = entryCell.IsEnabled;
     cell.DetailTextLabel.Enabled = entryCell.IsEnabled;
 }