private View TabItem(string title, ImageSource iconActive, ImageSource iconInactive, HomeViewModel.View view) { var iconSize = Sizes.Title; var iconNotSelected = new SvgCachedImage { Scale = Sizes.TabIconScale, Source = iconInactive, Aspect = Aspect.AspectFit, }; Utils.Accessibility.Unused(iconNotSelected); iconNotSelected.SetBinding(IsVisibleProperty, nameof(ViewModel.CurrentView), converter: new ValueConverterGroup() { new ViewToBooleanConverter(view), new InvertedBooleanConverter(), }); var iconSelected = new SvgCachedImage { Scale = Sizes.TabIconScale, Source = iconActive, Aspect = Aspect.AspectFit, IsVisible = false, }; Utils.Accessibility.Unused(iconSelected); iconSelected.SetBinding(IsVisibleProperty, nameof(ViewModel.CurrentView), converter: new ViewToBooleanConverter(view)); var lblTab = new Label { HorizontalOptions = LayoutOptions.Center, FontSize = Sizes.TextMicro, TextColor = Colors.TabPanelForeground, Margin = new Thickness(-20, 0), MaxLines = 1, LineBreakMode = LineBreakMode.NoWrap, Text = title, }; Utils.Accessibility.Unused(lblTab); lblTab.SetBinding(Label.TextColorProperty, nameof(ViewModel.CurrentView), converter: new ValueConverterGroup() { new ViewToBooleanConverter(view), new BooleanToColorConverter(Colors.TextSpecial, Colors.TabPanelForeground), }); var layout = new Grid() { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Center, Padding = new Thickness(0, 14f), RowSpacing = 2f, RowDefinitions = new RowDefinitionCollection() { new RowDefinition() { Height = iconSize }, new RowDefinition() { Height = GridLength.Auto }, }, Children = { { iconNotSelected, 0, 0 }, { iconSelected, 0, 0 }, { lblTab, 0, 1 }, } }; layout.AddTouchCommand(new Binding(nameof(HomeViewModel.ChangeView)), view); Utils.Accessibility.InUse(layout, title, $"Velger {title}"); return(layout); }
public ViewToBooleanConverter(HomeViewModel.View trueView) { _trueView = trueView; }