mirror of
https://github.com/bitwarden/android.git
synced 2024-12-26 19:08:32 +03:00
PM-3349 Changed the "track color" for the Android switch so that the color is different from the "thumb"
This commit is contained in:
parent
5d2fc4530f
commit
fa4a2247e3
2 changed files with 28 additions and 5 deletions
|
@ -2,7 +2,10 @@
|
|||
using Android.Graphics.Drawables;
|
||||
using Android.OS;
|
||||
using AndroidX.Core.Content.Resources;
|
||||
using AndroidX.Core.Graphics;
|
||||
using Bit.App.Droid.Utilities;
|
||||
using Bit.App.Utilities;
|
||||
using Microsoft.Maui.Platform;
|
||||
|
||||
namespace Bit.App.Handlers
|
||||
{
|
||||
|
@ -37,6 +40,31 @@ namespace Bit.App.Handlers
|
|||
};
|
||||
handler.PlatformView.ThumbTintList = new ColorStateList(thumbStates, thumbColors);
|
||||
});
|
||||
|
||||
Microsoft.Maui.Handlers.SwitchHandler.Mapper.AppendToMapping(nameof(ISwitch.TrackColor), (handler, mauiSwitch) =>
|
||||
{
|
||||
var trackStates = new[]
|
||||
{
|
||||
new[] { Android.Resource.Attribute.StateChecked }, // checked
|
||||
new[] { -Android.Resource.Attribute.StateChecked }, // unchecked
|
||||
};
|
||||
|
||||
var selectedColor = ColorUtils.BlendARGB(ThemeHelpers.SwitchOnColor.ToArgb(), Colors.Black.ToPlatform().ToArgb(), 0.5f);
|
||||
var unselectedColor = ColorUtils.BlendARGB(ThemeHelpers.SwitchThumbColor.ToArgb(), Colors.Black.ToPlatform().ToArgb(), 0.7f);
|
||||
if (ThemeManager.UsingLightTheme)
|
||||
{
|
||||
selectedColor = ColorUtils.BlendARGB(ThemeHelpers.SwitchOnColor.ToArgb(), Colors.White.ToPlatform().ToArgb(), 0.7f);
|
||||
unselectedColor = ColorUtils.BlendARGB(ThemeHelpers.SwitchThumbColor.ToArgb(), Colors.Black.ToPlatform().ToArgb(), 0.3f);
|
||||
}
|
||||
|
||||
var trackColors = new int[]
|
||||
{
|
||||
selectedColor,
|
||||
unselectedColor
|
||||
};
|
||||
|
||||
handler.PlatformView.TrackTintList = new ColorStateList(trackStates, trackColors);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,11 +42,6 @@
|
|||
<Setter Property="Margin"
|
||||
Value="-4, 0, -4, -4" />
|
||||
</Style>
|
||||
<Style TargetType="Switch"
|
||||
ApplyToDerivedTypes="True">
|
||||
<Setter Property="OnColor"
|
||||
Value="{DynamicResource SwitchOnColor}" />
|
||||
</Style>
|
||||
<Style TargetType="SearchBar"
|
||||
ApplyToDerivedTypes="True">
|
||||
<Setter Property="BackgroundColor"
|
||||
|
|
Loading…
Reference in a new issue