コード例 #1
0
ファイル: MuaPage.cs プロジェクト: acedev1/Tiro_App
        private DataTemplate GetDataTemplate()
        {
            return(new DataTemplate(() =>
            {
                Label author = new CustomLabel();
                author.SetBinding(Label.TextProperty, "Author");
                author.TextColor = Props.ButtonInfoPageColor;
                author.FontSize = 20;
                author.FontFamily = UIUtils.FONT_BEBAS_REGULAR;
                author.Margin = new Thickness(20, 0, 20, 0);

                var ratingLayout = new RatingLayout();
                ratingLayout.HeightRequest = 20;
                ratingLayout.SetBinding(RatingLayout.RatingProperty, "Rating");
                ratingLayout.HorizontalOptions = LayoutOptions.EndAndExpand;
                ratingLayout.Margin = new Thickness(0, 0, 20, 0);

                var top = new StackLayout {
                    Orientation = StackOrientation.Horizontal,
                    Margin = new Thickness(0, 20, 0, 0),
                    Children =
                    {
                        author,
                        ratingLayout
                    }
                };

                var review = new CustomLabel();
                review.SetBinding(Label.TextProperty, "Description");
                review.TextColor = Color.Black;
                review.HorizontalOptions = LayoutOptions.Fill;
                review.FontFamily = UIUtils.FONT_SFUIDISPLAY_LIGHT;
                review.Margin = new Thickness(20, 0, 20, 0);

                var layout = new StackLayout();
                layout.Children.Add(top);
                layout.Children.Add(review);
                var viewCell = new ViewCell();
                viewCell.View = layout;
                return viewCell;
            }));
        }
コード例 #2
0
ファイル: SearchPage.cs プロジェクト: acedev1/Tiro_App
        private DataTemplate GetDataTemplate()
        {
            return(new DataTemplate(() =>
            {
                CustomLabel address = new CustomLabel();
                address.SetBinding(Label.TextProperty, "Address");
                address.LetterSpacing = 0.15f;
                address.FontSize = 14;
                address.TextColor = Color.FromHex("#4A4A4A");
                address.LineBreakMode = LineBreakMode.TailTruncation;
                address.FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR;
                address.Margin = new Thickness(10, 0, 5, 0);

                CustomLabel mainText = new CustomLabel();
                mainText.SetBinding(Label.TextProperty, "BusinessName");
                mainText.LetterSpacing = 0.25f;
                mainText.FontSize = 21;
                mainText.TextColor = Color.FromHex("#4A4A4A");
                mainText.FontFamily = UIUtils.FONT_BEBAS_BOOK;
                mainText.Margin = new Thickness(5, 0, 0, 0);

                CustomLabel price = new CustomLabel();
                price.SetBinding(Label.TextProperty, "Price");
                price.LetterSpacing = 0.1f;
                price.FontSize = 14;
                price.TextColor = Color.FromHex("#4A4A4A");
                price.FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR;

                CustomLabel nameMua = new CustomLabel();
                nameMua.SetBinding(Label.TextProperty, "FullName");
                nameMua.LetterSpacing = 0.15f;
                nameMua.FontSize = 16;
                nameMua.TextColor = Color.FromHex("#4A4A4A");
                nameMua.FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR;
                nameMua.Margin = new Thickness(5, 0, 0, 0);

                var imageBackground = new Image();
                imageBackground.SetBinding(UIUtils.TagProperty, "Pictures");
                imageBackground.SetValue(UIUtils.Tag2Property, 0);
                imageBackground.Aspect = Aspect.AspectFill;
                imageBackground.SetBinding(Image.SourceProperty, "PictureSourse");

                var leftImg = new Image();
                leftImg.Source = ImageSource.FromResource("TiroApp.Images.goToMua.png");
                leftImg.HeightRequest = 40;
                leftImg.WidthRequest = leftImg.HeightRequest;
                leftImg.GestureRecognizers.Add(new TapGestureRecognizer((v) =>
                {
                    ShowNextBgImage(imageBackground, -1);
                }));

                var rightImg = new Image();
                rightImg.Source = ImageSource.FromResource("TiroApp.Images.goToMua.png");
                rightImg.Rotation = 180;
                rightImg.HeightRequest = 40;
                rightImg.WidthRequest = rightImg.HeightRequest;
                rightImg.GestureRecognizers.Add(new TapGestureRecognizer((v) =>
                {
                    ShowNextBgImage(imageBackground, 1);
                }));

                var location = new Image();
                location.Source = ImageSource.FromResource("TiroApp.Images.location_black.png");
                location.HeightRequest = 20;
                //location.WidthRequest = rightImg.HeightRequest;

                var ratingLayout = new RatingLayout();
                ratingLayout.HeightRequest = 20;
                ratingLayout.SetBinding(RatingLayout.RatingProperty, "Rating");

                var infoImage = new Image();
                infoImage.Source = ImageSource.FromResource("TiroApp.Images.muaListRectangle.png");
                infoImage.Aspect = Aspect.Fill;
                //infoImage.HeightRequest = 70;
                //infoImage.WidthRequest = App.ScreenWidth;

                //var infoFrame = new Frame();
                //infoFrame.Content = infoImage;
                //infoFrame.OutlineColor = Color.FromHex("#979797");

                var layout = new RelativeLayout();
                layout.Children.Add(imageBackground, Constraint.Constant(0), Constraint.Constant(0)
                                    , Constraint.RelativeToParent(p => p.Width)
                                    , Constraint.RelativeToParent(p => p.Height - 70));
                layout.Children.Add(leftImg
                                    , Constraint.RelativeToParent(p => p.Width - Utils.GetControlSize(leftImg).Width - 10)
                                    , Constraint.RelativeToParent(p => (p.Height - 70) / 2 - Utils.GetControlSize(leftImg).Height / 2));
                layout.Children.Add(rightImg
                                    , Constraint.Constant(10)
                                    , Constraint.RelativeToParent(p => (p.Height - 70) / 2 - Utils.GetControlSize(rightImg).Height / 2));
                layout.Children.Add(infoImage
                                    , Constraint.Constant(0)
                                    , Constraint.RelativeToParent(p => p.Height - 70)
                                    , Constraint.RelativeToParent(p => p.Width)
                                    , Constraint.Constant(75));
                layout.Children.Add(mainText
                                    , Constraint.Constant(3)
                                    , Constraint.RelativeToParent(p => p.Height - 65));
                layout.Children.Add(nameMua
                                    , Constraint.Constant(3)
                                    , Constraint.RelativeToParent(p => p.Height - Utils.GetControlSize(nameMua).Height - Utils.GetControlSize(location).Height - 4));
                layout.Children.Add(location
                                    , Constraint.Constant(8)
                                    , Constraint.RelativeToParent(p => p.Height - Utils.GetControlSize(location).Height - 2));
                layout.Children.Add(address
                                    , Constraint.RelativeToParent(p => Utils.GetControlSize(location).Width + 4)
                                    , Constraint.RelativeToParent(p => p.Height - Utils.GetControlSize(address).Height - 2)
                                    , Constraint.RelativeToParent(p => Utils.GetControlSize(address).Width)
                                    , Constraint.RelativeToParent(p => Utils.GetControlSize(address).Height));
                layout.Children.Add(ratingLayout
                                    , Constraint.RelativeToParent(p => p.Width - Utils.GetControlSize(ratingLayout).Width - 5)
                                    , Constraint.RelativeToParent(p => p.Height - 65));
                layout.Children.Add(price
                                    , Constraint.RelativeToParent(p => p.Width - Utils.GetControlSize(price).Width - 5)
                                    , Constraint.RelativeToParent(p => p.Height - 40));
                layout.Margin = new Thickness(0, 0, 0, 25);
                var viewCell = new ViewCell();
                viewCell.View = layout;
                return viewCell;
            }));
        }
コード例 #3
0
ファイル: SearchPage.cs プロジェクト: yomtej/Tiro_App
        private DataTemplate GetDataTemplate()
        {
            return(new DataTemplate(() =>
            {
                Label address = new CustomLabel();
                address.SetBinding(Label.TextProperty, "Address");
                address.TextColor = Color.White;
                address.LineBreakMode = LineBreakMode.TailTruncation;
                address.FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR;

                Label mainText = new CustomLabel();
                mainText.SetBinding(Label.TextProperty, "BusinessName");
                mainText.FontSize = 21;
                mainText.TextColor = Color.White;
                mainText.FontFamily = UIUtils.FONT_BEBAS_BOOK;

                Label price = new CustomLabel();
                price.SetBinding(Label.TextProperty, "Price");
                price.TextColor = Color.White;
                price.FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR;

                Label nameMua = new CustomLabel();
                nameMua.SetBinding(Label.TextProperty, "FullName");
                nameMua.TextColor = Color.White;
                nameMua.FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR;

                var imageBackground = new Image();
                imageBackground.SetBinding(UIUtils.TagProperty, "Pictures");
                imageBackground.SetValue(UIUtils.Tag2Property, 0);
                imageBackground.Aspect = Aspect.AspectFill;
                imageBackground.SetBinding(Image.SourceProperty, "PictureSourse");

                var leftImg = new Image();
                leftImg.Source = ImageSource.FromResource("TiroApp.Images.goToMua.png");
                leftImg.HeightRequest = 40;
                leftImg.WidthRequest = leftImg.HeightRequest;
                leftImg.GestureRecognizers.Add(new TapGestureRecognizer((v) =>
                {
                    ShowNextBgImage(imageBackground, -1);
                }));

                var rightImg = new Image();
                rightImg.Source = ImageSource.FromResource("TiroApp.Images.goToMua.png");
                rightImg.Rotation = 180;
                rightImg.HeightRequest = 40;
                rightImg.WidthRequest = rightImg.HeightRequest;
                rightImg.GestureRecognizers.Add(new TapGestureRecognizer((v) =>
                {
                    ShowNextBgImage(imageBackground, 1);
                }));

                var location = new Image();
                location.Source = ImageSource.FromResource("TiroApp.Images.location.png");
                location.HeightRequest = 20;
                location.WidthRequest = rightImg.HeightRequest;

                var ratingLayout = new RatingLayout();
                ratingLayout.HeightRequest = 20;
                ratingLayout.SetBinding(RatingLayout.RatingProperty, "Rating");

                var layout = new RelativeLayout();
                layout.BackgroundColor = Color.Black;//TEMP
                layout.Children.Add(imageBackground, Constraint.Constant(0), Constraint.Constant(0)
                                    , Constraint.RelativeToParent(p => p.Width)
                                    , Constraint.RelativeToParent(p => p.Height));
                layout.Children.Add(price
                                    , Constraint.Constant(10)
                                    , Constraint.Constant(10));
                layout.Children.Add(mainText
                                    , Constraint.Constant(10)
                                    , Constraint.RelativeToParent(p => p.Height - p.Height / 3 - Utils.GetControlSize(mainText).Height + 20));
                layout.Children.Add(nameMua
                                    , Constraint.Constant(10)
                                    , Constraint.RelativeToParent(p => p.Height - p.Height / 3 + 20));
                layout.Children.Add(leftImg
                                    , Constraint.RelativeToParent(p => p.Width - Utils.GetControlSize(leftImg).Width - 10)
                                    , Constraint.RelativeToParent(p => p.Height / 2 - Utils.GetControlSize(leftImg).Height / 2));
                layout.Children.Add(rightImg
                                    , Constraint.Constant(10)
                                    , Constraint.RelativeToParent(p => p.Height / 2 - Utils.GetControlSize(rightImg).Height / 2));
                layout.Children.Add(location
                                    , Constraint.Constant(0)
                                    , Constraint.RelativeToParent(p => p.Height - Utils.GetControlSize(location).Height - 15));
                layout.Children.Add(address
                                    , Constraint.Constant(40)
                                    , Constraint.RelativeToParent(p => p.Height - Utils.GetControlSize(address).Height - 15)
                                    , Constraint.RelativeToParent(p => p.Width - Utils.GetControlSize(ratingLayout).Width - 60)
                                    , Constraint.RelativeToParent(p => Utils.GetControlSize(address).Height));
                layout.Children.Add(ratingLayout
                                    , Constraint.RelativeToParent(p => p.Width - Utils.GetControlSize(ratingLayout).Width - 15)
                                    , Constraint.RelativeToParent(p => p.Height - Utils.GetControlSize(ratingLayout).Height - 15));
                var viewCell = new ViewCell();
                viewCell.View = layout;
                return viewCell;
            }));
        }
コード例 #4
0
        public ServiceViewCell(EventHandler OnEditClick, EventHandler OnDeleteClick)
        {
            var nameLabel = new CustomLabel();

            nameLabel.TextColor         = Color.Black;
            nameLabel.FontFamily        = UIUtils.FONT_SFUIDISPLAY_REGULAR;
            nameLabel.FontSize          = 16;
            nameLabel.HorizontalOptions = LayoutOptions.Start;
            nameLabel.SetBinding(Label.TextProperty, "Name", stringFormat: "Name: {0}");
            var priceLabel = new CustomLabel();

            priceLabel.TextColor         = Color.Black;
            priceLabel.FontFamily        = UIUtils.FONT_SFUIDISPLAY_REGULAR;
            priceLabel.FontSize          = 16;
            priceLabel.HorizontalOptions = LayoutOptions.EndAndExpand;
            priceLabel.SetBinding(Label.TextProperty, "Price", stringFormat: UIUtils.NIARA_SIGN + "{0}");
            var row1 = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Margin      = new Thickness(20, 5, 20, 5),
                Children    = { nameLabel, priceLabel }
            };

            var categoryLabel = new CustomLabel();

            categoryLabel.TextColor         = Color.Black;
            categoryLabel.FontFamily        = UIUtils.FONT_SFUIDISPLAY_REGULAR;
            categoryLabel.FontSize          = 16;
            categoryLabel.HorizontalOptions = LayoutOptions.Start;
            categoryLabel.SetBinding(Label.TextProperty, "Category");
            var lengthLabel = new CustomLabel();

            lengthLabel.TextColor         = Color.Black;
            lengthLabel.FontFamily        = UIUtils.FONT_SFUIDISPLAY_REGULAR;
            lengthLabel.FontSize          = 16;
            lengthLabel.HorizontalOptions = LayoutOptions.EndAndExpand;
            lengthLabel.SetBinding(Label.TextProperty, "Length", stringFormat: "{0} minutes");
            var row2 = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Margin      = new Thickness(20, 5, 20, 5),
                Children    = { categoryLabel, lengthLabel }
            };

            var btn1 = UIUtils.MakeButton("EDIT", UIUtils.FONT_SFUIDISPLAY_MEDIUM);

            btn1.TextColor       = Props.ButtonColor;
            btn1.BackgroundColor = Color.FromHex("F8F8F8");
            btn1.SetBinding(UIUtils.TagProperty, "Id");
            btn1.Clicked += (o, a) => { OnEditClick?.Invoke(o, a); };
            var btn2 = UIUtils.MakeButton("DELETE", UIUtils.FONT_SFUIDISPLAY_MEDIUM);

            btn2.SetBinding(UIUtils.TagProperty, "Id");
            btn2.Clicked += (o, a) => { OnDeleteClick?.Invoke(o, a); };
            var row3 = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing           = 0,
                Children          = { btn1, btn2 }
            };

            var content = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Spacing     = 0,
                Children    = { row1, row2, row3, UIUtils.MakeSeparator(true) }
            };

            this.View = content;
        }
コード例 #5
0
        public void CreateView()
        {
            var gridLayout = new Grid {
                RowSpacing = 10, Padding = new Thickness(0, 10, 0, 10), Margin = 10
            };

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

            gridLayout.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            var outerlayout = new StackLayout {
                HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Start
            };


            StackLayout         innerlayout = null;
            int                 count       = list.Count;
            var                 amp         = list;
            int                 colmCounter = 0;
            KeyToValueConverter keyToValue  = new KeyToValueConverter();

            var product = amp[0];

            for (int i = 0; i < product.Count; i++)
            {
                if (i % 2 == 0)
                {
                    innerlayout = new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    };
                    outerlayout.Children.Add(innerlayout);
                    colmCounter = 0;
                }

                object jj = null;
                if (product[i].ContainsValue("Label"))
                {
                    var x = product[i];

                    foreach (var item in x)
                    {
                        if (!item.Value.Equals("Label"))
                        {
                            jj = item.Value;
                        }
                    }

                    var label = new CustomLabel
                    {
                        Text            = "dummy" + i.ToString(),
                        FontSize        = 15,
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        Index           = i.ToString(),
                        BindingKey      = (string)jj,
                        WidthRequest    = 100,
                        Margin          = new Thickness(10, 0, 0, 0)
                    };

                    if (colmCounter % 2 == 0)
                    {
                        label.HorizontalOptions = LayoutOptions.Start;
                    }
                    else
                    {
                        label.HorizontalOptions = LayoutOptions.CenterAndExpand;
                        // label.Margin = new Thickness(10, 0, 0, 0);
                    }


                    //var test = label.BindingKey;
                    //object t1 = new object();
                    //t1 = test;
                    //  var test = x;
                    object t1 = new object();
                    t1 = i;
                    // t1 = test;


                    label.SetBinding(CustomLabel.BindingKeyProperty, new Binding(".", BindingMode.TwoWay,
                                                                                 new KeyToValueConverter(), t1, null,
                                                                                 this.BindingContext));

                    // label.SetBinding(Label.TextProperty, ".",BindingMode.Default,null);


                    gridLayout.Children.Add(label, colmCounter, 1);
                    innerlayout.Children.Add(label);
                    Grid.SetColumnSpan(outerlayout, 2);
                    colmCounter++;
                }
            }

            gridLayout.Children.Add(outerlayout);

            View = new CustomFrame
            {
                Content           = gridLayout,
                CornerRadius      = 10,
                HasShadow         = true,
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.Fill,
                Margin            = new Thickness(10, 5, 10, 5),
                Padding           = 0,
                BorderColor       = Color.Gray,
            };
            // View.HeightRequest = 150;
            this.View.Margin = 5;
        }