Exemple #1
0
 private static void UpdateText(CellView cell, EntryCell entryCell)
 {
     if (cell.CustomView.FirstChild is TextInput textInput)
     {
         textInput.Text = entryCell.Text ?? string.Empty;
     }
 }
Exemple #2
0
 private static void UpdatePlaceholder(CellView cell, EntryCell entryCell)
 {
     if (cell.CustomView.FirstChild is TextInput textInput)
     {
         textInput.Placeholder = entryCell.Placeholder ?? string.Empty;
     }
 }
Exemple #3
0
        public override CellView GetCell(Cell item, CellView reusableView, List listView)
        {
            var nativeTextCell = base.GetCell(item, reusableView, listView);
            var textCell       = (TextCell)item;

            if (nativeTextCell.Cell != null)
            {
                nativeTextCell.Cell.PropertyChanged -= nativeTextCell.HandlePropertyChanged;
            }

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

            nativeTextCell.TextLabel.Text              = textCell.Text ?? string.Empty;
            nativeTextCell.DetailTextLabel.Text        = textCell.Detail ?? string.Empty;
            nativeTextCell.TextLabel.Style.Color       = textCell.TextColor.ToOouiColor();
            nativeTextCell.DetailTextLabel.Style.Color = textCell.DetailColor.ToOouiColor();

            WireUpForceUpdateSizeRequested(item, nativeTextCell);

            UpdateBackground(nativeTextCell, item);

            return(nativeTextCell);
        }
Exemple #4
0
        static async Task SetImage(ImageCell cell, CellView target)
        {
            var source = cell.ImageSource;

            target.ImageView.Source = null;

            IImageSourceHandler handler;

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

                target.ImageView.Source = image;
            }
            else
            {
                target.ImageView.Source = null;
            }
        }
Exemple #5
0
        protected void WireUpForceUpdateSizeRequested(Cell cell, CellView nativeCell)
        {
            cell.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested;

            _onForceUpdateSizeRequested = (sender, e) =>
            {
                OnForceUpdateSizeRequest(cell, nativeCell);
            };

            cell.ForceUpdateSizeRequested += _onForceUpdateSizeRequested;
        }
Exemple #6
0
        private void OnSwitchClick(object sender, EventArgs eventArgs)
        {
            var switchInput = (Input)sender;

            CellView realCell = GetRealCell(_cell);

            if (realCell != null)
            {
                ((SwitchCell)realCell.Cell).On = switchInput.IsChecked;
            }
        }
Exemple #7
0
        public virtual CellView GetCell(Cell item, CellView reusableView, List listView)
        {
            var nativeCell = reusableView as CellView ?? GetCellInstance(item);

            nativeCell.Cell = item;

            WireUpForceUpdateSizeRequested(item, nativeCell);
            UpdateBackground(nativeCell, item);

            return(nativeCell);
        }
Exemple #8
0
        private static void OnTextChanged(object sender, EventArgs eventArgs)
        {
            var textInput = (TextInput)sender;

            CellView realCell = GetRealCell(_cell);

            if (realCell != null)
            {
                ((EntryCell)realCell.Cell).Text = textInput.Text;
            }
        }
Exemple #9
0
        protected void UpdateBackground(CellView tableViewCell, Cell cell)
        {
            var   defaultColor    = Xamarin.Forms.Color.White.ToOouiColor();
            Color backgroundColor = defaultColor;

            if (cell.RealParent is VisualElement element)
            {
                backgroundColor = element.BackgroundColor ==
                                  Xamarin.Forms.Color.Default ? backgroundColor : element.BackgroundColor.ToOouiColor();
            }

            tableViewCell.Style.BackgroundColor = backgroundColor;
        }
Exemple #10
0
        public override CellView GetCell(Cell item, CellView reusableView, List listView)
        {
            TextInput nativeEntry = null;

            var nativeEntryCell = base.GetCell(item, reusableView, listView);

            if (nativeEntryCell == null)
            {
                nativeEntryCell = new CellView();
            }
            else
            {
                nativeEntryCell.Cell.PropertyChanged -= OnCellPropertyChanged;

                nativeEntry = nativeEntryCell.CustomView.FirstChild as TextInput;
                if (nativeEntry != null)
                {
                    nativeEntryCell.CustomView.RemoveChild(nativeEntry);
                    nativeEntry.Change -= OnTextChanged;
                }
            }

            SetRealCell(item, nativeEntryCell);

            if (nativeEntry == null)
            {
                nativeEntryCell.CustomView.AppendChild(nativeEntry = new TextInput());
            }

            var entryCell = (EntryCell)item;

            nativeEntryCell.Cell = item;
            nativeEntryCell.SecondCol.Style.Width = "25%";
            _cell = nativeEntryCell.Cell;

            nativeEntryCell.Cell.PropertyChanged += OnCellPropertyChanged;
            nativeEntry.Change += OnTextChanged;

            WireUpForceUpdateSizeRequested(item, nativeEntryCell);

            UpdateBackground(nativeEntryCell, entryCell);
            UpdateLabel(nativeEntryCell, entryCell);
            UpdateText(nativeEntryCell, entryCell);
            UpdatePlaceholder(nativeEntryCell, entryCell);
            UpdateLabelColor(nativeEntryCell, entryCell);

            return(nativeEntryCell);
        }
Exemple #11
0
        public override CellView GetCell(Cell item, CellView reusableView, List listView)
        {
            var   nativeSwitchCell = reusableView as CellView;
            Input oouiSwitch       = null;

            if (nativeSwitchCell == null)
            {
                nativeSwitchCell = new CellView();
            }
            else
            {
                oouiSwitch = nativeSwitchCell.CustomView.FirstChild as Input;

                if (oouiSwitch != null)
                {
                    nativeSwitchCell.CustomView.RemoveChild(oouiSwitch);
                    oouiSwitch.Click -= OnSwitchClick;
                }
                nativeSwitchCell.Cell.PropertyChanged -= OnCellPropertyChanged;
            }

            SetRealCell(item, nativeSwitchCell);

            if (oouiSwitch == null)
            {
                oouiSwitch = new Input(InputType.Checkbox);
                oouiSwitch.SetAttribute("data-toggle", "toggle");
            }

            var switchCell = (SwitchCell)item;

            nativeSwitchCell.Cell = item;
            nativeSwitchCell.SecondCol.Style.Width = "25%";
            _cell = nativeSwitchCell.Cell;

            nativeSwitchCell.Cell.PropertyChanged += OnCellPropertyChanged;
            nativeSwitchCell.CustomView.AppendChild(oouiSwitch);
            nativeSwitchCell.TextLabel.Text = switchCell.Text ?? string.Empty;

            oouiSwitch.IsChecked = switchCell.On;
            oouiSwitch.Click    += OnSwitchClick;

            WireUpForceUpdateSizeRequested(item, nativeSwitchCell);

            UpdateBackground(nativeSwitchCell, item);

            return(nativeSwitchCell);
        }
Exemple #12
0
        public override CellView GetCell(Cell item, CellView reusableView, List listView)
        {
            var nativeImageCell = reusableView as CellView ?? new CellView();

            var result = (CellView)base.GetCell(item, nativeImageCell, listView);

            var imageCell = (ImageCell)item;

            WireUpForceUpdateSizeRequested(item, result);

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            SetImage(imageCell, result);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

            return(result);
        }
Exemple #13
0
        public override CellView GetCell(Cell item, CellView reusableView, List listView)
        {
            var viewCell = (ViewCell)item;

            var nativeViewCell = reusableView as ViewCellView;

            if (nativeViewCell == null)
            {
                nativeViewCell = new ViewCellView();
            }

            nativeViewCell.ViewCell = viewCell;

            SetRealCell(item, nativeViewCell);

            WireUpForceUpdateSizeRequested(item, nativeViewCell);

            return(nativeViewCell);
        }
Exemple #14
0
 protected virtual void OnForceUpdateSizeRequest(Cell cell, CellView nativeCell)
 {
     nativeCell.Style.Height = (int)cell.RenderHeight;
 }
Exemple #15
0
 private static void UpdateLabelColor(CellView cell, EntryCell entryCell)
 {
     cell.TextLabel.Style.Color = entryCell.LabelColor.ToOouiColor();
 }
Exemple #16
0
 private static void UpdateLabel(CellView cell, EntryCell entryCell)
 {
     cell.TextLabel.Text = entryCell.Label ?? string.Empty;
 }
Exemple #17
0
 internal static void SetRealCell(BindableObject cell, CellView renderer)
 {
     cell.SetValue(RealCellProperty, renderer);
 }