1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-26 12:16:07 +01:00

positioning. extended switch cell.

This commit is contained in:
Kyle Spearrin 2016-05-18 23:55:30 -04:00
parent 383a49b75c
commit 54652e639b
10 changed files with 103 additions and 15 deletions

View File

@ -197,6 +197,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\ExtendedEditorRenderer.cs" />
<Compile Include="Controls\ExtendedSwitchCellRenderer.cs" />
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
<Compile Include="Controls\ExtendedTextCellRenderer.cs" />
<Compile Include="Controls\ExtendedPickerRenderer.cs" />

View File

@ -0,0 +1,42 @@
using Android.Content;
using System.ComponentModel;
using Android.Views;
using Bit.Android.Controls;
using Bit.App.Controls;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using AView = Android.Views.View;
[assembly: ExportRenderer(typeof(ExtendedSwitchCell), typeof(ExtendedSwitchCellRenderer))]
namespace Bit.Android.Controls
{
public class ExtendedSwitchCellRenderer : SwitchCellRenderer
{
protected AView View { get; private set; }
protected override AView GetCellCore(Cell item, AView convertView, ViewGroup parent, Context context)
{
var View = base.GetCellCore(item, convertView, parent, context);
var extendedCell = (ExtendedSwitchCell)item;
if(View != null)
{
View.SetBackgroundColor(extendedCell.BackgroundColor.ToAndroid());
}
return View;
}
protected override void OnCellPropertyChanged(object sender, PropertyChangedEventArgs args)
{
base.OnCellPropertyChanged(sender, args);
var cell = (ExtendedSwitchCell)Cell;
if(args.PropertyName == ExtendedSwitchCell.BackgroundColorProperty.PropertyName)
{
View.SetBackgroundColor(cell.BackgroundColor.ToAndroid());
}
}
}
}

View File

@ -52,6 +52,7 @@
<Compile Include="Controls\ExtendedPicker.cs" />
<Compile Include="Controls\ExtendedEntry.cs" />
<Compile Include="Controls\ExtendedTabbedPage.cs" />
<Compile Include="Controls\ExtendedSwitchCell.cs" />
<Compile Include="Controls\ExtendedViewCell.cs" />
<Compile Include="Controls\FormEditorCell.cs" />
<Compile Include="Controls\ExtendedTextCell.cs" />

View File

@ -0,0 +1,16 @@
using Xamarin.Forms;
namespace Bit.App.Controls
{
public class ExtendedSwitchCell : SwitchCell
{
public static readonly BindableProperty BackgroundColorProperty =
BindableProperty.Create(nameof(BackgroundColor), typeof(Color), typeof(ExtendedSwitchCell), Color.White);
public Color BackgroundColor
{
get { return (Color)GetValue(BackgroundColorProperty); }
set { SetValue(BackgroundColorProperty, value); }
}
}
}

View File

@ -18,8 +18,7 @@ namespace Bit.App.Controls
{
Keyboard = entryKeyboard,
HasBorder = false,
VerticalOptions = LayoutOptions.CenterAndExpand,
Margin = new Thickness(0, 5, 0, 0)
VerticalOptions = LayoutOptions.CenterAndExpand
};
var stackLayout = new StackLayout

View File

@ -19,8 +19,7 @@ namespace Bit.App.Controls
Picker = new ExtendedPicker
{
HasBorder = false,
VerticalOptions = LayoutOptions.CenterAndExpand,
Margin = new Thickness(0, 5, 0, 0)
VerticalOptions = LayoutOptions.CenterAndExpand
};
foreach(var item in pickerItems)

View File

@ -40,7 +40,7 @@ namespace Bit.App.Controls
Text = valueText,
LineBreakMode = LineBreakMode.TailTruncation,
VerticalOptions = LayoutOptions.CenterAndExpand,
Margin = new Thickness(0, 5, 0, 0)
TextColor = Color.FromHex("333333")
};
labelValueStackLayout.Children.Add(Value);

View File

@ -23,40 +23,44 @@ namespace Bit.App.Pages
private void Init()
{
var touchIdCell = new SwitchCell
var touchIdCell = new ExtendedSwitchCell
{
Text = "Use Touch ID"
};
touchIdCell.Tapped += TouchIdCell_Tapped;
touchIdCell.OnChanged += TouchIdCell_Changed;
var lockOnExitCell = new SwitchCell
var lockOnExitCell = new ExtendedSwitchCell
{
Text = "Lock Immediately On Exit"
};
lockOnExitCell.Tapped += LockOnExitCell_Tapped;
lockOnExitCell.OnChanged += LockOnExitCell_Changed;
var changeMasterPasswordCell = new ExtendedTextCell
{
Text = "Change Master Password"
Text = "Change Master Password",
TextColor = Color.FromHex("333333")
};
changeMasterPasswordCell.Tapped += ChangeMasterPasswordCell_Tapped;
var foldersCell = new ExtendedTextCell
{
Text = "Folders",
ShowDisclousure = true
ShowDisclousure = true,
TextColor = Color.FromHex("333333")
};
foldersCell.Tapped += FoldersCell_Tapped;
var lockCell = new ExtendedTextCell
{
Text = "Lock"
Text = "Lock",
TextColor = Color.FromHex("333333")
};
lockCell.Tapped += LockCell_Tapped;
var logOutCell = new ExtendedTextCell
{
Text = "Log Out"
Text = "Log Out",
TextColor = Color.FromHex("333333")
};
logOutCell.Tapped += LogOutCell_Tapped;
@ -109,7 +113,7 @@ namespace Bit.App.Pages
Application.Current.MainPage = new LoginNavigationPage();
}
private void LockOnExitCell_Tapped(object sender, EventArgs e)
private void LockOnExitCell_Changed(object sender, EventArgs e)
{
}
@ -124,7 +128,7 @@ namespace Bit.App.Pages
Device.OpenUri(new Uri("https://vault.bitwarden.com"));
}
private void TouchIdCell_Tapped(object sender, EventArgs e)
private void TouchIdCell_Changed(object sender, EventArgs e)
{
}

View File

@ -0,0 +1,25 @@
using Bit.App.Controls;
using Bit.iOS.Controls;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(ExtendedSwitchCell), typeof(ExtendedSwitchCellRenderer))]
namespace Bit.iOS.Controls
{
public class ExtendedSwitchCellRenderer : SwitchCellRenderer
{
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
var extendedCell = (ExtendedSwitchCell)item;
var cell = base.GetCell(item, reusableCell, tv);
if(cell != null)
{
cell.BackgroundColor = extendedCell.BackgroundColor.ToUIColor();
}
return cell;
}
}
}

View File

@ -102,6 +102,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="Controls\ContentPageRenderer.cs" />
<Compile Include="Controls\ExtendedSwitchCellRenderer.cs" />
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
<Compile Include="Controls\ExtendedTextCellRenderer.cs" />
<Compile Include="Controls\ExtendedTableViewRenderer.cs" />