Beispiel #1
0
        public Frame GetFrameIsDuplicate(PortionModel model)
        {
            var frame = new Frame()
            {
                Margin = new Thickness(10, 10)
            };

            var stackTemplate = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal
            };

            var checkImage = new Image()
            {
                WidthRequest   = 20,
                HeightRequest  = 20,
                BindingContext = model
            };

            checkImage.SetBinding(Image.SourceProperty, new Binding(nameof(model.IsDuplicate), BindingMode.OneWay, new IsAvailableUpdateToCheckBoxIconConverter(Constants.CheckboxOnImageSource, Constants.CheckboxOffImageSource)));

            var checkClickableView = new ClickableContentView()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                CommandParameter  = model,
                BindingContext    = model,
                Content           = checkImage
            };

            checkClickableView.SetBinding(ClickableContentView.CommandProperty, nameof(model.ChangeCheckboxIsDuplicateCommand));

            var titleLable = new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Text = "Дублировать порцию",
            };

            stackTemplate.Children.Add(checkClickableView);
            stackTemplate.Children.Add(titleLable);

            frame.Content = stackTemplate;
            return(frame);
        }
Beispiel #2
0
        private StackLayout GetDishItemView(PortionWithCheckDish model)
        {
            var template = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Margin      = new Thickness(0, 10)
            };

            var titleLabel = new Label()
            {
                Text = model.Dish.Name,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            var checkImage = new Image()
            {
                WidthRequest   = 20,
                HeightRequest  = 20,
                BindingContext = model.Dish
            };

            checkImage.SetBinding(Image.SourceProperty, new Binding(nameof(model.Dish.IsSelected), BindingMode.OneWay, new IsAvailableUpdateToCheckBoxIconConverter(Constants.CheckboxOnImageSource, Constants.CheckboxOffImageSource)));

            var checkClickableView = new ClickableContentView()
            {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                CommandParameter  = model,
                BindingContext    = model.Dish,
                Content           = checkImage
            };

            checkClickableView.SetBinding(ClickableContentView.CommandProperty, nameof(model.Dish.ChangeCheckboxCommand));

            template.Children.Add(titleLabel);
            template.Children.Add(checkClickableView);

            return(template);
        }
Beispiel #3
0
        private ContentView GetView(DishModel model)
        {
            var mainContent = new ContentView();
            var template    = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Margin      = new Thickness(0, 10),
                //BackgroundColor = Color.LimeGreen
            };

            var checkImage = new Image()
            {
                WidthRequest      = 20,
                HeightRequest     = 20,
                BindingContext    = model,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            checkImage.SetBinding(Image.SourceProperty, new Binding(nameof(model.IsSelected), BindingMode.OneWay, new IsAvailableUpdateToCheckBoxIconConverter(Constants.CheckboxOnImageSource, Constants.CheckboxOffImageSource)));

            var checkClickableView = new ClickableContentView()
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                CommandParameter  = model,
                BindingContext    = model,
                Content           = checkImage,
                WidthRequest      = 30,
                //BackgroundColor = Color.Red,
                Margin = 0
            };

            checkClickableView.SetBinding(ClickableContentView.CommandProperty, nameof(model.ChangeCheckboxCommand));

            var titleLabel = new Label()
            {
                Margin = 0,
                Text   = model.Name,
                //VerticalTextAlignment = TextAlignment.Start,
                //HorizontalTextAlignment = TextAlignment.Start,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                //BackgroundColor = Color.Blue
            };

            var deleteImage = new Image()
            {
                Source        = "delete",
                WidthRequest  = 20,
                HeightRequest = 20,
            };

            var deleteClickableView = new ClickableContentView()
            {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                CommandParameter  = model.Id,
                Content           = deleteImage,
                //BackgroundColor = Color.Red
            };

            switch (model.CategoryType)
            {
            case DishCategory.Garnish:
                deleteClickableView.SetBinding(ClickableContentView.CommandProperty, nameof(DishViewModel.DeleteGarnishDishCommand));
                break;

            case DishCategory.Meat:
                deleteClickableView.SetBinding(ClickableContentView.CommandProperty, nameof(DishViewModel.DeleteMeatDishCommand));
                break;

            case DishCategory.Salad:
                deleteClickableView.SetBinding(ClickableContentView.CommandProperty, nameof(DishViewModel.DeleteSaladDishCommand));
                break;

            case DishCategory.Bread:
                deleteClickableView.SetBinding(ClickableContentView.CommandProperty, nameof(DishViewModel.DeleteBreadDishCommand));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            template.Children.Add(checkClickableView);
            template.Children.Add(titleLabel);
            template.Children.Add(deleteClickableView);

            mainContent.Content = template;

            return(mainContent);
        }
Beispiel #4
0
        private ContentView GetView(PortionModel model)
        {
            var mainContent = new ContentView();
            var template    = new StackLayout()
            {
                Orientation = StackOrientation.Vertical
            };

            var templateShowPortition = new StackLayout()
            {
                Orientation     = StackOrientation.Horizontal,
                BackgroundColor = Color.LightCoral,
                HeightRequest   = 40,
                Margin          = new Thickness(10)
            };

            var titleShowPortitionLabel = new Label()
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Text = "Порция",
            };

            var showPortitionImage = new Image()
            {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                BindingContext    = model,
                Margin            = new Thickness(0, 0, 30, 0)
            };

            showPortitionImage.SetBinding(Image.SourceProperty, new Binding(nameof(model.IsVisible), BindingMode.OneWay, new IsAvailableUpdateToCheckBoxIconConverter(Constants.MoreImageSource, Constants.LessImageSource)));

            templateShowPortition.Children.Add(titleShowPortitionLabel);
            templateShowPortition.Children.Add(showPortitionImage);

            var contentPortitionView = new ContentView()
            {
                BindingContext = model,
            };
            var templatePotition = new StackLayout()
            {
                BindingContext = model
            };

            contentPortitionView.SetBinding(ContentView.IsVisibleProperty, new Binding(nameof(model.IsVisible)));

            var showPortitionClickableView = new ClickableContentView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Content           = templateShowPortition,
                CommandParameter  = model,
                BindingContext    = model
            };

            showPortitionClickableView.SetBinding(ClickableContentView.CommandProperty, nameof(model.ChangeVisiblePortitionCommand));


            templatePotition.Children.Add(GetDishFream(model, "side_dish", "Гарнир", DishCategory.Garnish));
            templatePotition.Children.Add(GetDishFream(model, "meat", "Мясное", DishCategory.Meat));
            templatePotition.Children.Add(GetDishFream(model, "salad", "Салат", DishCategory.Salad));
            templatePotition.Children.Add(GetDishFream(model, "bread", "Хлеб", DishCategory.Bread));
            templatePotition.Children.Add(GetFrameIsDuplicate(model));


            template.Children.Add(showPortitionClickableView);
            contentPortitionView.Content = templatePotition;
            template.Children.Add(contentPortitionView);
            mainContent.Content = template;
            return(mainContent);
        }
        private ContentView GetPortitionView(PortionModel model)
        {
            var mainContant = new ContentView();
            var template    = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Margin      = new Thickness(0, 10)
            };

            var titleTemplate = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal
            };

            var titleLabel = new Label()
            {
                Text              = "Порция:",
                TextColor         = Color.Black,
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            var checkImage = new Image()
            {
                WidthRequest      = 20,
                HeightRequest     = 20,
                Source            = "delete",
                HorizontalOptions = LayoutOptions.EndAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                BindingContext    = model
            };

            var checkClickableView = new ClickableContentView()
            {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                CommandParameter  = model,
                BindingContext    = model,
                Content           = checkImage
            };

            checkClickableView.SetBinding(ClickableContentView.CommandProperty, nameof(model.DeletePortionCommand));

            titleTemplate.Children.Add(titleLabel);
            titleTemplate.Children.Add(checkClickableView);

            var bodyTemplate = new StackLayout()
            {
                Orientation = StackOrientation.Vertical
            };


            var garnishLabel = new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                BindingContext    = model.PortionInfo,
            };

            garnishLabel.SetBinding(Label.TextProperty, new Binding(nameof(model.PortionInfo.GarnishName)));
            garnishLabel.SetBinding(Label.IsVisibleProperty, new Binding(nameof(model.PortionInfo.IsGarnishVisible)));

            var meatLabel = new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                BindingContext    = model.PortionInfo
            };

            meatLabel.SetBinding(Label.TextProperty, new Binding(nameof(model.PortionInfo.MeatName)));
            meatLabel.SetBinding(Label.IsVisibleProperty, new Binding(nameof(model.PortionInfo.IsMeatVisible)));

            var firstSaladLabel = new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                BindingContext    = model.PortionInfo
            };

            firstSaladLabel.SetBinding(Label.TextProperty, new Binding(nameof(model.PortionInfo.FirstSaladName)));
            firstSaladLabel.SetBinding(Label.IsVisibleProperty, new Binding(nameof(model.PortionInfo.IsFirstSaladVisible)));

            var secondSaladLabel = new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                BindingContext    = model.PortionInfo
            };

            secondSaladLabel.SetBinding(Label.TextProperty, new Binding(nameof(model.PortionInfo.SecondSaladName)));
            secondSaladLabel.SetBinding(Label.IsVisibleProperty, new Binding(nameof(model.PortionInfo.IsSecondSaladVisible)));

            var breadLabel = new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                BindingContext    = model.PortionInfo
            };

            breadLabel.SetBinding(Label.TextProperty, new Binding(nameof(model.PortionInfo.BreadName)));
            breadLabel.SetBinding(Label.IsVisibleProperty, new Binding(nameof(model.PortionInfo.IsBreadVisible)));

            var sauseLabel = new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                BindingContext    = model,
                Text = "Подлива"
            };

            sauseLabel.SetBinding(Label.IsVisibleProperty, new Binding(nameof(model.IsToggled)));

            var sumTempalte = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal
            };
            var sumLabel = new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Text           = "Сумма:",
                TextColor      = Color.Black,
                FontAttributes = FontAttributes.Bold
            };

            var dublePriceLabel = new Label()
            {
                HorizontalOptions       = LayoutOptions.End,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                HorizontalTextAlignment = TextAlignment.End,
                Text           = "2x",
                BindingContext = model
            };

            dublePriceLabel.SetBinding(Label.IsVisibleProperty, new Binding(nameof(model.IsDuplicate)));

            var priceLabel = new Label()
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                TextColor         = Color.FromHex("#47cfa5"),
                FontAttributes    = FontAttributes.Bold,
                BindingContext    = model
            };

            priceLabel.SetBinding(Label.TextProperty, new Binding(nameof(model.PriceStr)));

            var commentEntry = new Entry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Placeholder       = "Введите свой коментарий",
                BindingContext    = model.Comment,
                FontSize          = 14
            };

            commentEntry.SetBinding(Entry.TextProperty, new Binding(nameof(model.Comment)));

            sumTempalte.Children.Add(sumLabel);
            sumTempalte.Children.Add(dublePriceLabel);
            sumTempalte.Children.Add(priceLabel);

            bodyTemplate.Children.Add(garnishLabel);
            bodyTemplate.Children.Add(meatLabel);
            bodyTemplate.Children.Add(firstSaladLabel);
            bodyTemplate.Children.Add(secondSaladLabel);
            bodyTemplate.Children.Add(breadLabel);
            bodyTemplate.Children.Add(sauseLabel);
            bodyTemplate.Children.Add(sumTempalte);
            bodyTemplate.Children.Add(commentEntry);

            template.Children.Add(titleTemplate);
            template.Children.Add(bodyTemplate);

            mainContant.Content = template;
            return(mainContant);
        }