Example #1
0
        Cell CreateTintColorCell(string colorName, Color colorValue, CellGlossAccessoryType accessoryType)
        {
            Cell result;

            if (accessoryType == CellGlossAccessoryType.EditIndicator)
            {
                result = new EntryCell();
                (result as EntryCell).Label                   = colorName;
                (result as EntryCell).Placeholder             = "Optional";
                (result as EntryCell).HorizontalTextAlignment = TextAlignment.End;
            }
            else
            {
                result = new TextCell();
                (result as TextCell).Text = colorName;
            }

            // Instantiate an instance of the Gloss properties you want to assign values to
            var gloss = new CellGloss(result);

            gloss.TintColor     = colorValue;
            gloss.AccessoryType = accessoryType;

            return(result);
        }
Example #2
0
        public BackgroundColorPage()
        {
            /*
             * This is a bit of a hack. Android's renderer for TableView always adds an empty header for a
             * TableSection declaration, while iOS doesn't. To compensate, I'm using a Label to display info text
             * on iOS, and the TableSection on Android since there is no easy way to get rid of it.This is a
             * long-standing bug in the XF TableView on Android.
             * (https://forums.xamarin.com/discussion/18037/tablesection-w-out-header)
             */
            TableSection section;

            if (Device.RuntimePlatform == Device.Android)
            {
                section = new TableSection("Cell BackgroundColor values set in C#:");
            }
            else
            {
                section = new TableSection();
            }

            var cell = new TextCell {
                Text = "Red", TextColor = Color.White
            };

            CellGloss.SetBackgroundColor(cell, Color.Red);
            section.Add(cell);

            cell = new TextCell {
                Text = "Green", TextColor = Color.White
            };
            CellGloss.SetBackgroundColor(cell, Color.Green);
            section.Add(cell);

            cell = new TextCell {
                Text = "Blue", TextColor = Color.White
            };
            CellGloss.SetBackgroundColor(cell, Color.Blue);
            section.Add(cell);

            var stack = new StackLayout();

            if (Device.RuntimePlatform == Device.iOS)
            {
                stack.Children.Add(new Label {
                    Text = "Cell BackgroundColor values set in C#:", Margin = new Thickness(10)
                });
            }
            stack.Children.Add(new TableView
            {
                Intent        = TableIntent.Data,
                HeightRequest = DeviceExtensions.OnPlatform <double>(132, 190, 0),
                Root          = new TableRoot
                {
                    section
                }
            });

            Content = stack;
        }
        Cell[] CreateAccessoryTypeCells()
        {
            List <Cell> result = new List <Cell>();

            // Iterate through the enumeration's values, creating a new text cell for each entity
            var typeNames = Enum.GetNames(typeof(CellGlossAccessoryType));

            foreach (string typeName in typeNames)
            {
                Cell cell;
                if (typeName == nameof(CellGlossAccessoryType.EditIndicator))
                {
                    cell = new EntryCell();
                }
                else
                {
                    cell = new TextCell();
                }

                if (cell is EntryCell)
                {
                    var entryCell = cell as EntryCell;
                    entryCell.Label                   = typeName;
                    entryCell.Placeholder             = "Optional";
                    entryCell.HorizontalTextAlignment = TextAlignment.End;
                }
                else
                {
                    (cell as TextCell).Text = typeName;
                }

                // Assign our gloss properties
                var accType = (CellGlossAccessoryType)Enum.Parse(typeof(CellGlossAccessoryType), typeName);

                // You can use the standard static setter...
                CellGloss.SetAccessoryType(cell, accType);

                // ...or instantiate an instance of the Gloss properties you want to assign values to
                //	var gloss = new XFGloss.Views.Cell(cell);
                //	gloss.AccessoryType = accType;
                //	gloss.BackgroundColor = Color.Blue;
                //	gloss.TintColor = Color.Red;
                //	...

                result.Add(cell);
            }

            return(result.ToArray());
        }
Example #4
0
        SwitchCell CreateTintColorSwitchCell(string colorName, Color colorValue)
        {
            var result = new SwitchCell();

            result.Text = colorName;

            // Assign our gloss properties - You can use the standard static setter...
            CellGloss.SetTintColor(result, colorValue);

            // ...or instantiate an instance of the Gloss properties you want to assign values to
            //	var gloss = new XFGloss.Views.SwitchCell(result);
            //	gloss.BackgroundColor = Color.Blue;
            //	gloss.TintColor = Color.Red;
            //	...

            return(result);
        }
        private void PauseResumeClock(object sender, EventArgs e)
        {
            ShouldContinue = !ShouldContinue;

            if (ShouldContinue)
            {
                CellGloss.SetBackgroundColor(ElapsedTimeCell, Color.White);

                if (!IsRunning)
                {
                    IsRunning = true;

                    Device.StartTimer(TimeSpan.FromSeconds(1), this.RunTimer);
                }
            }
            else
            {
                CellGloss.SetBackgroundColor(ElapsedTimeCell, Color.LightGoldenrodYellow);
            }
        }
        TableSection buildTeamMembers()
        {
            var sect = new TableSection("Team Member");

            Members = new List <TeamMember>();

            foreach (var member in LocalRealmInstance.All <TeamMember>())
            {
                Members.Add(member);
            }

            foreach (var m in Members)
            {
                var tc = new TextCell
                {
                    Text   = m.Name,
                    Detail = m.Username
                };

                tc.Command = new Command(() =>
                {
                    if (SelectedTeamMemberCell != null)
                    {
                        CellGloss.SetBackgroundColor(SelectedTeamMemberCell, Color.White);
                    }

                    SelectedTeamMember     = m;
                    SelectedTeamMemberCell = tc;

                    CellGloss.SetBackgroundColor(tc, Color.LightGreen);
                });

                sect.Add(tc);
            }

            return(sect);
        }
        TextCell[] CreateBackgroundGradientCells()
        {
            List <TextCell> result = new List <TextCell>();

            Dictionary <string, Tuple <int, Color, Color> > Colors = new Dictionary <string, Tuple <int, Color, Color> >()
            {
                { "Red", new Tuple <int, Color, Color>(Gradient.RotationTopToBottom, Color.Red, Color.Maroon) },
                { "Green", new Tuple <int, Color, Color>(Gradient.RotationLeftToRight, Color.Lime, Color.Green) },
                { "Blue", new Tuple <int, Color, Color>(Gradient.RotationBottomToTop, Color.Blue, Color.Navy) }
            };

            // Iterate through the color values, creating a new text cell for each entity
            var colorNames = Colors.Keys;

            foreach (string colorName in colorNames)
            {
                var cell = new TextCell();
                cell.Text      = colorName;
                cell.TextColor = Color.White;

                // Assign our gloss properties - You can use the standard static setter...
                var cellInfo = Colors[colorName];
                CellGloss.SetBackgroundGradient(cell, new Gradient(cellInfo.Item1, cellInfo.Item2, cellInfo.Item3));

                // ...or instantiate an instance of the Gloss properties you want to assign values to
                //	var gloss = new XFGloss.Views.Cell(cell);
                //	gloss.AccessoryType = accType;
                //	gloss.BackgroundColor = Color.Blue;
                //	gloss.TintColor = Color.Red;
                //	...

                result.Add(cell);
            }

            // Add a multi-color gradient
            rotatingCell           = new TextCell();
            rotatingCell.Text      = "All Three";
            rotatingCell.TextColor = Color.White;

            // Manually construct a multi-color gradient at an angle of our choosing
            rotatingGradient = new Gradient()
            {
                Rotation = 135,
                Steps    = new GradientStepCollection()
                {
                    new GradientStep(Colors["Red"].Item2, 0),
                    new GradientStep(Colors["Red"].Item3, .25),
                    new GradientStep(Colors["Green"].Item2, .4),
                    new GradientStep(Colors["Green"].Item3, .6),
                    new GradientStep(Colors["Blue"].Item2, .75),
                    new GradientStep(Colors["Blue"].Item3, 1),
                }
            };

            // You can also initialize a multi-color gradient in code like this:
            //rotatingGradient = new Gradient(135); // 135 degree angle
            //rotatingGradient.AddStep(Colors["Red"].Item2, 0);
            //rotatingGradient.AddStep(Colors["Red"].Item3, .25);
            //rotatingGradient.AddStep(Colors["Green"].Item2, .4);
            //rotatingGradient.AddStep(Colors["Green"].Item3, .6);
            //rotatingGradient.AddStep(Colors["Blue"].Item2, .75);
            //rotatingGradient.AddStep(Colors["Blue"].Item3, 1);

            CellGloss.SetBackgroundGradient(rotatingCell, rotatingGradient);

            result.Add(rotatingCell);

            return(result.ToArray());
        }