Example #1
0
        private async Task OnSelectCategory(IRokredListChildDataSource category)
        {
            SelectedChildCategory = category;
            SetInternalSelectedStates();

            base.AddContext(category);

            (App.Current as App).NavigateTo(new CategoryView(base.DataSourceContext, category as CategoryVmi));
        }
Example #2
0
        private async Task OnSelectOpinion(IRokredListChildDataSource vmi)
        {
            SelectedChildOpinion = vmi;
            SetInternalSelectedStates();

            base.AddContext(vmi);

            (App.Current as App).NavigateTo(new OpinionView(base.DataSourceContext, CurrentSubject, vmi as OpinionVmi));
        }
Example #3
0
        private async Task OnSelectSubject(IRokredListChildDataSource subject)
        {
            SelectedChildSubject  = subject;
            SelectedChildCategory = null;
            SetInternalSelectedStates();

            base.AddContext(subject);

            (App.Current as App).NavigateTo(page: new SubjectView(base.DataSourceContext, subject as SubjectVmi));
        }
Example #4
0
 protected void SelectedItemChanged(IRokredListChildDataSource val)
 {
     foreach (var child in StackChildren.Children)
     {
         if (child is RokredButton button)
         {
             if (button.Content is IRokredListChildView view)
             {
                 view.SetIsSelected(val == view.DataSource);
             }
         }
     }
 }
Example #5
0
        protected void AddContext(IRokredListChildDataSource item)
        {
            if (DataSourceContext == null)
            {
                DataSourceContext = new DataSourceContext();
            }

            while (DataSourceContext.ContextItems.Count >= DataSourceContextIndex + 1)
            {
                DataSourceContext.ContextItems.RemoveAt(DataSourceContext.ContextItems.Count - 1);
            }

            DataSourceContext.ContextItems.Add(item);
        }
Example #6
0
        public static string GetImageBasedOnContext(this IRokredListChildDataSource val, bool isSelected)
        {
            var result = string.Empty;

            if (val is CategoryVmi)
            {
                result = isSelected ? "category-icon-selected.svg" : "category-icon.svg";
            }
            if (val is SubjectVmi)
            {
                result = isSelected ? "subject-icon-selected.svg" : "subject-icon.svg";
            }
            if (val is OpinionVmi)
            {
                result = isSelected ? "opinion-icon-selected.svg" : "opinion-icon.svg";
            }

            return(result);
        }
Example #7
0
        public static IRokredListChildView CreateDynamicListItem(this IRokredListChildDataSource val, bool isSelected)
        {
            IRokredListChildView result;

            if (val is CategoryVmi)
            {
                result = new CategoryListItem(val as CategoryVmi);
            }
            else if (val is SubjectVmi)
            {
                result = new SubjectListItem(val as SubjectVmi);
            }
            else if (val is OpinionVmi)
            {
                result = new OpinionListItem(val as OpinionVmi);
            }
            else
            {
                throw new NotImplementedException();
            }

            result.SetHasChevron(false);
            return(result);
        }
Example #8
0
 protected BaseViewModel(IRokredListChildDataSource currentContext = null)
 {
     _currentContext = currentContext;
     Initialize();
 }
Example #9
0
        public static View CreateBreadcrumbView(this IRokredListChildDataSource context, ICommand command = null)
        {
            //if there is no command, this is the outside most view
            var mainStackLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal, Spacing = 0,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Fill
            };

            var insideView = new RoundedView {
                CornerRadius = 5
            };

            // this stack contains the bordered text of the item plus the chevron
            var insideStack = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Spacing     = 0, VerticalOptions = LayoutOptions.Center
            };

            var label = new RokredLabel
            {
                FontSize        = 16, IsBold = true,
                Margin          = new Thickness(15, 5, 15, 5),
                VerticalOptions = LayoutOptions.Center
            };
            var chevron = new SvgCachedImage
            {
                Source = "chevron-dark.svg", WidthRequest = 10, HeightRequest = 15,
                Margin = new Thickness(15, 5, 0, 5)
            };

            if (context is CategoryVmi category)
            {
                insideView.BackgroundColor = Color.White;
                label.TextColor            = Color.Black;
                label.Text     = category.Name;
                label.Margin   = new Thickness(5, 5, 10, 5);
                label.FontSize = 12;

                // category has an icon
                var categoryIcon = new SvgCachedImage
                {
                    WidthRequest = 15, HeightRequest = 20, Margin = new Thickness(10, 5, 5, 5),
                    Source       = context.GetImageBasedOnContext(false)
                };

                insideStack.Children.Add(categoryIcon);
            }
            else if (context is SubjectVmi)
            {
                insideView.BackgroundColor = Color.FromHex("4A44F2");
                label.TextColor            = Color.White;
                label.Text = "S";
            }
            else if (context is OpinionVmi && !(context as OpinionVmi).IsDirty)
            {
                insideView.BackgroundColor = Color.FromHex("F2BE22");
                label.TextColor            = Color.Black;
                label.Text = "O";
            }
            else if (context is OpinionVmi && (context as OpinionVmi).IsDirty)
            {
                chevron.IsVisible = false;
                label.IsVisible   = false;

                insideView.BackgroundColor = Color.Transparent;

                var star = new SvgCachedImage
                {
                    Source = "star-icon.svg", WidthRequest = 35, HeightRequest = 35,
                    Margin = new Thickness(0, 0, 0, 0)
                };

                insideStack.Children.Add(star);
            }

            insideStack.Children.Add(label);

            mainStackLayout.HorizontalOptions = LayoutOptions.Start;
            mainStackLayout.VerticalOptions   = LayoutOptions.Center;
            mainStackLayout.Margin            = new Thickness(10);

            insideView.Content = insideStack;
            mainStackLayout.Children.Add(insideView);
            mainStackLayout.Children.Add(chevron);

            if (command != null)
            {
                var button = new RokredButton();
                button.Content          = mainStackLayout;
                button.Command          = command;
                button.CommandParameter = context;

                return(button);
            }

            return(mainStackLayout);
        }
Example #10
0
 public DynamicListItem(IRokredListChildDataSource data)
 {
     BoundDataSource = data;
 }
Example #11
0
        protected void BoundDataSourceChanged(IRokredListChildDataSource val)
        {
            var view = val.CreateDynamicListItem(true);

            Content = view as View;
        }