Exemple #1
0
        public StackLayout EmojiCompLayout(List <string> emojiList, List <string> emojiDescList)
        {
            _baseLayout = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.Center
            };
            _imLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest     = 100
            };
            for (int i = 0; i < emojiList.Count; i++)
            {
                _emojiLayout = new StackLayout
                {
                    Orientation       = StackOrientation.Vertical,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center,
                    WidthRequest      = 150,
                    Spacing           = 20
                };
                _emojiDescLabel = new Label
                {
                    TextColor = Color.White,
                    FontSize  = 18,
                    Text      = emojiDescList[i],
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalOptions       = LayoutOptions.CenterAndExpand,
                    HeightRequest           = 200,
                };

                _emojiIcon = new Image {
                    Aspect = Aspect.AspectFit
                };
                _emojiIcon.Source       = ImageSource.FromFile(emojiList[i]);
                _emojiIcon.WidthRequest = 80;

                GlobalModel.EmojiDescLabelList.Add(_emojiDescLabel);
                GlobalModel.EmojiIconList.Add(_emojiIcon);

                TapGestureRecognizer _tapGestureRecognizer = new TapGestureRecognizer();
                _tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, "TappedCommand");

                EmojiIconModel _emojiIconModel = new EmojiIconModel(i.ToString(), _emojiIcon, _emojiDescLabel);
                _tapGestureRecognizer.CommandParameter = _emojiIconModel;
                _emojiIcon.GestureRecognizers.Add(_tapGestureRecognizer);

                _emojiLayout.Children.Add(_emojiIcon);
                _emojiLayout.Children.Add(_emojiDescLabel);

                _imLayout.Children.Add(_emojiLayout);
            }

            _baseLayout.Children.Add(_imLayout);

            return(_baseLayout);
        }
        /// <summary>
        /// Emojis the tapped.
        /// </summary>
        /// <returns>The tapped.</returns>
        /// <param name="emojiIconModel">Emoji icon model.</param>
        async Task EmojiTapped(EmojiIconModel emojiIconModel)
        {
            if (!_tapLocked)
            {
                _tapLocked   = true;
                _canLoadNext = false;
                _canGoBack   = false;

                _selectedValue = (Convert.ToInt32(emojiIconModel.Id) + 1).ToString();

                if (FeedbackCart._guestImage == null && Convert.ToInt32(_selectedValue) < 3)
                {
                    NativeCamera.UploadImage();
                }

                Console.WriteLine("tapped :" + _selectedValue);

                foreach (var item in emojiIconList)
                {
                    if (item.Id != emojiIconModel.EmojiIcon.Id)
                    {
                        item.Opacity = 0.5;
                    }
                    else
                    {
                        item.Opacity = 1;
                    }
                }

                foreach (var item in emojiLabelList)
                {
                    if (emojiIconModel.EmojiDescLabel.Id == item.Id)
                    {
                        item.TextColor = Color.LightGreen;
                    }
                    else
                    {
                        item.TextColor = Color.Gray;
                    }
                }

                await emojiIconModel.EmojiIcon.ScaleTo(2, 150);

                await emojiIconModel.EmojiIcon.ScaleTo(1, 150);


                //Check Criterias

                var subCriteria = _Questions.SubQuestionCriteria;
                if (!string.IsNullOrEmpty(subCriteria) && subCriteria != "All")
                {
                    if (subCriteria.Contains(_selectedValue))
                    {
                        SetChildVisibility(_selectedValue);
                    }
                    else
                    {
                        _childLayout.IsVisible = false;
                        ResetChildRatingsFromCart();
                        _autofoward = true;
                    }
                }

                Device.StartTimer(TimeSpan.FromSeconds(GlobalModel.TimeSpan), () =>
                {
                    if (_autofoward)
                    {
                        LoadNextPage();
                        _canLoadNext = false;
                        _canGoBack   = false;
                        _tapLocked   = true;
                    }
                    else
                    {
                        _canLoadNext = true;
                        _canGoBack   = true;
                        _tapLocked   = false;
                    }

                    return(false);
                });
            }
        }