use black text for search bar on light theme

This commit is contained in:
Kyle Spearrin 2019-10-04 09:32:59 -04:00
parent 4d8c665917
commit a363712127
5 changed files with 35 additions and 4 deletions

View file

@ -0,0 +1,21 @@
using Bit.App.Abstractions;
using Bit.Core.Utilities;
using Xamarin.Forms;
namespace Bit.App.Controls
{
public class ExtendedSearchBar : SearchBar
{
public ExtendedSearchBar()
{
if(Device.RuntimePlatform == Device.iOS)
{
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService", true);
if(!deviceActionService?.UsingDarkTheme() ?? false)
{
TextColor = Color.Black;
}
}
}
}
}

View file

@ -34,7 +34,7 @@
VerticalOptions="CenterAndExpand"
Clicked="BackButton_Clicked"
x:Name="_backButton" />
<SearchBar
<controls:ExtendedSearchBar
x:Name="_searchBar"
HorizontalOptions="FillAndExpand"
TextChanged="SearchBar_TextChanged"

View file

@ -22,7 +22,8 @@
<Setter Property="Margin"
Value="-4, 0, -4, -4" />
</Style>
<Style TargetType="SearchBar">
<Style TargetType="SearchBar"
ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor"
Value="Transparent" />
<Setter Property="TextColor"

View file

@ -35,7 +35,8 @@
<Setter Property="OnColor"
Value="{StaticResource SwitchOnColor}" />
</Style>
<Style TargetType="SearchBar">
<Style TargetType="SearchBar"
ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor"
Value="{StaticResource ListHeaderBackgroundColor}" />
<Setter Property="TextColor"

View file

@ -352,9 +352,17 @@ namespace Bit.iOS.Core.Services
}
public bool UsingDarkTheme()
{
try
{
if(SystemMajorVersion() > 12)
{
return UIScreen.MainScreen.TraitCollection.UserInterfaceStyle == UIUserInterfaceStyle.Dark;
}
}
catch { }
return false;
}
private void ImagePicker_FinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs e)
{