From ea968913a6a5d9c0fa37ae37807dab58a35fe7ad Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Mon, 7 Aug 2023 10:19:19 -0700 Subject: [PATCH] Center floor levels correctly on Windows Works around layout inconsistencies in Maui --- .../FloorFilter.DefaultTemplates.cs | 395 +++++++++--------- 1 file changed, 199 insertions(+), 196 deletions(-) diff --git a/src/Toolkit/Toolkit.Maui/FloorFilter/FloorFilter.DefaultTemplates.cs b/src/Toolkit/Toolkit.Maui/FloorFilter/FloorFilter.DefaultTemplates.cs index 054fb8db3..997e6f823 100644 --- a/src/Toolkit/Toolkit.Maui/FloorFilter/FloorFilter.DefaultTemplates.cs +++ b/src/Toolkit/Toolkit.Maui/FloorFilter/FloorFilter.DefaultTemplates.cs @@ -1,197 +1,200 @@ -// /******************************************************************************* -// * Copyright 2012-2018 Esri -// * -// * Licensed under the Apache License, Version 2.0 (the "License"); -// * you may not use this file except in compliance with the License. -// * You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// ******************************************************************************/ - -namespace Esri.ArcGISRuntime.Toolkit.Maui; - -public partial class FloorFilter -{ - private static readonly DataTemplate DefaultLevelDataTemplate; - private static readonly DataTemplate DefaultFacilityDataTemplate; - private static readonly DataTemplate DefaultSiteDataTemplate; - private static readonly DataTemplate DefaultDifferentiatingFacilityDataTemplate; - private static readonly ControlTemplate DefaultControlTemplate; - - static FloorFilter() - { - DefaultLevelDataTemplate = new DataTemplate(() => - { - Grid containingGrid = new Grid - { - WidthRequest = 48, - HeightRequest = 48, - InputTransparent = false, - CascadeInputTransparent = false, - }; - containingGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(48) }); - Label textLabel = new Label - { - FontSize = 14, - VerticalTextAlignment = TextAlignment.Center, - HorizontalTextAlignment = TextAlignment.Center, - HorizontalOptions = LayoutOptions.Fill, - VerticalOptions = LayoutOptions.Fill, - InputTransparent = false, - }; - textLabel.SetBinding(Label.TextProperty, "ShortName"); - containingGrid.Children.Add(textLabel); - return containingGrid; - }); - - DefaultFacilityDataTemplate = new DataTemplate(() => - { - Grid containingGrid = new Grid(); - containingGrid.SetAppThemeColor(Grid.BackgroundColorProperty, Color.FromArgb("#FFF"), Color.FromArgb("#353535")); - - Label textLabel = new Label - { - FontSize = 14, - VerticalTextAlignment = TextAlignment.Center, - Margin = new Thickness(8), - HorizontalOptions = LayoutOptions.Fill - }; - textLabel.SetBinding(Label.TextProperty, "Name"); - textLabel.SetAppThemeColor(Label.TextColorProperty, Color.FromArgb("#6e6e6e"), Color.FromArgb("#fff")); - - containingGrid.Children.Add(textLabel); - return containingGrid; - }); - - DefaultSiteDataTemplate = DefaultFacilityDataTemplate; - - DefaultDifferentiatingFacilityDataTemplate = new DataTemplate(() => - { - Grid containingGrid = new Grid - { - Padding = new Thickness(8), - }; - containingGrid.SetAppThemeColor(Grid.BackgroundColorProperty, Color.FromArgb("#FFF"), Color.FromArgb("#353535")); - - containingGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); - containingGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); - containingGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); - - Grid textStack = new Grid - { - VerticalOptions = LayoutOptions.Center, - RowSpacing = 2, - }; - - textStack.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); - textStack.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); - - Label titleLabel = new Label - { - FontAttributes = FontAttributes.Bold, - VerticalOptions = LayoutOptions.End, - VerticalTextAlignment = TextAlignment.End, - FontSize = 14, - }; - titleLabel.SetAppThemeColor(Label.TextColorProperty, Color.FromArgb("#6e6e6e"), Color.FromArgb("#fff")); - titleLabel.SetBinding(Label.TextProperty, "Name"); - - Label subtitleLabel = new Label - { - FontSize = 11, - VerticalTextAlignment = TextAlignment.Start, - VerticalOptions = LayoutOptions.Start, - }; - subtitleLabel.SetAppThemeColor(Label.TextColorProperty, Color.FromArgb("#2e2e2e"), Color.FromArgb("#aaa")); - subtitleLabel.SetBinding(Label.TextProperty, "Site.Name"); - - textStack.Children.Add(titleLabel); - textStack.Children.Add(subtitleLabel); - Grid.SetRow(titleLabel, 0); - Grid.SetRow(subtitleLabel, 1); - - containingGrid.Children.Add(textStack); - - Grid.SetColumn(textStack, 1); - return containingGrid; - }); - - string template = -$@" - - - - - - - - - - - - - - - -