mirror of
https://github.com/bitwarden/mobile
synced 2025-12-10 21:33:36 +00:00
Android styles and theme, updated to extended controls
This commit is contained in:
@@ -224,6 +224,15 @@
|
||||
<Name>App</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\values-v21\styles.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\values\styles.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\values\colors.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<Import Project="..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace Bit.Android.Controls
|
||||
}
|
||||
|
||||
SetBorder(view);
|
||||
SetPlaceholderTextColor(view);
|
||||
SetMaxLength(view);
|
||||
}
|
||||
|
||||
@@ -36,14 +35,10 @@ namespace Bit.Android.Controls
|
||||
|
||||
if(e.PropertyName == ExtendedEntry.HasBorderProperty.PropertyName
|
||||
|| e.PropertyName == ExtendedEntry.HasOnlyBottomBorderProperty.PropertyName
|
||||
|| e.PropertyName == ExtendedEntry.BorderColorProperty.PropertyName)
|
||||
|| e.PropertyName == ExtendedEntry.BottomBorderColorProperty.PropertyName)
|
||||
{
|
||||
SetBorder(view);
|
||||
}
|
||||
if(e.PropertyName == ExtendedEntry.PlaceholderTextColorProperty.PropertyName)
|
||||
{
|
||||
SetPlaceholderTextColor(view);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnElementPropertyChanged(sender, e);
|
||||
@@ -63,13 +58,5 @@ namespace Bit.Android.Controls
|
||||
{
|
||||
Control.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(view.MaxLength) });
|
||||
}
|
||||
|
||||
private void SetPlaceholderTextColor(ExtendedEntry view)
|
||||
{
|
||||
if(view.PlaceholderTextColor != Xamarin.Forms.Color.Default)
|
||||
{
|
||||
Control.SetHintTextColor(view.PlaceholderTextColor.ToAndroid());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Bit.Android" android:versionCode="1" android:versionName="0.0.1" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="23" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<application android:label="bitwarden" android:theme="@android:style/Theme.Material.Light.DarkActionBar"></application>
|
||||
<application android:label="bitwarden" android:theme="@style/BitwardenTheme"></application>
|
||||
</manifest>
|
||||
66
src/Android/Resources/Resource.Designer.cs
generated
66
src/Android/Resources/Resource.Designer.cs
generated
@@ -1166,32 +1166,32 @@ namespace Bit.Android
|
||||
public partial class Color
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f0b0048
|
||||
public const int abc_background_cache_hint_selector_material_dark = 2131427400;
|
||||
// aapt resource value: 0x7f0b004d
|
||||
public const int abc_background_cache_hint_selector_material_dark = 2131427405;
|
||||
|
||||
// aapt resource value: 0x7f0b0049
|
||||
public const int abc_background_cache_hint_selector_material_light = 2131427401;
|
||||
// aapt resource value: 0x7f0b004e
|
||||
public const int abc_background_cache_hint_selector_material_light = 2131427406;
|
||||
|
||||
// aapt resource value: 0x7f0b004a
|
||||
public const int abc_color_highlight_material = 2131427402;
|
||||
// aapt resource value: 0x7f0b004f
|
||||
public const int abc_color_highlight_material = 2131427407;
|
||||
|
||||
// aapt resource value: 0x7f0b0004
|
||||
public const int abc_input_method_navigation_guard = 2131427332;
|
||||
|
||||
// aapt resource value: 0x7f0b004b
|
||||
public const int abc_primary_text_disable_only_material_dark = 2131427403;
|
||||
// aapt resource value: 0x7f0b0050
|
||||
public const int abc_primary_text_disable_only_material_dark = 2131427408;
|
||||
|
||||
// aapt resource value: 0x7f0b004c
|
||||
public const int abc_primary_text_disable_only_material_light = 2131427404;
|
||||
// aapt resource value: 0x7f0b0051
|
||||
public const int abc_primary_text_disable_only_material_light = 2131427409;
|
||||
|
||||
// aapt resource value: 0x7f0b004d
|
||||
public const int abc_primary_text_material_dark = 2131427405;
|
||||
// aapt resource value: 0x7f0b0052
|
||||
public const int abc_primary_text_material_dark = 2131427410;
|
||||
|
||||
// aapt resource value: 0x7f0b004e
|
||||
public const int abc_primary_text_material_light = 2131427406;
|
||||
// aapt resource value: 0x7f0b0053
|
||||
public const int abc_primary_text_material_light = 2131427411;
|
||||
|
||||
// aapt resource value: 0x7f0b004f
|
||||
public const int abc_search_url_text = 2131427407;
|
||||
// aapt resource value: 0x7f0b0054
|
||||
public const int abc_search_url_text = 2131427412;
|
||||
|
||||
// aapt resource value: 0x7f0b0005
|
||||
public const int abc_search_url_text_normal = 2131427333;
|
||||
@@ -1202,11 +1202,14 @@ namespace Bit.Android
|
||||
// aapt resource value: 0x7f0b0007
|
||||
public const int abc_search_url_text_selected = 2131427335;
|
||||
|
||||
// aapt resource value: 0x7f0b0050
|
||||
public const int abc_secondary_text_material_dark = 2131427408;
|
||||
// aapt resource value: 0x7f0b0055
|
||||
public const int abc_secondary_text_material_dark = 2131427413;
|
||||
|
||||
// aapt resource value: 0x7f0b0051
|
||||
public const int abc_secondary_text_material_light = 2131427409;
|
||||
// aapt resource value: 0x7f0b0056
|
||||
public const int abc_secondary_text_material_light = 2131427414;
|
||||
|
||||
// aapt resource value: 0x7f0b004c
|
||||
public const int accent = 2131427404;
|
||||
|
||||
// aapt resource value: 0x7f0b0008
|
||||
public const int accent_material_dark = 2131427336;
|
||||
@@ -1262,6 +1265,9 @@ namespace Bit.Android
|
||||
// aapt resource value: 0x7f0b0003
|
||||
public const int cardview_shadow_start_color = 2131427331;
|
||||
|
||||
// aapt resource value: 0x7f0b0049
|
||||
public const int darkgray = 2131427401;
|
||||
|
||||
// aapt resource value: 0x7f0b003e
|
||||
public const int design_fab_shadow_end_color = 2131427390;
|
||||
|
||||
@@ -1310,6 +1316,9 @@ namespace Bit.Android
|
||||
// aapt resource value: 0x7f0b001b
|
||||
public const int foreground_material_light = 2131427355;
|
||||
|
||||
// aapt resource value: 0x7f0b004a
|
||||
public const int gray = 2131427402;
|
||||
|
||||
// aapt resource value: 0x7f0b001c
|
||||
public const int highlighted_text_material_dark = 2131427356;
|
||||
|
||||
@@ -1358,6 +1367,9 @@ namespace Bit.Android
|
||||
// aapt resource value: 0x7f0b002b
|
||||
public const int material_grey_900 = 2131427371;
|
||||
|
||||
// aapt resource value: 0x7f0b004b
|
||||
public const int primary = 2131427403;
|
||||
|
||||
// aapt resource value: 0x7f0b002c
|
||||
public const int primary_dark_material_dark = 2131427372;
|
||||
|
||||
@@ -1406,11 +1418,11 @@ namespace Bit.Android
|
||||
// aapt resource value: 0x7f0b003b
|
||||
public const int switch_thumb_disabled_material_light = 2131427387;
|
||||
|
||||
// aapt resource value: 0x7f0b0052
|
||||
public const int switch_thumb_material_dark = 2131427410;
|
||||
// aapt resource value: 0x7f0b0057
|
||||
public const int switch_thumb_material_dark = 2131427415;
|
||||
|
||||
// aapt resource value: 0x7f0b0053
|
||||
public const int switch_thumb_material_light = 2131427411;
|
||||
// aapt resource value: 0x7f0b0058
|
||||
public const int switch_thumb_material_light = 2131427416;
|
||||
|
||||
// aapt resource value: 0x7f0b003c
|
||||
public const int switch_thumb_normal_material_dark = 2131427388;
|
||||
@@ -1418,6 +1430,9 @@ namespace Bit.Android
|
||||
// aapt resource value: 0x7f0b003d
|
||||
public const int switch_thumb_normal_material_light = 2131427389;
|
||||
|
||||
// aapt resource value: 0x7f0b0048
|
||||
public const int white = 2131427400;
|
||||
|
||||
static Color()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
@@ -3610,6 +3625,9 @@ namespace Bit.Android
|
||||
// aapt resource value: 0x7f0a015b
|
||||
public const int Base_Widget_Design_TabLayout = 2131362139;
|
||||
|
||||
// aapt resource value: 0x7f0a0172
|
||||
public const int BitwardenTheme = 2131362162;
|
||||
|
||||
// aapt resource value: 0x7f0a0017
|
||||
public const int CardView = 2131361815;
|
||||
|
||||
|
||||
9
src/Android/Resources/values-v21/styles.xml
Normal file
9
src/Android/Resources/values-v21/styles.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<resources>
|
||||
<style name="BitwardenTheme" parent="android:Theme.Material.Light.DarkActionBar">
|
||||
<item name="android:colorPrimary">@color/primary</item>
|
||||
<item name="android:textColorPrimary">@color/darkgray</item>
|
||||
<item name="android:colorAccent">@color/accent</item>
|
||||
<item name="android:windowBackground">@color/white</item>
|
||||
</style>
|
||||
</resources>
|
||||
8
src/Android/Resources/values/colors.xml
Normal file
8
src/Android/Resources/values/colors.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<resources>
|
||||
<color name="white">#FFFFFF</color>
|
||||
<color name="darkgray">#333333</color>
|
||||
<color name="gray">#738182</color>
|
||||
<color name="primary">#222d32</color>
|
||||
<color name="accent">#3c8dbc</color>
|
||||
</resources>
|
||||
9
src/Android/Resources/values/styles.xml
Normal file
9
src/Android/Resources/values/styles.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<resources>
|
||||
<style name="BitwardenTheme" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||
<item name="android:colorPrimary">@color/primary</item>
|
||||
<item name="android:textColorPrimary">@color/darkgray</item>
|
||||
<item name="android:colorAccent">@color/accent</item>
|
||||
<item name="android:windowBackground">@color/white</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -46,6 +46,7 @@
|
||||
<Compile Include="Behaviors\RequiredValidationBehavior.cs" />
|
||||
<Compile Include="Controls\EntryLabel.cs" />
|
||||
<Compile Include="Controls\BottomBorderEntry.cs" />
|
||||
<Compile Include="Controls\ExtendedPicker.cs" />
|
||||
<Compile Include="Controls\ExtendedEntry.cs" />
|
||||
<Compile Include="Controls\ExtendedTabbedPage.cs" />
|
||||
<Compile Include="Models\Api\ApiError.cs" />
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Bit.App.Controls
|
||||
public BottomBorderEntry()
|
||||
{
|
||||
HasBorder = HasOnlyBottomBorder = true;
|
||||
BorderColor = Color.FromHex("d2d6de");
|
||||
BottomBorderColor = Color.FromHex("d2d6de");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,8 @@ namespace Bit.App.Controls
|
||||
public static readonly BindableProperty HasOnlyBottomBorderProperty =
|
||||
BindableProperty.Create(nameof(HasOnlyBottomBorder), typeof(bool), typeof(ExtendedEntry), false);
|
||||
|
||||
public static readonly BindableProperty BorderColorProperty =
|
||||
BindableProperty.Create(nameof(BorderColor), typeof(Color), typeof(ExtendedEntry), Color.Default);
|
||||
|
||||
public static readonly BindableProperty PlaceholderTextColorProperty =
|
||||
BindableProperty.Create(nameof(PlaceholderTextColor), typeof(Color), typeof(ExtendedEntry), Color.Default);
|
||||
public static readonly BindableProperty BottomBorderColorProperty =
|
||||
BindableProperty.Create(nameof(BottomBorderColor), typeof(Color), typeof(ExtendedEntry), Color.Default);
|
||||
|
||||
public static readonly BindableProperty MaxLengthProperty =
|
||||
BindableProperty.Create(nameof(MaxLength), typeof(int), typeof(ExtendedEntry), int.MaxValue);
|
||||
@@ -32,16 +29,10 @@ namespace Bit.App.Controls
|
||||
set { SetValue(HasOnlyBottomBorderProperty, value); }
|
||||
}
|
||||
|
||||
public Color BorderColor
|
||||
public Color BottomBorderColor
|
||||
{
|
||||
get { return (Color)GetValue(BorderColorProperty); }
|
||||
set { SetValue(BorderColorProperty, value); }
|
||||
}
|
||||
|
||||
public Color PlaceholderTextColor
|
||||
{
|
||||
get { return (Color)GetValue(PlaceholderTextColorProperty); }
|
||||
set { SetValue(PlaceholderTextColorProperty, value); }
|
||||
get { return (Color)GetValue(BottomBorderColorProperty); }
|
||||
set { SetValue(BottomBorderColorProperty, value); }
|
||||
}
|
||||
|
||||
public int MaxLength
|
||||
|
||||
35
src/App/Controls/ExtendedPicker.cs
Normal file
35
src/App/Controls/ExtendedPicker.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Controls
|
||||
{
|
||||
public class ExtendedPicker : Picker
|
||||
{
|
||||
public static readonly BindableProperty HasBorderProperty =
|
||||
BindableProperty.Create(nameof(HasBorder), typeof(bool), typeof(ExtendedEntry), true);
|
||||
|
||||
public static readonly BindableProperty HasOnlyBottomBorderProperty =
|
||||
BindableProperty.Create(nameof(HasOnlyBottomBorder), typeof(bool), typeof(ExtendedEntry), false);
|
||||
|
||||
public static readonly BindableProperty BottomBorderColorProperty =
|
||||
BindableProperty.Create(nameof(BottomBorderColor), typeof(Color), typeof(ExtendedEntry), Color.Default);
|
||||
|
||||
public bool HasBorder
|
||||
{
|
||||
get { return (bool)GetValue(HasBorderProperty); }
|
||||
set { SetValue(HasBorderProperty, value); }
|
||||
}
|
||||
|
||||
public bool HasOnlyBottomBorder
|
||||
{
|
||||
get { return (bool)GetValue(HasOnlyBottomBorderProperty); }
|
||||
set { SetValue(HasOnlyBottomBorderProperty, value); }
|
||||
}
|
||||
|
||||
public Color BottomBorderColor
|
||||
{
|
||||
get { return (Color)GetValue(BottomBorderColorProperty); }
|
||||
set { SetValue(BottomBorderColorProperty, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Acr.UserDialogs;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Controls;
|
||||
using Bit.App.Resources;
|
||||
using Plugin.Connectivity.Abstractions;
|
||||
using Xamarin.Forms;
|
||||
@@ -34,6 +35,14 @@ namespace Bit.App.Pages
|
||||
|
||||
var stackLayout = new StackLayout { };
|
||||
stackLayout.Children.Add( syncButton );
|
||||
stackLayout.Children.Add( new ExtendedEntry
|
||||
{
|
||||
BottomBorderColor = Color.Black,
|
||||
HasBorder = true,
|
||||
HasOnlyBottomBorder = true,
|
||||
Placeholder = "Some placeholder",
|
||||
PlaceholderColor = Color.Red
|
||||
} );
|
||||
|
||||
Title = "Sync";
|
||||
Content = stackLayout;
|
||||
|
||||
@@ -34,7 +34,12 @@ namespace Bit.App.Pages
|
||||
|
||||
var uriEntry = new BottomBorderEntry { Keyboard = Keyboard.Url };
|
||||
var nameEntry = new BottomBorderEntry();
|
||||
var folderPicker = new Picker { Title = AppResources.Folder };
|
||||
var folderPicker = new ExtendedPicker
|
||||
{
|
||||
Title = AppResources.Folder,
|
||||
BottomBorderColor = Color.FromHex( "d2d6de" ),
|
||||
HasOnlyBottomBorder = true
|
||||
};
|
||||
folderPicker.Items.Add( AppResources.FolderNone );
|
||||
folderPicker.SelectedIndex = 0;
|
||||
foreach( var folder in folders )
|
||||
@@ -43,20 +48,20 @@ namespace Bit.App.Pages
|
||||
}
|
||||
var usernameEntry = new BottomBorderEntry();
|
||||
var passwordEntry = new BottomBorderEntry { IsPassword = true };
|
||||
var notesEditor = new Editor();
|
||||
var notesEditor = new Editor { HeightRequest = 75 };
|
||||
|
||||
var stackLayout = new StackLayout { Padding = new Thickness( 15 ) };
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.URI } );
|
||||
stackLayout.Children.Add( uriEntry );
|
||||
stackLayout.Children.Add(new EntryLabel { Text = AppResources.Name });
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Name, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||
stackLayout.Children.Add( nameEntry );
|
||||
stackLayout.Children.Add(new EntryLabel { Text = AppResources.Folder });
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Folder, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||
stackLayout.Children.Add( folderPicker );
|
||||
stackLayout.Children.Add(new EntryLabel { Text = AppResources.Username });
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Username, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||
stackLayout.Children.Add( usernameEntry );
|
||||
stackLayout.Children.Add(new EntryLabel { Text = AppResources.Password });
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Password, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||
stackLayout.Children.Add( passwordEntry );
|
||||
stackLayout.Children.Add(new EntryLabel { Text = AppResources.Notes });
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Notes, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||
stackLayout.Children.Add( notesEditor );
|
||||
|
||||
var scrollView = new ScrollView
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace Bit.iOS.Controls
|
||||
if(view != null)
|
||||
{
|
||||
SetBorder(view);
|
||||
SetPlaceholderTextColor(view);
|
||||
SetMaxLength(view);
|
||||
}
|
||||
}
|
||||
@@ -35,32 +34,28 @@ namespace Bit.iOS.Controls
|
||||
|
||||
if(e.PropertyName == ExtendedEntry.HasBorderProperty.PropertyName
|
||||
|| e.PropertyName == ExtendedEntry.HasOnlyBottomBorderProperty.PropertyName
|
||||
|| e.PropertyName == ExtendedEntry.BorderColorProperty.PropertyName)
|
||||
|| e.PropertyName == ExtendedEntry.BottomBorderColorProperty.PropertyName)
|
||||
{
|
||||
SetBorder(view);
|
||||
}
|
||||
if(e.PropertyName == ExtendedEntry.PlaceholderTextColorProperty.PropertyName)
|
||||
{
|
||||
SetPlaceholderTextColor(view);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBorder(ExtendedEntry view)
|
||||
{
|
||||
if(view.HasBorder && view.HasOnlyBottomBorder)
|
||||
if(view.HasOnlyBottomBorder)
|
||||
{
|
||||
var borderLayer = new CALayer();
|
||||
borderLayer.MasksToBounds = true;
|
||||
borderLayer.Frame = new CGRect(0f, Frame.Height / 2, Frame.Width, 1f);
|
||||
borderLayer.BorderColor = view.BorderColor.ToCGColor();
|
||||
borderLayer.BorderWidth = 1.0f;
|
||||
borderLayer.Frame = new CGRect(0f, Frame.Height / 2, Frame.Width * 2, 1f);
|
||||
borderLayer.BorderColor = view.BottomBorderColor.ToCGColor();
|
||||
borderLayer.BorderWidth = 1f;
|
||||
|
||||
Control.Layer.AddSublayer(borderLayer);
|
||||
Control.BorderStyle = UITextBorderStyle.None;
|
||||
}
|
||||
else if(view.HasBorder)
|
||||
{
|
||||
Control.BorderStyle = UITextBorderStyle.Line;
|
||||
Control.BorderStyle = UITextBorderStyle.RoundedRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -76,20 +71,5 @@ namespace Bit.iOS.Controls
|
||||
return newLength <= view.MaxLength;
|
||||
};
|
||||
}
|
||||
|
||||
private void SetPlaceholderTextColor(ExtendedEntry view)
|
||||
{
|
||||
if(string.IsNullOrEmpty(view.Placeholder) == false && view.PlaceholderTextColor != Color.Default)
|
||||
{
|
||||
var placeholderString = new NSAttributedString(
|
||||
view.Placeholder,
|
||||
new UIStringAttributes()
|
||||
{
|
||||
ForegroundColor = view.PlaceholderTextColor.ToUIColor()
|
||||
});
|
||||
|
||||
Control.AttributedPlaceholder = placeholderString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
64
src/iOS/Controls/ExtendedPickerRenderer.cs
Normal file
64
src/iOS/Controls/ExtendedPickerRenderer.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Bit.App.Controls;
|
||||
using Bit.iOS.Controls;
|
||||
using CoreAnimation;
|
||||
using CoreGraphics;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.iOS;
|
||||
|
||||
[assembly: ExportRenderer(typeof(ExtendedPicker), typeof( ExtendedPickerRenderer ) )]
|
||||
namespace Bit.iOS.Controls
|
||||
{
|
||||
public class ExtendedPickerRenderer : PickerRenderer
|
||||
{
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
|
||||
var view = e.NewElement as ExtendedPicker;
|
||||
if(view != null)
|
||||
{
|
||||
SetBorder(view);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
base.OnElementPropertyChanged(sender, e);
|
||||
|
||||
var view = (ExtendedPicker)Element;
|
||||
|
||||
if(e.PropertyName == ExtendedPicker.HasBorderProperty.PropertyName
|
||||
|| e.PropertyName == ExtendedPicker.HasOnlyBottomBorderProperty.PropertyName
|
||||
|| e.PropertyName == ExtendedPicker.BottomBorderColorProperty.PropertyName)
|
||||
{
|
||||
SetBorder(view);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBorder( ExtendedPicker view )
|
||||
{
|
||||
if(view.HasOnlyBottomBorder)
|
||||
{
|
||||
var borderLayer = new CALayer();
|
||||
borderLayer.MasksToBounds = true;
|
||||
borderLayer.Frame = new CGRect( 0f, Frame.Height / 2, Frame.Width * 2, 1f );
|
||||
borderLayer.BorderColor = view.BottomBorderColor.ToCGColor();
|
||||
borderLayer.BorderWidth = 1f;
|
||||
|
||||
Control.Layer.AddSublayer( borderLayer );
|
||||
Control.BorderStyle = UITextBorderStyle.None;
|
||||
}
|
||||
else if(view.HasBorder)
|
||||
{
|
||||
Control.BorderStyle = UITextBorderStyle.RoundedRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
Control.BorderStyle = UITextBorderStyle.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,7 @@
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controls\ExtendedPickerRenderer.cs" />
|
||||
<Compile Include="Controls\ExtendedEntryRenderer.cs" />
|
||||
<Compile Include="Controls\ExtendedTabbedPageRenderer.cs" />
|
||||
<Compile Include="Services\ClipboardService.cs" />
|
||||
|
||||
Reference in New Issue
Block a user