コード例 #1
0
ファイル: EntryCellRenderer.cs プロジェクト: TabNoc/PiWeb
 private static void UpdateText(CellView cell, EntryCell entryCell)
 {
     if (cell.CustomView.FirstChild is TextInput textInput)
     {
         textInput.Text = entryCell.Text ?? string.Empty;
     }
 }
コード例 #2
0
ファイル: EntryCellRenderer.cs プロジェクト: TabNoc/PiWeb
 private static void UpdatePlaceholder(CellView cell, EntryCell entryCell)
 {
     if (cell.CustomView.FirstChild is TextInput textInput)
     {
         textInput.Placeholder = entryCell.Placeholder ?? string.Empty;
     }
 }
コード例 #3
0
ファイル: TextCellRenderer.cs プロジェクト: yrest/Ooui
        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);
        }
コード例 #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;
            }
        }
コード例 #5
0
        protected void WireUpForceUpdateSizeRequested(Cell cell, CellView nativeCell)
        {
            cell.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested;

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

            cell.ForceUpdateSizeRequested += _onForceUpdateSizeRequested;
        }
コード例 #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;
            }
        }
コード例 #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);
        }
コード例 #8
0
ファイル: EntryCellRenderer.cs プロジェクト: TabNoc/PiWeb
        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;
            }
        }
コード例 #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;
        }
コード例 #10
0
ファイル: EntryCellRenderer.cs プロジェクト: TabNoc/PiWeb
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #13
0
ファイル: ViewCellRenderer.cs プロジェクト: TabNoc/PiWeb
        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);
        }
コード例 #14
0
 protected virtual void OnForceUpdateSizeRequest(Cell cell, CellView nativeCell)
 {
     nativeCell.Style.Height = (int)cell.RenderHeight;
 }
コード例 #15
0
ファイル: EntryCellRenderer.cs プロジェクト: TabNoc/PiWeb
 private static void UpdateLabelColor(CellView cell, EntryCell entryCell)
 {
     cell.TextLabel.Style.Color = entryCell.LabelColor.ToOouiColor();
 }
コード例 #16
0
ファイル: EntryCellRenderer.cs プロジェクト: TabNoc/PiWeb
 private static void UpdateLabel(CellView cell, EntryCell entryCell)
 {
     cell.TextLabel.Text = entryCell.Label ?? string.Empty;
 }
コード例 #17
0
 internal static void SetRealCell(BindableObject cell, CellView renderer)
 {
     cell.SetValue(RealCellProperty, renderer);
 }