mirror of
https://github.com/bitwarden/android.git
synced 2024-12-19 07:41:52 +03:00
positioning. extended switch cell.
This commit is contained in:
parent
383a49b75c
commit
54652e639b
10 changed files with 103 additions and 15 deletions
|
@ -197,6 +197,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Controls\ExtendedEditorRenderer.cs" />
|
<Compile Include="Controls\ExtendedEditorRenderer.cs" />
|
||||||
|
<Compile Include="Controls\ExtendedSwitchCellRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
|
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedTextCellRenderer.cs" />
|
<Compile Include="Controls\ExtendedTextCellRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedPickerRenderer.cs" />
|
<Compile Include="Controls\ExtendedPickerRenderer.cs" />
|
||||||
|
|
42
src/Android/Controls/ExtendedSwitchCellRenderer.cs
Normal file
42
src/Android/Controls/ExtendedSwitchCellRenderer.cs
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,6 +52,7 @@
|
||||||
<Compile Include="Controls\ExtendedPicker.cs" />
|
<Compile Include="Controls\ExtendedPicker.cs" />
|
||||||
<Compile Include="Controls\ExtendedEntry.cs" />
|
<Compile Include="Controls\ExtendedEntry.cs" />
|
||||||
<Compile Include="Controls\ExtendedTabbedPage.cs" />
|
<Compile Include="Controls\ExtendedTabbedPage.cs" />
|
||||||
|
<Compile Include="Controls\ExtendedSwitchCell.cs" />
|
||||||
<Compile Include="Controls\ExtendedViewCell.cs" />
|
<Compile Include="Controls\ExtendedViewCell.cs" />
|
||||||
<Compile Include="Controls\FormEditorCell.cs" />
|
<Compile Include="Controls\FormEditorCell.cs" />
|
||||||
<Compile Include="Controls\ExtendedTextCell.cs" />
|
<Compile Include="Controls\ExtendedTextCell.cs" />
|
||||||
|
|
16
src/App/Controls/ExtendedSwitchCell.cs
Normal file
16
src/App/Controls/ExtendedSwitchCell.cs
Normal 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); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,8 +18,7 @@ namespace Bit.App.Controls
|
||||||
{
|
{
|
||||||
Keyboard = entryKeyboard,
|
Keyboard = entryKeyboard,
|
||||||
HasBorder = false,
|
HasBorder = false,
|
||||||
VerticalOptions = LayoutOptions.CenterAndExpand,
|
VerticalOptions = LayoutOptions.CenterAndExpand
|
||||||
Margin = new Thickness(0, 5, 0, 0)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var stackLayout = new StackLayout
|
var stackLayout = new StackLayout
|
||||||
|
|
|
@ -19,8 +19,7 @@ namespace Bit.App.Controls
|
||||||
Picker = new ExtendedPicker
|
Picker = new ExtendedPicker
|
||||||
{
|
{
|
||||||
HasBorder = false,
|
HasBorder = false,
|
||||||
VerticalOptions = LayoutOptions.CenterAndExpand,
|
VerticalOptions = LayoutOptions.CenterAndExpand
|
||||||
Margin = new Thickness(0, 5, 0, 0)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach(var item in pickerItems)
|
foreach(var item in pickerItems)
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace Bit.App.Controls
|
||||||
Text = valueText,
|
Text = valueText,
|
||||||
LineBreakMode = LineBreakMode.TailTruncation,
|
LineBreakMode = LineBreakMode.TailTruncation,
|
||||||
VerticalOptions = LayoutOptions.CenterAndExpand,
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
||||||
Margin = new Thickness(0, 5, 0, 0)
|
TextColor = Color.FromHex("333333")
|
||||||
};
|
};
|
||||||
|
|
||||||
labelValueStackLayout.Children.Add(Value);
|
labelValueStackLayout.Children.Add(Value);
|
||||||
|
|
|
@ -23,40 +23,44 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
var touchIdCell = new SwitchCell
|
var touchIdCell = new ExtendedSwitchCell
|
||||||
{
|
{
|
||||||
Text = "Use Touch ID"
|
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"
|
Text = "Lock Immediately On Exit"
|
||||||
};
|
};
|
||||||
lockOnExitCell.Tapped += LockOnExitCell_Tapped;
|
lockOnExitCell.OnChanged += LockOnExitCell_Changed;
|
||||||
|
|
||||||
var changeMasterPasswordCell = new ExtendedTextCell
|
var changeMasterPasswordCell = new ExtendedTextCell
|
||||||
{
|
{
|
||||||
Text = "Change Master Password"
|
Text = "Change Master Password",
|
||||||
|
TextColor = Color.FromHex("333333")
|
||||||
};
|
};
|
||||||
changeMasterPasswordCell.Tapped += ChangeMasterPasswordCell_Tapped;
|
changeMasterPasswordCell.Tapped += ChangeMasterPasswordCell_Tapped;
|
||||||
|
|
||||||
var foldersCell = new ExtendedTextCell
|
var foldersCell = new ExtendedTextCell
|
||||||
{
|
{
|
||||||
Text = "Folders",
|
Text = "Folders",
|
||||||
ShowDisclousure = true
|
ShowDisclousure = true,
|
||||||
|
TextColor = Color.FromHex("333333")
|
||||||
};
|
};
|
||||||
foldersCell.Tapped += FoldersCell_Tapped;
|
foldersCell.Tapped += FoldersCell_Tapped;
|
||||||
|
|
||||||
var lockCell = new ExtendedTextCell
|
var lockCell = new ExtendedTextCell
|
||||||
{
|
{
|
||||||
Text = "Lock"
|
Text = "Lock",
|
||||||
|
TextColor = Color.FromHex("333333")
|
||||||
};
|
};
|
||||||
lockCell.Tapped += LockCell_Tapped;
|
lockCell.Tapped += LockCell_Tapped;
|
||||||
|
|
||||||
var logOutCell = new ExtendedTextCell
|
var logOutCell = new ExtendedTextCell
|
||||||
{
|
{
|
||||||
Text = "Log Out"
|
Text = "Log Out",
|
||||||
|
TextColor = Color.FromHex("333333")
|
||||||
};
|
};
|
||||||
logOutCell.Tapped += LogOutCell_Tapped;
|
logOutCell.Tapped += LogOutCell_Tapped;
|
||||||
|
|
||||||
|
@ -109,7 +113,7 @@ namespace Bit.App.Pages
|
||||||
Application.Current.MainPage = new LoginNavigationPage();
|
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"));
|
Device.OpenUri(new Uri("https://vault.bitwarden.com"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TouchIdCell_Tapped(object sender, EventArgs e)
|
private void TouchIdCell_Changed(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
25
src/iOS/Controls/ExtendedSwitchCellRenderer.cs
Normal file
25
src/iOS/Controls/ExtendedSwitchCellRenderer.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -102,6 +102,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Controls\ContentPageRenderer.cs" />
|
<Compile Include="Controls\ContentPageRenderer.cs" />
|
||||||
|
<Compile Include="Controls\ExtendedSwitchCellRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
|
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedTextCellRenderer.cs" />
|
<Compile Include="Controls\ExtendedTextCellRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedTableViewRenderer.cs" />
|
<Compile Include="Controls\ExtendedTableViewRenderer.cs" />
|
||||||
|
|
Loading…
Reference in a new issue