コード例 #1
0
        private View CreateGridColumn(View cellView, string oppId, double widthRequest = 0)
        {
            var tgr = new TapGestureRecognizer();

            tgr.Tapped += ChapterId_Tapped;
            var bodyStackLayout = new OppStackLayout
            {
                Padding              = new Thickness(5, 5, 5, 5),
                BackgroundColor      = Color.White,
                Orientation          = StackOrientation.Horizontal,
                HorizontalOptions    = LayoutOptions.Fill,
                VerticalOptions      = LayoutOptions.Fill,
                MinimumHeightRequest = 30,
                OppId = oppId
            };

            if (widthRequest > 0)
            {
                bodyStackLayout.WidthRequest = widthRequest;
            }

            bodyStackLayout.Children.Add(cellView);
            bodyStackLayout.Children.Add(new Label
            {
                Text                 = ">",
                TextColor            = Color.FromHex("#333333"),
                HorizontalOptions    = LayoutOptions.End,
                MinimumHeightRequest = 30,
                FontSize             = 14
            });
            bodyStackLayout.GestureRecognizers.Add(tgr);
            return(bodyStackLayout);
        }
コード例 #2
0
        private View CreateGridColumn(View cellView, double widthRequest = 0)
        {
            var bodyStackLayout = new OppStackLayout
            {
                Padding              = new Thickness(5, 5, 5, 1),
                BackgroundColor      = Color.White,
                Orientation          = StackOrientation.Vertical,
                HorizontalOptions    = LayoutOptions.Fill,
                VerticalOptions      = LayoutOptions.Fill,
                MinimumHeightRequest = 30
            };

            if (widthRequest > 0)
            {
                bodyStackLayout.WidthRequest = widthRequest;
            }

            bodyStackLayout.Children.Add(cellView);
            return(bodyStackLayout);
        }
コード例 #3
0
        private void InitPage()
        {
            var listOppsView       = new List <IList <View> >();
            var listOppsViewColumn = new List <View>();

            var tgr = new TapGestureRecognizer();

            tgr.Tapped += SubTracker_Tapped;

            listOppsViewColumn.AddRange(Opps.Select(opp =>
            {
                var stackLayout = new OppStackLayout
                {
                    GestureRecognizers = { tgr },
                    OppId             = opp.ReadingType,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    BackgroundColor   = _blueColor,
                    Padding           = new Thickness(0, 5, 0, 5),
                    Children          =
                    {
                        new Label
                        {
                            FontSize          = 20,
                            TextColor         = Color.White,
                            Text              = "Log New",
                            HorizontalOptions = LayoutOptions.CenterAndExpand,
                            VerticalOptions   = LayoutOptions.CenterAndExpand,
                        }
                    }
                };
                return(new StackLayout
                {
                    Padding = new Thickness(0, 20, 0, 0),
                    BackgroundColor = Color.White,
                    Children =
                    {
                        new StackLayout
                        {
                            Padding = new Thickness(1, 1, 1, 1),
                            BackgroundColor = Color.FromHex("#aaaaaa"),
                            Spacing = 1,
                            Children =
                            {
                                new StackLayout
                                {
                                    Padding = new Thickness(0, 20, 0, 20),
                                    BackgroundColor = Color.White,
                                    VerticalOptions = LayoutOptions.FillAndExpand,
                                    HorizontalOptions = LayoutOptions.FillAndExpand,
                                    Children =
                                    {
                                        new Label
                                        {
                                            FontSize = 24,
                                            TextColor = _blueColor,
                                            Text = opp.ReadingName,
                                            VerticalOptions = LayoutOptions.CenterAndExpand,
                                            HorizontalOptions = LayoutOptions.CenterAndExpand,
                                        }
                                    }
                                },
                                new StackLayout
                                {
                                    Padding = new Thickness(0, 10, 0, 10),
                                    BackgroundColor = Color.White,
                                    VerticalOptions = LayoutOptions.FillAndExpand,
                                    HorizontalOptions = LayoutOptions.FillAndExpand,
                                    Children =
                                    {
                                        new Label
                                        {
                                            FontSize = 18,
                                            TextColor = Color.FromHex("#333333"),
                                            Text = "Last Reading",
                                            HorizontalOptions = LayoutOptions.CenterAndExpand,
                                            VerticalOptions = LayoutOptions.CenterAndExpand
                                        },
                                        new Label
                                        {
                                            FontSize = 18,
                                            TextColor = Color.FromHex("#333333"),
                                            HorizontalOptions = LayoutOptions.CenterAndExpand,
                                            VerticalOptions = LayoutOptions.CenterAndExpand,
                                            Text = opp.ReadingDate
                                        },
                                        new Label
                                        {
                                            FontSize = 15,
                                            TextColor = Color.FromHex("#333333"),
                                            HorizontalOptions = LayoutOptions.CenterAndExpand,
                                            VerticalOptions = LayoutOptions.CenterAndExpand,
                                            Text = opp.Source
                                        },
                                        new StackLayout
                                        {
                                            Orientation = StackOrientation.Horizontal,
                                            VerticalOptions = LayoutOptions.Center,
                                            HorizontalOptions = LayoutOptions.Center,
                                            Children =
                                            {
                                                new Label
                                                {
                                                    FontSize = 30,
                                                    TextColor = _blueColor,
                                                    Text = opp.Value1,
                                                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                                                    VerticalOptions = LayoutOptions.CenterAndExpand,
                                                },
                                                new Label
                                                {
                                                    FontSize = opp.Unit == "" ? 30 : 24,
                                                    TextColor =
                                                        opp.Unit == "" ? _blueColor : Color.FromHex("#999999"),
                                                    Text = opp.Unit == "" ? $"/ {opp.Value2}" : opp.Unit,
                                                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                                                    VerticalOptions = LayoutOptions.CenterAndExpand,
                                                }
                                            }
                                        },
                                        new StackLayout
                                        {
                                            Padding = new Thickness(20, 0, 20, 0),
                                            Children =
                                            {
                                                new StackLayout
                                                {
                                                    BackgroundColor = Color.FromHex("#CCCCCC"),
                                                    Padding = new Thickness(1, 1, 1, 1),
                                                    Children =
                                                    {
                                                        stackLayout
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                });
            }));

            listOppsView.Add(new List <View>(listOppsViewColumn));
            var eventsGrid = new CustomGrid <View>(listOppsView);

            TrackersLayoutHealth.Children.Add(eventsGrid.GetGrid);
            listOppsView.Clear();
            listOppsViewColumn.Clear();
        }
コード例 #4
0
        private void InitOpportunityPage()
        {
            if (Response.Incentive != null)
            {
                IncentiveLayout.IsVisible    = true;
                IncentiveIntroView.IsVisible = true;
                IncentiveIntroView.Source    = new HtmlWebViewSource {
                    Html = Response.IncentiveIntro
                };
                IncentiveTableLayout.IsVisible = true;
                ContentIncentiveWeb.IsVisible  = true;

                opps = new ObservableCollection <OpportunitiesModel>();
                foreach (var incentive in Response.Incentive)
                {
                    opps.Add(new OpportunitiesModel
                    {
                        Title         = incentive.OpportunityName,
                        IsComplete    = int.Parse(incentive.Awarded) == 0,
                        OpportunityId = incentive.OpportunityId
                    });
                }

                #region New Table view

                var listOppsView       = new List <IList <View> >();
                var listOppsViewColumn = new List <View>();


                var tgr = new TapGestureRecognizer();
                tgr.Tapped += InsTgr_Tapped;

                #region AddColumn

                var gridForFirstElement = ViewForFirstRow(tgr, opps.First().OpportunityId, opps.First().Title);
                listOppsViewColumn.Add(CreateGridColumn(gridForFirstElement, opps.First().IsComplete));

                #endregion
                var tablesRows = opps.Except(opps.Take(1)).Select(opp =>
                {
                    var oppStackLayout = new OppStackLayout
                    {
                        GestureRecognizers = { tgr },
                        OppId = opp.OpportunityId,
                    };
                    var layout = new OppStackLayout
                    {
                        GestureRecognizers = { tgr },
                        OppId             = opp.OpportunityId,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Padding           = new Thickness(0, 13, 0, 13),
                        VerticalOptions   = LayoutOptions.CenterAndExpand,
                        Children          =
                        {
                            new Label
                            {
                                Text     = opp.Title,
                                Style    = (Style)Resources["labelStyle"],
                                FontSize = 13
                            }
                        }
                    };
                    var item = new Grid
                    {
                        BackgroundColor   = Color.White,
                        ColumnSpacing     = 0,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                        ColumnDefinitions =
                        {
                            new ColumnDefinition
                            {
                                Width = new GridLength(7, GridUnitType.Star)
                            },
                            new ColumnDefinition
                            {
                                Width = new GridLength(1, GridUnitType.Star)
                            }
                        },
                        Children =
                        {
                            { oppStackLayout, 1, 0 },
                            { layout,         0, 0 }
                        }
                    };
                    var stackLayout = new StackLayout
                    {
                        Padding           = new Thickness(0, 1, 0, 0),
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        BackgroundColor   = Color.FromHex("#cfced2"),
                        Children          = { item }
                    };
                    return(CreateGridColumn(stackLayout, opp.IsComplete));
                });

                listOppsViewColumn.AddRange(tablesRows);

                listOppsView.Add(new List <View>(listOppsViewColumn));
                IncentiveTableLayout.Children.Clear();
                var eventsGrid = new CustomGrid <View>(listOppsView, 0);
                IncentiveTableLayout.Children.Add(eventsGrid.GetGrid);
                #endregion
                AchievedLabel.IsVisible           = PercentAwardedLabel.IsVisible = Response.PercentAwarded != null;
                PercentAwardedLabel.Text          = $"{Response.PercentAwarded}%";
                AchievedeLayout.IsVisible         = true;
                AchievedeLayoutSubStack.IsVisible = true;
            }

            if (Response.Reward != null)
            {
                RewardTableLayout.IsVisible = true;
                RewardIntroView.IsVisible   = true;
                RewardIntroView.Source      = new HtmlWebViewSource {
                    Html = Response.RewardIntro
                };

                opps = new ObservableCollection <OpportunitiesModel>();
                foreach (var reward in Response.Reward)
                {
                    opps.Add(new OpportunitiesModel
                    {
                        Title         = reward.OpportunityName,
                        IsComplete    = int.Parse(reward.Awarded) == 0,
                        OpportunityId = reward.OpportunityId
                    });
                }

                #region OppReward table view

                var listOppsView       = new List <IList <View> >();
                var listOppsViewColumn = new List <View>();

                var tgr = new TapGestureRecognizer();
                tgr.Tapped += RewardTgr_Tapped;

                var gridForFirstElement = ViewForFirstRow(tgr, opps.First().OpportunityId, opps.First().Title);
                listOppsViewColumn.Add(CreateGridColumn(gridForFirstElement, opps.First().IsComplete));

                var tablesRows = opps.Except(opps.Take(1)).Select(opp =>
                {
                    var oppStackLayout = new OppStackLayout
                    {
                        GestureRecognizers = { tgr },
                        OppId = opp.OpportunityId,
                    };
                    var layout = new OppStackLayout
                    {
                        GestureRecognizers = { tgr },
                        OppId             = opp.OpportunityId,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Padding           = new Thickness(0, 13, 0, 13),
                        VerticalOptions   = LayoutOptions.CenterAndExpand,
                        Children          =
                        {
                            new Label
                            {
                                Text     = opp.Title,
                                Style    = (Style)Resources["labelStyle"],
                                FontSize = 13
                            }
                        }
                    };
                    var item = new Grid
                    {
                        BackgroundColor   = Color.White,
                        ColumnSpacing     = 0,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                        ColumnDefinitions =
                        {
                            new ColumnDefinition
                            {
                                Width = new GridLength(7, GridUnitType.Star)
                            },
                            new ColumnDefinition
                            {
                                Width = new GridLength(1, GridUnitType.Star)
                            }
                        },
                        Children =
                        {
                            { oppStackLayout, 1, 0 },
                            { layout,         0, 0 }
                        }
                    };
                    var stackLayout = new StackLayout
                    {
                        Padding           = new Thickness(0, 1, 0, 0),
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        BackgroundColor   = Color.FromHex("#cfced2"),
                        Children          = { item }
                    };
                    return(CreateGridColumn(stackLayout, opp.IsComplete));
                });

                listOppsViewColumn.AddRange(tablesRows);

                listOppsView.Add(new List <View>(listOppsViewColumn));
                var eventsGrid = new CustomGrid <View>(listOppsView, 0);
                RewardTableLayout.Children.Clear();
                RewardTableLayout.Children.Add(eventsGrid.GetGrid);
                #endregion

                AwardedLayout.IsVisible        = true;
                CurrencyAwardedLabel.IsVisible = true;
                CurrencyAwardedLabel.Text      = Response.CurrencyAwarded;
            }
            else
            {
                RewardTableLayout.IsVisible = false;
                RewardIntroView.IsVisible   = false;
            }
            if (Response.ContactInfo != null)
            {
                AdditionalInfoView.IsVisible = true;
                AdditionalInfoView.Source    = new HtmlWebViewSource {
                    Html = Response.ContactInfo
                };
            }

            MainStackLayout.Opacity = 1;
        }