Example #1
0
        public MainPage()
        {
            InitializeComponent();
            Cities cities = null;
            Task   t      = Task.Run(async() =>
            {
                CustomWebClient webClient = new CustomWebClient();
                cities = await webClient.GetCitiesData();
            });

            t.Wait();
            listView.ItemsSource = cities;
            ImageCircle.Forms.Plugin.Abstractions.CircleImage myImage = null;
        }
Example #2
0
        private void AddCommentToPage(Comment comment)
        {
            noCommentLabel.IsVisible = false;
            UserDataAccess userDataAccess   = new UserDataAccess();
            StackLayout    stackLayoutUpper = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal
            };
            User user = userDataAccess.GetUserByEmail(comment.UserEmail);

            if (user.UserPhoto == null)
            {
                user.UserPhoto = "@drawable/defaultuser";
            }
            ImageCircle.Forms.Plugin.Abstractions.CircleImage image = new ImageCircle.Forms.Plugin.Abstractions.CircleImage {
                Source        = user.UserPhoto.Replace("Uri: ", ""),
                HeightRequest = 20
            };
            Label userLabel = new Label {
                Text           = user.UserName,
                FontAttributes = FontAttributes.Bold,
                FontSize       = 17
            };

            stackLayoutUpper.Children.Add(image);
            stackLayoutUpper.Children.Add(userLabel);

            StackLayout stackLayoutLower = new StackLayout();
            Label       commentLabel     = new Label()
            {
                Text     = comment.CommentOfBook,
                FontSize = 13
            };

            stackLayoutLower.Children.Add(commentLabel);

            StackLayout stackLayoutOuter = new StackLayout();

            stackLayoutOuter.Children.Add(stackLayoutUpper);
            stackLayoutOuter.Children.Add(stackLayoutLower);
            Frame frame = new Frame {
                Content      = stackLayoutOuter,
                CornerRadius = 20,
                BorderColor  = Color.FromHex("#6d6d6d")
            };

            CommentStackLayout.Children.Add(frame);
        }
        public async void LoadProducts()
        {
            stkItens.Children.Clear();
            foreach (CategoryGroup itemGroup in _listCategoryGroup)
            {
                float groupFontSize = 18;
                if (Device.Idiom == TargetIdiom.Tablet)
                {
                    groupFontSize = 24;
                }

                Label lblgroup = new Label
                {
                    FontSize                = groupFontSize,
                    FontAttributes          = FontAttributes.Bold,
                    Margin                  = new Thickness(0, 5, 0, 15),
                    TextColor               = Color.FromHex("#212121"),
                    HorizontalTextAlignment = TextAlignment.Start,
                    Text = itemGroup.Name
                };

                stkItens.Children.Add(lblgroup);

                foreach (Product item in itemGroup.Products)
                {
                    Grid grid = new Grid
                    {
                        ColumnDefinitions =
                        {
                            new ColumnDefinition {
                                Width = new GridLength(1, GridUnitType.Auto)
                            },
                            new ColumnDefinition {
                                Width = new GridLength(1, GridUnitType.Star)
                            },
                            new ColumnDefinition {
                                Width = new GridLength(1, GridUnitType.Auto)
                            }
                        }
                    };


                    StackLayout stk = new StackLayout
                    {
                        Margin  = new Thickness(0, 0, 0, 10),
                        Spacing = 0
                    };

                    TapGestureRecognizer detailsRecognizer = new TapGestureRecognizer();
                    detailsRecognizer.Tapped += ProductGesture_Tapped;
                    grid.GestureRecognizers.Add(detailsRecognizer);
                    grid.StyleId = item.Id;

                    StackLayout stkImages = new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Margin            = new Thickness(0, 0, 0, 10),
                        Spacing           = 0
                    };

                    StackLayout stkprice = new StackLayout
                    {
                        Margin  = new Thickness(0, 0, 0, 10),
                        Spacing = 0
                    };

                    ImageCircle.Forms.Plugin.Abstractions.CircleImage image = new ImageCircle.Forms.Plugin.Abstractions.CircleImage
                    {
                        HeightRequest     = 50,
                        WidthRequest      = 50,
                        FillColor         = Color.FromHex("#ccc"),
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions   = LayoutOptions.Center,
                        Aspect            = Aspect.AspectFill,
                        Source            = item.ImageUri,
                        StyleId           = item.Id
                    };


                    float nameFontSize    = 12;
                    float commentFontSize = 10;
                    float priceFontSize   = 12;

                    if (Device.Idiom == TargetIdiom.Tablet)
                    {
                        nameFontSize    = 18;
                        commentFontSize = 16;
                        priceFontSize   = 18;
                    }

                    Label lblName = new Label
                    {
                        FontSize  = nameFontSize,
                        TextColor = Color.FromHex("#212121"),
                        HorizontalTextAlignment = TextAlignment.Start,
                        Text = item.Name
                    };

                    Label lblComentario = new Label
                    {
                        FontSize  = commentFontSize,
                        TextColor = Color.Silver,
                        HorizontalTextAlignment = TextAlignment.Start,
                        Text = item.Description
                    };

                    Label lblPrice = new Label
                    {
                        FontSize  = priceFontSize,
                        TextColor = Color.Green,
                        HorizontalTextAlignment = TextAlignment.Start
                    };
                    //lblPrice.Text = String.Format(new System.Globalization.CultureInfo("en-US"), "{0:C}", item.Price);

                    if (item.ShowElementBySegment)
                    {
                        CultureInfo cult = _company.CurrencyType.ToCultureInfo();
                        lblPrice.Text      = string.Format(cult, "{0:C}", item.Price);
                        lblPrice.IsVisible = true;
                    }
                    else
                    {
                        lblPrice.IsVisible = false;
                    }

                    Image imgStar = new Image
                    {
                        WidthRequest = 16,
                        Source       = item.ProductStarImage
                    };

                    Image imgFavorite = new Image
                    {
                        WidthRequest = 16,
                        Source       = "ic_heart_list"
                    };

                    BoxView box = new BoxView
                    {
                        HeightRequest = 1,
                        WidthRequest  = 500,
                        Color         = Color.FromHex("#ccc")
                    };


                    if (item.IsFavorited)
                    {
                        stkImages.Children.Add(imgFavorite);
                    }

                    //stkImages.Children.Add(imgStar);
                    stkprice.Children.Add(lblPrice);
                    stkprice.Children.Add(stkImages);

                    stk.Children.Add(lblName);
                    stk.Children.Add(lblComentario);

                    if (!string.IsNullOrEmpty(item.ImageUri))
                    {
                        grid.Children.Add(image, 0, 0);
                    }

                    grid.Children.Add(stk, 1, 0);
                    grid.Children.Add(stkprice, 2, 0);

                    stkItens.Children.Add(grid);
                    stkItens.Children.Add(box);
                }
            }

            ShowLoading(false);
        }
        public void LoadLocations(List <Location> list)
        {
            stkLocations.IsVisible = true;
            stkCk.IsVisible        = false;

            foreach (var item in list)
            {
                var grid = new Grid
                {
                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Auto)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Auto)
                        }
                    }
                };


                StackLayout stk = new StackLayout();
                stk.Margin      = new Thickness(0, 0, 0, 10);
                stk.Orientation = StackOrientation.Horizontal;
                stk.Spacing     = 0;



                ImageCircle.Forms.Plugin.Abstractions.CircleImage image = new ImageCircle.Forms.Plugin.Abstractions.CircleImage();
                image.HeightRequest     = 26;
                image.WidthRequest      = 26;
                image.FillColor         = Color.FromHex("#ccc");
                image.HorizontalOptions = LayoutOptions.Center;
                image.VerticalOptions   = LayoutOptions.Center;
                image.Aspect            = Aspect.AspectFill;
                image.Source            = item.ImageUri;
                image.StyleId           = item.Id;

                Label lblName = new Label();
                lblName.FontSize  = 12;
                lblName.Margin    = new Thickness(10, 0, 0, 0);
                lblName.TextColor = Color.FromHex("#212121");
                lblName.HorizontalTextAlignment = TextAlignment.Start;
                lblName.VerticalTextAlignment   = TextAlignment.Center;
                lblName.Text = item.Name;

                stk.Children.Add(image);
                stk.Children.Add(lblName);



                Image imgCk = new Image();
                imgCk.WidthRequest = 28;
                imgCk.Source       = "ic_detail_checkin";


                grid.Children.Add(stk, 0, 0);
                grid.Children.Add(imgCk, 2, 0);

                var detailsRecognizer = new TapGestureRecognizer();
                detailsRecognizer.Tapped += OnCkGestureTapped_Tapped;
                grid.GestureRecognizers.Add(detailsRecognizer);
                grid.StyleId = item.Id;


                stkLocations.Children.Add(grid);
            }
        }
        public async void LoadOrdersByCheckinId()
        {
            OrderService Orderservice = new OrderService();

            try
            {
                var result = await Orderservice.GetCheckinsSubsByCheckinId(_checkin.Id);

                _listSubCheckin       = JsonConvert.DeserializeObject <List <CheckinSub> >(result);
                listView.IsRefreshing = false;
                stkLocations.Children.Clear();
                stkLocations.IsVisible  = true;
                stkTipsAndTax.IsVisible = false;

                foreach (var item in _listSubCheckin.OrderByDescending(m => m.CreatedAt).ToList())
                {
                    var grid = new Grid
                    {
                        ColumnDefinitions =
                        {
                            new ColumnDefinition {
                                Width = new GridLength(2, GridUnitType.Star)
                            },
                            new ColumnDefinition {
                                Width = new GridLength(6, GridUnitType.Star)
                            },
                            new ColumnDefinition {
                                Width = new GridLength(2, GridUnitType.Star)
                            }
                        }
                    };

                    StackLayout stk = new StackLayout();
                    stk.Margin      = new Thickness(0, 0, 0, 10);
                    stk.Orientation = StackOrientation.Vertical;
                    stk.Spacing     = 2;
                    stk.StyleId     = item.Id;

                    ImageCircle.Forms.Plugin.Abstractions.CircleImage image =
                        new ImageCircle.Forms.Plugin.Abstractions.CircleImage();
                    image.HeightRequest     = 40;
                    image.WidthRequest      = 40;
                    image.FillColor         = Color.FromHex("#ccc");
                    image.HorizontalOptions = LayoutOptions.Center;
                    image.VerticalOptions   = LayoutOptions.Center;
                    image.Aspect            = Aspect.AspectFill;
                    image.Source            = item.Location.ImageUri;
                    image.StyleId           = item.Id;

                    Label lblName = new Label();
                    lblName.FontSize  = 14;
                    lblName.TextColor = Color.FromHex("#212121");
                    lblName.HorizontalTextAlignment = TextAlignment.Start;
                    lblName.VerticalTextAlignment   = TextAlignment.Center;
                    lblName.Text = $"{item.LocationNameWithValue}";

                    Label lblStatus = new Label();
                    lblStatus.FontSize = 12;
                    lblStatus.Text     = item.CheckinSubStatusStrWithValue;

                    lblStatus.IsVisible = true;
                    switch (item.CheckinSubStatus)
                    {
                    case CheckinSubStatus.Pending:
                        lblStatus.TextColor = Color.Red;
                        break;

                    case CheckinSubStatus.Active:
                        if (item.Paid && item.PaidInCard == 0)
                        {
                            lblStatus.TextColor = Color.Orange;
                        }
                        else if (item.Paid && item.PaidInCard != 0)
                        {
                            lblStatus.TextColor = Color.Green;
                        }
                        else if (item.PaymentMethod == PaymentMethod.Money && !item.PaidFromAdmin)
                        {
                            lblStatus.TextColor = Color.Orange;
                        }
                        else if (item.PaymentMethod == PaymentMethod.Transferred && !item.PaidFromAdmin)
                        {
                            lblStatus.TextColor = Color.Orange;
                        }
                        else
                        {
                            lblStatus.TextColor = Color.Blue;
                        }
                        break;

                    case CheckinSubStatus.Closed:
                        if (item.TotalSpent != item.TotalPaid)
                        {
                            lblStatus.TextColor = Color.Orange;
                        }
                        else
                        {
                            lblStatus.TextColor = Color.Green;
                        }
                        break;

                    case CheckinSubStatus.RequestedCheckout:
                        lblStatus.TextColor = Color.Black;
                        break;

                    case CheckinSubStatus.Checkout:
                        lblStatus.TextColor = Color.Red;
                        break;

                    case CheckinSubStatus.Denied:
                        lblStatus.TextColor = Color.Red;
                        break;
                    }

                    Label lblPaidIn = new Label();
                    lblPaidIn.FontSize = 12;

                    lblPaidIn.TextColor = Color.Gray;
                    lblPaidIn.IsVisible = false;
                    if (item.CheckinSubStatus == Enums.CheckinSubStatus.RequestedCheckout && !item.Paid)
                    {
                        lblPaidIn.IsVisible = true;

                        if (item.PaymentMethod == PaymentMethod.Card)
                        {
                            lblPaidIn.Text = AppResource.lblCardObs;
                        }
                        else if (item.PaymentMethod == PaymentMethod.Money)
                        {
                            lblPaidIn.Text = AppResource.lblMoneyObs;
                        }
                        else
                        {
                            lblPaidIn.IsVisible = false;
                        }
                    }

                    Label lblPaid = new Label();
                    lblPaid.FontSize  = 12;
                    lblPaid.Text      = AppResource.lblPaid;
                    lblPaid.TextColor = Color.Green;

                    Label lblPaidLater = new Label();
                    lblPaidLater.FontSize = 12;

                    ////ESSA MUDANÇA FOI FEITA NO DIA QUE O ALAIN TAVA EM CURITIBA ANTES DE IR EMBORA, PEDIMOS BERA E BURGUER
                    ////ELE PEDIU PARA CASO PEÇA FECHAR A CONTA DO CHECKIN COM LOCATION ATIVA, TEM Q APARECER PENDENTE PAGAMENTO
                    stk.Children.Add(lblName);
                    stk.Children.Add(lblStatus);
                    stk.Children.Add(lblPaidIn);

                    if (!item.Paid && item.CheckinSubStatus == Enums.CheckinSubStatus.Closed || item.CheckinSubStatus == Enums.CheckinSubStatus.RequestedCheckout)
                    {
                        stk.Children.Add(lblPaidLater);
                    }

                    var tpReco = new TapGestureRecognizer();
                    tpReco.Tapped += OnLocationTapped;
                    stk.GestureRecognizers.Add(tpReco);

                    Label lblValuePaid = new Label();

                    lblValuePaid.TextColor = item.CheckinSubStatusColorValueInColor;
                    lblValuePaid.Text      = item.CheckinSubStatusStrWithValueV2;
                    lblValuePaid.FontSize  = 12;

                    grid.Padding       = new Thickness(10, 6, 10, 0);
                    grid.ColumnSpacing = 8;
                    grid.Children.Add(image, 0, 0);
                    grid.Children.Add(stk, 1, 0);
                    grid.Children.Add(lblValuePaid, 2, 0);

                    stkLocations.Children.Add(grid);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
        }
        /**
         * summary CreateNewGridType01 creates the Grid display
         * param name="ReminderType" is the type of reminder
         * param name="ImageAddress" is the address of the image file
         * param name="Content" is the message content
         * param name="Time" is the time the message was delivered
         * returns return the new Grid
         * **/
        public static StackLayout Notification01(String ImageAddress, String Content, String Time, NotificationType UserNotificationType, int ID)
        {
            String ReminderType = Enum.GetName(typeof(NotificationType), UserNotificationType);

            Grid ParentGrid = new Grid
            {
                HeightRequest = 75
            };

            /** grid1 should be tappable and should send some info to the chatpage**/
            TapGestureRecognizer ParentGridTapped = new TapGestureRecognizer();

            ParentGridTapped.Tapped +=
                delegate
            {
                switch (UserNotificationType)
                {
                case NotificationType.Chat:
                    App.Current.MainPage.Navigation.PushAsync(new ChatPage(ID, Utilities.IsMedic));
                    break;

                case NotificationType.Reminder:
                    //send to reminder here
                    break;

                case NotificationType.Appointment:
                    App.Current.MainPage.Navigation.PushAsync(new ChatPage(ID, Utilities.IsMedic));
                    break;
                }
                ;
            };

            ParentGrid.GestureRecognizers.Add(ParentGridTapped);

            ColumnDefinition ColDef0 = new ColumnDefinition
            {
                Width = new GridLength(0.5, GridUnitType.Star)
            };

            ColumnDefinition ColDef1 = new ColumnDefinition
            {
                Width = new GridLength(1.5, GridUnitType.Star)
            };

            ParentGrid.ColumnDefinitions.Add(ColDef0);
            ParentGrid.ColumnDefinitions.Add(ColDef1);

            /** Gird0 holds the image and the online offline status **/
            Grid Grid0 = new Grid();


            /** Set the child grid to appear in grid view with index 0 **/
            Grid.SetColumn(Grid0, 0);

            UserImage = new ImageCircle.Forms.Plugin.Abstractions.CircleImage
            {
                Source = ImageSource.FromUri(new Uri("https://www.clipartmax.com/png/middle/258-2582267_circled-user-male-skin-type-1-2-icon-male-user-icon.png")),
                Aspect = Aspect.AspectFit
            };

            Grid0.Children.Add(UserImage);

            /**Grid1 holds the name, time etc**/
            Grid Grid1 = new Grid();


            Grid.SetColumn(Grid1, 1);

            /** Grid1 needs 2 rowdefinintions to separate
             * 1 for the toplevel and the other for the lower level
             * **/
            RowDefinition RowDef0 = new RowDefinition
            {
                Height = new GridLength(1, GridUnitType.Star)
            };

            RowDefinition RowDef1 = new RowDefinition
            {
                Height = new GridLength(1, GridUnitType.Star)
            };

            Grid1.RowDefinitions.Add(RowDef0);
            Grid1.RowDefinitions.Add(RowDef1);

            /** inside GRID1 , the top layer GRID is used by the name and time
             * while LowerLevel holds the message brief content
             * **/
            Grid TopLevel = new Grid();

            Grid.SetRow(TopLevel, 0);

            /** the top level is dived into two sections the name and the time
             * so we need two columndefinitions
             * **/

            TopLevel.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            TopLevel.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            Label ReminderTypeLabel = new Label
            {
                Text                    = ReminderType,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor               = (Color)App.Current.Resources["_MedAppLightBlue"],
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand
            };

            Grid.SetColumn(ReminderTypeLabel, 0);

            Label TimeLabel = new Label
            {
                Text     = Time,
                FontSize = 10,
                HorizontalTextAlignment = TextAlignment.End,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand
            };

            Grid.SetColumn(TimeLabel, 1);

            TopLevel.Children.Add(ReminderTypeLabel);
            TopLevel.Children.Add(TimeLabel);

            /**thw lowerlevel is made of just a label of content**/

            Label ContentLabel = new Label
            {
                Text     = Content,
                FontSize = 16
            };

            Grid.SetRow(ContentLabel, 1);

            Grid1.Children.Add(TopLevel);
            Grid1.Children.Add(ContentLabel);


            ParentGrid.Children.Add(Grid0);
            ParentGrid.Children.Add(Grid1);

            StackLayout AllStack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Spacing     = 0
            };

            AllStack.Children.Add(ParentGrid);
            AllStack.Children.Add(new BoxView {
                Style = App.Current.Resources["_BoxViewBottomLine"] as Style, BackgroundColor = Color.White
            });

            return(AllStack);
        }
        public async void LoadLocations(List <Location> list)
        {
            stkAct.IsVisible       = true;
            stkLocations.IsVisible = true;
            stkCk.IsVisible        = false;
            stkLocations.Children.Clear();
            foreach (var item in list)
            {
                var grid = new Grid
                {
                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Auto)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Auto)
                        }
                    }
                };


                StackLayout stk = new StackLayout();
                stk.Margin      = new Thickness(0, 0, 0, 10);
                stk.Orientation = StackOrientation.Horizontal;
                stk.Spacing     = 0;



                ImageCircle.Forms.Plugin.Abstractions.CircleImage image = new ImageCircle.Forms.Plugin.Abstractions.CircleImage();
                image.HeightRequest     = 26;
                image.WidthRequest      = 26;
                image.FillColor         = Color.FromHex("#ccc");
                image.HorizontalOptions = LayoutOptions.Center;
                image.VerticalOptions   = LayoutOptions.Center;
                image.Aspect            = Aspect.AspectFill;
                image.Source            = item.ImageUri;
                image.StyleId           = item.Id;

                Label lblName = new Label();
                lblName.FontSize  = 12;
                lblName.Margin    = new Thickness(10, 0, 0, 0);
                lblName.TextColor = Color.FromHex("#212121");
                lblName.HorizontalTextAlignment = TextAlignment.Start;
                lblName.VerticalTextAlignment   = TextAlignment.Center;
                lblName.Text = item.Name;

                stk.Children.Add(image);
                stk.Children.Add(lblName);



                Image imgCk = new Image();
                imgCk.WidthRequest = 28;


                if (item.CheckinAction == CheckinAction.EnableLocationCheckin || item.CheckinAction == CheckinAction.HasAnotherLocationPending)
                {
                    imgCk.Source = "ic_detail_checkin";
                    var detailsRecognizer = new TapGestureRecognizer();
                    detailsRecognizer.Tapped += OnCkGestureTapped_Tapped;
                    grid.GestureRecognizers.Add(detailsRecognizer);
                    grid.StyleId = item.Id;
                }
                //if (item.CheckinAction == CheckinAction.HasAnotherLocationPending)
                //{
                //    imgCk.Source = "ic_detail_checkin";
                //    var detailsRecognizer = new TapGestureRecognizer();
                //    detailsRecognizer.Tapped += onMessageTapped_Tapped;
                //    grid.GestureRecognizers.Add(detailsRecognizer);
                //}
                if (item.CheckinAction == CheckinAction.CheckoutLocationCheckin)
                {
                    imgCk.Source = "ic_detail_checkout";
                    //var detailsRecognizer = new TapGestureRecognizer();
                    //detailsRecognizer.Tapped += OnCancelTapped;
                    //grid.GestureRecognizers.Add(detailsRecognizer);
                    grid.StyleId = item.Id;
                }
                //posso fazer checkin na empresa
                //if (item.CheckinAction == CheckinAction.EnableLocationCheckin)
                //{
                //    imgCk.Source = "ic_detail_checkin";
                //    var detailsRecognizer = new TapGestureRecognizer();
                //    detailsRecognizer.Tapped += OnCkGestureTapped_Tapped;
                //    grid.GestureRecognizers.Add(detailsRecognizer);
                //    grid.StyleId = item.Id;
                //}
                //if (item.CheckinAction == CheckinAction.HasAnotherLocationPending)
                //{
                //    imgCk.Source = "ic_detail_checkin";
                //    var detailsRecognizer = new TapGestureRecognizer();
                //    detailsRecognizer.Tapped += onMessageTapped_Tapped;
                //    grid.GestureRecognizers.Add(detailsRecognizer);
                //}
                //if (item.CheckinAction == CheckinAction.CheckoutLocationCheckin)
                //{
                //    imgCk.Source = "ic_detail_checkout";
                //    var detailsRecognizer = new TapGestureRecognizer();
                //    detailsRecognizer.Tapped += OnCancelTapped;
                //    grid.GestureRecognizers.Add(detailsRecognizer);
                //    grid.StyleId = item.Id;

                //}



                grid.Children.Add(stk, 0, 0);
                grid.Children.Add(imgCk, 2, 0);

                stkLocations.Children.Add(grid);
            }

            stkAct.IsVisible   = false;
            stkItens.IsVisible = true;
            await Task.Delay(500);

            Acr.UserDialogs.UserDialogs.Instance.HideLoading();
        }
Example #8
0
        /**
         * summary CreateNewGridType01 creates the Grid display
         * param name="SenderName" is the user's name
         * param name="ImageAddress" is the address of the image file
         * param name="Content" is the message content
         * param name="Time" is the time the message was delivered
         * returns return the new Grid
         * **/


        public static StackLayout CreateNewStackType01(String SenderName, String ImageAddress, String Content, String Time, ContentPage con, int ReceiversID, int NewMessageCount, int MedicID)
        {
            Grid ParentGrid = new Grid
            {
                HeightRequest = 75
            };



            ColumnDefinition ColDef0 = new ColumnDefinition
            {
                Width = new GridLength(0.3, GridUnitType.Star)
            };

            ColumnDefinition ColDef1 = new ColumnDefinition
            {
                Width = new GridLength(1.7, GridUnitType.Star)
            };

            ParentGrid.ColumnDefinitions.Add(ColDef0);
            ParentGrid.ColumnDefinitions.Add(ColDef1);


            TapGestureRecognizer ParentGridTapped = new TapGestureRecognizer();

            ParentGridTapped.Tapped += delegate
            {
                if (((AbsoluteLayout)con.FindByName("_UserPopUpGrid")).IsVisible)
                {
                    ((AbsoluteLayout)con.FindByName("_UserPopUpGrid")).IsVisible = false;
                }
            };

            ParentGrid.GestureRecognizers.Add(ParentGridTapped);

            /** Gird0 holds the image and the online offline status **/
            Grid Grid0 = new Grid();

            /** grid1 should be tappable and should send some info to the chatpage**/
            TapGestureRecognizer Grid0Tapped = new TapGestureRecognizer();

            Grid0Tapped.Tapped += delegate
            {
                ((AbsoluteLayout)con.FindByName("_UserPopUpGrid")).IsVisible = true;
                //((AbsoluteLayout)con.FindByName("_UserPopUpGrid")).StyleId = ReceiversID.ToString();
                //((Image)con.FindByName("_PopUpUserImage")).Source = (Source == null) ? Utilities.Source(ImageAddress,typeof(ListAllChatTemplate)): Source;
                ((Image)con.FindByName("_PopUpUserImage")).Source = UserImage.Source;

                /** UserInfoArray holds the information which would be tagged to the control **/
                var UserInfoArray = new Dictionary <String, object>
                {
                    { "ReceiversID", ReceiversID },
                    { "Name", SenderName },
                    { "Image", UserImage.Source },
                    { "MedicID", MedicID }
                };

                ControlTagger <Object> .SetTag(((Image)con.FindByName("_PopUpUserImage")), UserInfoArray);

                //App.Current.MainPage.Navigation.PushAsync(new ChatPage());
            };

            Grid0.GestureRecognizers.Add(Grid0Tapped);
            /** Set the child grid to appear in grid view with index 0 **/
            Grid.SetColumn(Grid0, 0);

            UserImage = new ImageCircle.Forms.Plugin.Abstractions.CircleImage
            {
                //ImageSource.FromUri(new Uri("https://www.clipartmax.com/png/middle/258-2582267_circled-user-male-skin-type-1-2-icon-male-user-icon.png"))
                //
                Source = Utilities.Source("IMG_5204.JPG", typeof(ListAllChatTemplate)),
                Aspect = Aspect.AspectFit,
            };

            Label OnlineOffline = new Label
            {
                Text                    = "ONLINE",
                TextColor               = Color.Green,
                FontAttributes          = FontAttributes.Bold,
                FontSize                = 12,
                VerticalOptions         = LayoutOptions.End,
                VerticalTextAlignment   = TextAlignment.End,
                HorizontalTextAlignment = TextAlignment.Center,
                IsVisible               = false
            };

            Grid0.Children.Add(UserImage);
            //Grid0.Children.Add(OnlineOffline);

            /**Grid1 holds the name, time etc**/
            Grid Grid1 = new Grid();

            /** grid1 should be tappable and should send some info to the chatpage**/
            TapGestureRecognizer Grid1Tapped = new TapGestureRecognizer();

            Grid1Tapped.Tapped += delegate
            {
                if (((AbsoluteLayout)con.FindByName("_UserPopUpGrid")).IsVisible)
                {
                    ((AbsoluteLayout)con.FindByName("_UserPopUpGrid")).IsVisible = false;
                }
                else
                {
                    App.Current.MainPage.Navigation.PushAsync(new ChatPage(ReceiversID, Utilities.IsMedic, SenderName, MedicID));
                }
            };

            Grid1.GestureRecognizers.Add(Grid1Tapped);

            Grid.SetColumn(Grid1, 1);

            /** Grid1 needs 2 rowdefinintions to separate
             * 1 for the toplevel and the other for the lower level
             * **/
            RowDefinition RowDef0 = new RowDefinition
            {
                Height = new GridLength(.3, GridUnitType.Star)
            };

            RowDefinition RowDef1 = new RowDefinition
            {
                Height = new GridLength(.7, GridUnitType.Star)
            };

            Grid1.RowDefinitions.Add(RowDef0);
            Grid1.RowDefinitions.Add(RowDef1);

            /** inside GRID1 , the top layer GRID is used by the name and time
             * while LowerLevel holds the message brief content
             * **/
            Grid TopLevel = new Grid();

            Grid.SetRow(TopLevel, 0);

            /** the top level is dived into two sections the name and the time
             * so we need two columndefinitions
             * **/

            TopLevel.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            TopLevel.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            Label NameLabel = new Label
            {
                Text                    = SenderName,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Start,
            };

            Grid.SetColumn(NameLabel, 0);

            Label TimeLabel = new Label
            {
                Text     = Time,
                FontSize = 10,
                HorizontalTextAlignment = TextAlignment.End,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand
            };

            Grid.SetColumn(TimeLabel, 1);

            TopLevel.Children.Add(NameLabel);
            TopLevel.Children.Add(TimeLabel);

            /**the bottomlevel is made of  a label of content and the new message counter**/
            Grid BottomLevel = new Grid();

            Grid.SetRow(BottomLevel, 1);

            BottomLevel.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(.7, GridUnitType.Star)
            });
            BottomLevel.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(.3, GridUnitType.Star)
            });

            Label ContentLabel = new Label
            {
                Text = (Content.Length > 40) ? Content.Substring(0, 40) + "..." : Content,
                VerticalTextAlignment = TextAlignment.Start,
            };

            Label MessageCounterLabel = new Label
            {
                Text     = (NewMessageCount == 0) ? "" : NewMessageCount.ToString(),
                FontSize = 10,
                HorizontalTextAlignment = TextAlignment.End
            };

            Grid.SetColumn(ContentLabel, 0);
            Grid.SetColumn(MessageCounterLabel, 1);

            BottomLevel.Children.Add(ContentLabel);
            BottomLevel.Children.Add(MessageCounterLabel);


            Grid1.Children.Add(TopLevel);
            Grid1.Children.Add(BottomLevel);


            ParentGrid.Children.Add(Grid0);
            ParentGrid.Children.Add(Grid1);

            //
            StackLayout AllStack = new StackLayout {
                Spacing = 0
            };

            AllStack.Children.Add(ParentGrid);
            AllStack.Children.Add(new BoxView {
                Style = App.Current.Resources["_BoxViewBottomLine"] as Style, BackgroundColor = (Color.White)
            });

            return(AllStack);
        }
Example #9
0
        public async void LoadPage()
        {
            try
            {
                ShowLoading(true);

                var result = await service.GetAsync("product/rating/getProductRatingsByProductId?productId=" + Product.Id);

                var list = JsonConvert.DeserializeObject <List <ProductRating> >(result);

                if (list.Count < 1)
                {
                    return;
                }


                stkItens.Children.Clear();
                foreach (var item in list)
                {
                    var grid = new Grid
                    {
                        ColumnDefinitions =
                        {
                            new ColumnDefinition {
                                Width = new GridLength(1, GridUnitType.Auto)
                            },
                            new ColumnDefinition {
                                Width = new GridLength(1, GridUnitType.Star)
                            }
                        }
                    };


                    StackLayout stk = new StackLayout();
                    stk.Margin  = new Thickness(0, 0, 0, 10);
                    stk.Spacing = 0;

                    ImageCircle.Forms.Plugin.Abstractions.CircleImage image = new ImageCircle.Forms.Plugin.Abstractions.CircleImage();
                    image.HeightRequest     = 50;
                    image.WidthRequest      = 50;
                    image.HorizontalOptions = LayoutOptions.Center;
                    image.VerticalOptions   = LayoutOptions.Center;
                    image.Aspect            = Aspect.AspectFill;
                    image.Source            = item.Client.Photo;
                    image.StyleId           = item.Id;

                    Label lblName = new Label();
                    lblName.FontSize  = 12;
                    lblName.TextColor = Color.FromHex("#212121");
                    lblName.HorizontalTextAlignment = TextAlignment.Start;
                    lblName.Text = item.Client.Name + " - " + item.CreatedAt.ToString("dd/MM/yyyy");

                    Label lblComentario = new Label();
                    lblComentario.FontSize  = 10;
                    lblComentario.TextColor = Color.Silver;
                    lblComentario.HorizontalTextAlignment = TextAlignment.Start;
                    lblComentario.Text = item.Message;

                    BoxView box = new BoxView();
                    box.HeightRequest = 1;
                    box.WidthRequest  = 500;
                    box.Color         = Color.FromHex("#ccc");

                    stk.Children.Add(lblName);
                    stk.Children.Add(lblComentario);

                    grid.Children.Add(stk, 1, 0);
                    grid.Children.Add(image, 0, 0);

                    stkItens.Children.Add(grid);
                    stkItens.Children.Add(box);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                ShowLoading(false);
            }
        }
        public async void LoadOrdersByCheckinId()
        {
            OrderService Orderservice = new OrderService();

            try
            {
                var result = await Orderservice.GetCheckinsSubsByCheckinId(_checkin.Id);

                ListSubCheckin = JsonConvert.DeserializeObject <List <CheckinSub> >(result);


                stkLocations.IsVisible = true;

                foreach (var item in ListSubCheckin)
                {
                    var grid = new Grid
                    {
                        ColumnDefinitions =
                        {
                            new ColumnDefinition {
                                Width = new GridLength(1, GridUnitType.Auto)
                            },
                            new ColumnDefinition {
                                Width = new GridLength(1, GridUnitType.Star)
                            },
                            new ColumnDefinition {
                                Width = new GridLength(1, GridUnitType.Auto)
                            }
                        }
                    };


                    StackLayout stk = new StackLayout();
                    stk.Margin      = new Thickness(0, 0, 0, 10);
                    stk.Orientation = StackOrientation.Horizontal;
                    stk.Spacing     = 0;
                    stk.StyleId     = item.Id;



                    ImageCircle.Forms.Plugin.Abstractions.CircleImage image = new ImageCircle.Forms.Plugin.Abstractions.CircleImage();
                    image.HeightRequest     = 26;
                    image.WidthRequest      = 26;
                    image.FillColor         = Color.FromHex("#ccc");
                    image.HorizontalOptions = LayoutOptions.Center;
                    image.VerticalOptions   = LayoutOptions.Center;
                    image.Aspect            = Aspect.AspectFill;
                    image.Source            = item.Location.ImageUri;
                    image.StyleId           = item.Id;

                    Label lblName = new Label();
                    lblName.FontSize  = 12;
                    lblName.Margin    = new Thickness(10, 0, 0, 0);
                    lblName.TextColor = Color.FromHex("#212121");
                    lblName.HorizontalTextAlignment = TextAlignment.Start;
                    lblName.VerticalTextAlignment   = TextAlignment.Center;
                    lblName.Text = item.Location.Name + " - Total: " + AppResource.currency + item.TotalPaid.ToString("F");

                    stk.Children.Add(image);
                    stk.Children.Add(lblName);

                    //var tpReco = new TapGestureRecognizer();
                    //tpReco.Tapped += OnLocationTapped;
                    //stk.GestureRecognizers.Add(tpReco);


                    var stkTwo = new StackLayout();


                    Image imgCk = new Image();
                    //imgCk.IsVisible = item.CheckinSubStatus != Enums.CheckinSubStatus.Closed ? true : false;
                    imgCk.IsVisible    = false;
                    imgCk.WidthRequest = 28;
                    imgCk.Source       = "ic_detail_checkout";

                    Label lblStatus = new Label();
                    lblStatus.FontSize  = 12;
                    lblStatus.Text      = item.CheckinSubStatusStr;
                    lblStatus.IsVisible = true;

                    stkTwo.Children.Add(lblStatus);
                    stkTwo.Children.Add(imgCk);


                    grid.Children.Add(stk, 0, 0);
                    grid.Children.Add(stkTwo, 2, 0);


                    //var detailsRecognizer = new TapGestureRecognizer();
                    //detailsRecognizer.Tapped += OnCkGestureTapped_Tapped;
                    //imgCk.GestureRecognizers.Add(detailsRecognizer);
                    imgCk.StyleId = item.Id;


                    stkLocations.Children.Add(grid);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
        }
        public async void LoadProducts()
        {
            stkItens.Children.Clear();
            foreach (var itemGroup in ListProduct)
            {
                float groupFontSize = 18;
                if (Device.Idiom == TargetIdiom.Tablet)
                {
                    groupFontSize = 22;
                }

                Label lblgroup = new Label();
                lblgroup.FontSize                = groupFontSize;
                lblgroup.FontAttributes          = FontAttributes.Bold;
                lblgroup.Margin                  = new Thickness(0, 15, 0, 15);
                lblgroup.TextColor               = Color.FromHex("#212121");
                lblgroup.HorizontalTextAlignment = TextAlignment.Start;
                lblgroup.Text = itemGroup.Name;

                stkItens.Children.Add(lblgroup);

                foreach (var item in itemGroup.Products)
                {
                    var grid = new Grid
                    {
                        ColumnDefinitions =
                        {
                            new ColumnDefinition {
                                Width = new GridLength(1, GridUnitType.Auto)
                            },
                            new ColumnDefinition {
                                Width = new GridLength(1, GridUnitType.Star)
                            },
                            new ColumnDefinition {
                                Width = new GridLength(1, GridUnitType.Auto)
                            }
                        }
                    };


                    StackLayout stk = new StackLayout();
                    stk.Margin  = new Thickness(0, 0, 0, 10);
                    stk.Spacing = 0;

                    var detailsRecognizer = new TapGestureRecognizer();
                    detailsRecognizer.Tapped += DetailsRecognizer_Tapped;
                    grid.GestureRecognizers.Add(detailsRecognizer);
                    grid.StyleId = item.Id;

                    StackLayout stkImages = new StackLayout();
                    stkImages.Orientation       = StackOrientation.Horizontal;
                    stkImages.HorizontalOptions = LayoutOptions.Center;
                    stkImages.Margin            = new Thickness(0, 0, 0, 10);
                    stkImages.Spacing           = 0;

                    StackLayout stkprice = new StackLayout();
                    stkprice.Margin  = new Thickness(0, 0, 0, 10);
                    stkprice.Spacing = 0;

                    ImageCircle.Forms.Plugin.Abstractions.CircleImage image = new ImageCircle.Forms.Plugin.Abstractions.CircleImage();
                    image.HeightRequest     = 50;
                    image.WidthRequest      = 50;
                    image.FillColor         = Color.FromHex("#ccc");
                    image.HorizontalOptions = LayoutOptions.Center;
                    image.VerticalOptions   = LayoutOptions.Center;
                    image.Aspect            = Aspect.AspectFill;
                    image.Source            = item.ImageUri;
                    image.StyleId           = item.Id;


                    float nameFontSize    = 12;
                    float commentFontSize = 10;
                    float priceFontSize   = 12;

                    if (Device.Idiom == TargetIdiom.Tablet)
                    {
                        nameFontSize    = 18;
                        commentFontSize = 16;
                        priceFontSize   = 18;
                    }

                    Label lblName = new Label();
                    lblName.FontSize  = nameFontSize;
                    lblName.TextColor = Color.FromHex("#212121");
                    lblName.HorizontalTextAlignment = TextAlignment.Start;
                    lblName.Text = item.Name;

                    Label lblComentario = new Label();
                    lblComentario.FontSize  = commentFontSize;
                    lblComentario.TextColor = Color.Silver;
                    lblComentario.HorizontalTextAlignment = TextAlignment.Start;
                    lblComentario.Text = item.Description;

                    Label lblPrice = new Label();
                    lblPrice.FontSize  = priceFontSize;
                    lblPrice.TextColor = Color.Green;
                    lblPrice.HorizontalTextAlignment = TextAlignment.Start;
                    lblPrice.Text = String.Format(new System.Globalization.CultureInfo("en-US"), "{0:C}", item.Price);

                    Image imgStar = new Image();
                    imgStar.WidthRequest = 16;
                    imgStar.Source       = item.ProductStarImage;

                    Image imgFavorite = new Image();
                    imgFavorite.WidthRequest = 16;
                    imgFavorite.Source       = "ic_heart_list";

                    BoxView box = new BoxView();
                    box.HeightRequest = 1;
                    box.WidthRequest  = 500;
                    box.Color         = Color.FromHex("#ccc");


                    if (item.IsFavorited)
                    {
                        stkImages.Children.Add(imgFavorite);
                    }

                    //stkImages.Children.Add(imgStar);
                    stkprice.Children.Add(lblPrice);
                    stkprice.Children.Add(stkImages);

                    stk.Children.Add(lblName);
                    stk.Children.Add(lblComentario);

                    if (!string.IsNullOrEmpty(item.ImageUri))
                    {
                        grid.Children.Add(image, 0, 0);
                    }

                    grid.Children.Add(stk, 1, 0);
                    grid.Children.Add(stkprice, 2, 0);

                    stkItens.Children.Add(grid);
                    stkItens.Children.Add(box);
                }
            }

            ShowLoading(false);
        }