Skip to content

Commit

Permalink
Merge pull request #416 from trimble-oss/414-modus-styling-issue-unab…
Browse files Browse the repository at this point in the history
…le-to-change-the-control-label-text-color

Modus styling issues
  • Loading branch information
amosekr authored Dec 11, 2024
2 parents a20cb63 + 58ad256 commit 0e27828
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 23 deletions.
9 changes: 6 additions & 3 deletions Trimble.Modus.Components/Controls/DropDown/TMDropDown.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
xmlns:local="clr-namespace:Trimble.Modus.Components"
xmlns:constants="clr-namespace:Trimble.Modus.Components.Constant"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="Trimble.Modus.Components.TMDropDown">
x:Class="Trimble.Modus.Components.TMDropDown"
xmlns:converters="clr-namespace:Trimble.Modus.Components.Converters">
<ContentView.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<local:DropDownStyles />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<converters:StringNotNullOrEmptyBoolConverter x:Key="StringNotNullOrEmptyBoolConverter" />
</ResourceDictionary>
</ContentView.Resources>
<VerticalStackLayout BindingContext="{x:Reference dropDown}">
<local:ControlLabel TitleText="{Binding TitleText}"
IsRequired="{Binding IsRequired}" />
IsRequired="{Binding IsRequired}"
IsVisible="{Binding TitleText, Converter={StaticResource StringNotNullOrEmptyBoolConverter}}"/>
<Border x:Name="innerBorder"
HorizontalOptions="Fill"
StrokeThickness="2"
Expand Down
4 changes: 2 additions & 2 deletions Trimble.Modus.Components/Controls/Label/ControlLabel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
</ContentView.Resources>
<Grid x:Name="view"
BindingContext="{x:Reference controlLabelView}"
ColumnSpacing="4"
ColumnDefinitions="*,auto"
ColumnSpacing="6"
ColumnDefinitions="auto,*"
IsVisible="{Binding TitleText,Converter={StaticResource IsStringNotNullOrEmptyConverter}}">
<Label x:Name="inputLabel"
Padding="0,0,0,5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public bool IsReadOnly
public ControlLabel()
{
InitializeComponent();
this.SetDynamicResource(StyleProperty, "DefaultControlLabelStyle");
}

private static void OnHeaderTextColorPropertyChanged(BindableObject bindable, object oldValue, object newValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xmlns:local="clr-namespace:Trimble.Modus.Components;assembly=Trimble.Modus.Components"
x:Class="Trimble.Modus.Components.ControlLabelStyles">
<Style TargetType="local:ControlLabel"
x:Key="Default">
x:Key="DefaultControlLabelStyle">
<Setter Property="HeaderTextColor"
Value="{DynamicResource LabelTextColor}" />
Value="{DynamicResource ControlLabelTextColor}" />
</Style>

</ResourceDictionary>
6 changes: 4 additions & 2 deletions Trimble.Modus.Components/Controls/Popup/Pages/PopupPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,14 @@ private void OnSizeChanged(object sender, EventArgs e)
{
case Enums.ModalPosition.Top:
translationY = loc.Top - _popupHeight - loc.Height / 2;
translationX = loc.Center.X - _popupWidth / 2;
//https://github.com/trimble-oss/modus-mobile-maui-components/issues/415 - the change to fix android dropdown popup misalignment
translationX = loc.X;
break;

case Enums.ModalPosition.Bottom:
translationY = loc.Bottom - _popupHeight + loc.Height / 2;
translationX = loc.Center.X - _popupWidth / 2;
//https://github.com/trimble-oss/modus-mobile-maui-components/issues/415 - the change to fix android dropdown popup misalignment
translationX = loc.X;
break;

case Enums.ModalPosition.Left:
Expand Down
14 changes: 9 additions & 5 deletions Trimble.Modus.Components/Controls/TMInput/BaseInput.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Trimble.Modus.Components"
x:Class="Trimble.Modus.Components.Controls.BaseInput.BaseInput"
xmlns:Modus="clr-namespace:Trimble.Modus.Components">
xmlns:Modus="clr-namespace:Trimble.Modus.Components"
xmlns:converters="clr-namespace:Trimble.Modus.Components.Converters">

<ContentView.Resources>
<ContentView.Resources>

<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<local:TMInputStyles></local:TMInputStyles>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary.MergedDictionaries>
<converters:StringNotNullOrEmptyBoolConverter x:Key="StringNotNullOrEmptyBoolConverter" />
</ResourceDictionary>
<ControlTemplate x:Key="InputTemplate">
<Grid x:Name="tmInputContainer"
Expand All @@ -21,7 +24,8 @@
IsEnabled="{Binding IsEnabled}"
IsReadOnly="{Binding IsReadOnly}"
TitleText="{Binding TitleText}"
IsRequired="{Binding IsRequired}" />
IsRequired="{Binding IsRequired}"
IsVisible="{Binding TitleText, Converter={StaticResource StringNotNullOrEmptyBoolConverter}}"/>
<Border x:Name="inputBorder"
MinimumHeightRequest="48"
VerticalOptions="FillAndExpand"
Expand All @@ -45,7 +49,7 @@
WidthRequest="20"
HeightRequest="20" />
<Label x:Name="inputHelperLabel"
Grid.Column="1"
Grid.Column="1"
FontFamily="OpenSansRegular"
LineBreakMode="WordWrap" />
</Grid>
Expand Down
21 changes: 21 additions & 0 deletions Trimble.Modus.Components/Controls/TMInput/BaseInput.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ public partial class BaseInput : ContentView
public static readonly BindableProperty HelperLayoutBackgroundProperty =
BindableProperty.Create(nameof(HelperLayoutBackground), typeof(Color), typeof(BaseInput), Colors.Transparent,
propertyChanged: OnHelperLayoutBackgroundChanged);

/// <summary>
/// Gets or sets helper text color
/// </summary>
public static readonly BindableProperty HelperTextColorProperty =
BindableProperty.Create(nameof(HelperTextColor), typeof(Color), typeof(BaseInput), Colors.Transparent,
propertyChanged: OnHelperTextColorChanged);
#endregion

#region Public Properties
Expand Down Expand Up @@ -326,6 +333,12 @@ internal Color HelperLayoutBackground
{
get => (Color)GetValue(HelperLayoutBackgroundProperty);
set => SetValue(HelperLayoutBackgroundProperty, value);
}

internal Color HelperTextColor
{
get => (Color)GetValue(HelperTextColorProperty);
set => SetValue(HelperTextColorProperty, value);
}
#endregion
public BaseInput()
Expand Down Expand Up @@ -411,6 +424,14 @@ private static void OnHelperLayoutBackgroundChanged(BindableObject bindable, obj
}
}

private static void OnHelperTextColorChanged(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is BaseInput tmInput)
{
tmInput.HelperLabel.TextColor = tmInput.HelperTextColor;
}
}

private static void OnHelperIconImageChanged(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is BaseInput tmInput)
Expand Down
10 changes: 10 additions & 0 deletions Trimble.Modus.Components/Controls/TMInput/TMInputStyles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
Value="{DynamicResource InputDefaultBackgroundColor}" />
<Setter Property="HelperLayoutBackground"
Value="{DynamicResource InputDefaultHelperLayoutBackgroundColor}" />
<Setter Property="HelperTextColor"
Value="{DynamicResource InputDefaultHelperTextColor}" />
</Style>

<Style TargetType="local:TMInput"
Expand All @@ -30,6 +32,8 @@
Value="{DynamicResource InputDefaultBackgroundColor}" />
<Setter Property="HelperLayoutBackground"
Value="{DynamicResource InputPrimaryHelperLayoutBackgroundColor}" />
<Setter Property="HelperTextColor"
Value="{DynamicResource InputDefaultHelperTextColor}" />
</Style>

<Style TargetType="local:TMInput"
Expand All @@ -44,6 +48,8 @@
Value="{DynamicResource InputDefaultBackgroundColor}" />
<Setter Property="HelperLayoutBackground"
Value="{DynamicResource InputSuccessHelperLayoutBackgroundColor}" />
<Setter Property="HelperTextColor"
Value="{DynamicResource InputDefaultHelperTextColor}" />
</Style>

<Style TargetType="local:TMInput"
Expand All @@ -58,6 +64,8 @@
Value="{DynamicResource InputDefaultBackgroundColor}" />
<Setter Property="HelperLayoutBackground"
Value="{DynamicResource InputErrorHelperLayoutBackgroundColor}" />
<Setter Property="HelperTextColor"
Value="{DynamicResource InputDefaultHelperTextColor}" />
</Style>

<Style TargetType="local:TMInput"
Expand All @@ -72,6 +80,8 @@
Value="{DynamicResource InputReadOnlyBackgroundColor}" />
<Setter Property="HelperLayoutBackground"
Value="{DynamicResource InputReadOnlyHelperLayoutBackgroundColor}" />
<Setter Property="HelperTextColor"
Value="{DynamicResource InputDefaultHelperTextColor}" />
</Style>

</ResourceDictionary>
Expand Down
4 changes: 3 additions & 1 deletion Trimble.Modus.Components/Styles/DarkThemeStyling.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
x:Class="Trimble.Modus.Components.Styles.DarkThemeStyling">

<!--Label-->
<styles:ReferenceColor x:Key="LabelTextColor"
<styles:ReferenceColor x:Key="ControlLabelTextColor"
Color="{StaticResource DefaultTextColor}" />

<!--Button-->
Expand Down Expand Up @@ -496,6 +496,8 @@
Color="{StaticResource SecondaryLight}" />
<styles:ReferenceColor x:Key="InputIconTintColor"
Color="{StaticResource IconDark}" />
<styles:ReferenceColor x:Key="InputDefaultHelperTextColor"
Color="{StaticResource DefaultTextColor}" />

<!--Primary-->
<styles:ReferenceColor x:Key="InputPrimaryBorderColor"
Expand Down
4 changes: 3 additions & 1 deletion Trimble.Modus.Components/Styles/LightThemeStyling.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:styles="clr-namespace:Trimble.Modus.Components.Styles"
x:Class="Trimble.Modus.Components.Styles.LightThemeStyling">
<!--Label-->
<styles:ReferenceColor x:Key="LabelTextColor"
<styles:ReferenceColor x:Key="ControlLabelTextColor"
Color="{StaticResource DefaultTextColor}" />

<!--Button-->
Expand Down Expand Up @@ -491,6 +491,8 @@
Color="{StaticResource SecondaryLight}" />
<styles:ReferenceColor x:Key="InputIconTintColor"
Color="{StaticResource IconLight}" />
<styles:ReferenceColor x:Key="InputDefaultHelperTextColor"
Color="{StaticResource DefaultTextColor}" />

<!--Primary-->
<styles:ReferenceColor x:Key="InputPrimaryBorderColor"
Expand Down
10 changes: 3 additions & 7 deletions Trimble.Modus.Components/Trimble.Modus.Components.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
21.0
</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
10.0.17763.0
</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
10.0.17763.0
</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">
6.5
</SupportedOSPlatformVersion>

<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageId>Trimble.Modus.Components</PackageId>
<Title>Trimbel Modus</Title>
<Version>1.1.2.41</Version>
<Version>1.2.0.8</Version>
<Authors>Trimble Inc</Authors>
<Company>Trimble Inc</Company>
<Product>Trimble.Modus.Components</Product>
Expand Down

0 comments on commit 0e27828

Please sign in to comment.