[iOS] fix for SearchBar background color (#4229)
authorAndrei Nitescu <nitescua@yahoo.com>
Tue, 13 Nov 2018 18:00:39 +0000 (20:00 +0200)
committerShane Neuville <shane94@hotmail.com>
Tue, 13 Nov 2018 18:00:39 +0000 (11:00 -0700)
* iOS fix for SearchBar background color

* Update Xamarin.Forms.Controls.Issues.Shared.projitems

* Fix Merge Issues
- fixes #4194

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4194.xaml [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4194.xaml.cs [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.Platform.iOS/Renderers/SearchBarRenderer.cs

diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4194.xaml b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4194.xaml
new file mode 100644 (file)
index 0000000..4281a94
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+                        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+                        x:Class="Xamarin.Forms.Controls.Issues.Issue4194">
+       <StackLayout>
+               <Label Text="On iOS, after clicking the button, the second SearchBar should appear having same color as the first SearchBar, it should not be dark green " />
+               <SearchBar Text="Visible"
+                                  BackgroundColor="Lime" />
+               <SearchBar x:Name="SearchBar1"
+                                  IsVisible="false"
+                                  BackgroundColor="Lime" />
+               <Button Text="Show"
+                               Clicked="Handle_Clicked"
+                               HorizontalOptions="Center"
+                               VerticalOptions="CenterAndExpand" />
+       </StackLayout>
+</ContentPage>
\ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4194.xaml.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4194.xaml.cs
new file mode 100644 (file)
index 0000000..e5b08cf
--- /dev/null
@@ -0,0 +1,25 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+namespace Xamarin.Forms.Controls.Issues
+{
+       [Preserve(AllMembers = true)]
+       [Issue(IssueTracker.Github, 4194, "[iOS] SearchBar changes color if initial state is invisible", PlatformAffected.iOS)]
+
+       public partial class Issue4194 : ContentPage
+       {
+               public Issue4194()
+               {
+#if APP
+                       InitializeComponent();
+#endif
+               }
+
+               void Handle_Clicked(object sender, System.EventArgs e)
+               {
+#if APP
+                       SearchBar1.IsVisible = true;
+#endif
+               }
+       }
+}
\ No newline at end of file
index 2fc8b00..9338633 100644 (file)
       <DependentUpon>Issue3979.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="$(MSBuildThisFileDirectory)Issue4194.xaml.cs">
+      <DependentUpon>Issue4194.xaml</DependentUpon>
+      <SubType>Code</SubType>
+    </Compile>
     <Compile Include="$(MSBuildThisFileDirectory)Issue4136.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue4262.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)LegacyComponents\NonAppCompatSwitch.cs" />
     </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
+    <Folder Include="$(MSBuildThisFileDirectory)Controls\" />
     <EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue2858.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
     </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
-    <Folder Include="$(MSBuildThisFileDirectory)Controls\" />
+    <EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue4194.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
   </ItemGroup>
 </Project>
index 867abe2..4864c3a 100644 (file)
@@ -120,8 +120,7 @@ namespace Xamarin.Forms.Platform.iOS
                        
                        Control.BarTintColor = color.ToUIColor(_defaultTintColor);
 
-                       if (color.A < 1)
-                               Control.SetBackgroundImage(new UIImage(), UIBarPosition.Any, UIBarMetrics.Default);
+                       Control.SetBackgroundImage(new UIImage(), UIBarPosition.Any, UIBarMetrics.Default);
 
                        // updating BarTintColor resets the button color so we need to update the button color again
                        UpdateCancelButton();