mirror of
https://github.com/bitwarden/android.git
synced 2025-01-07 00:37:38 +03:00
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
|
using Android.Content;
|
|||
|
using Bit.App.Controls;
|
|||
|
using Bit.App.Utilities;
|
|||
|
using Bit.Droid.Renderers;
|
|||
|
using Xamarin.Forms;
|
|||
|
using Xamarin.Forms.Platform.Android;
|
|||
|
|
|||
|
[assembly: ExportRenderer(typeof(ExtendedStackLayout), typeof(ExtendedStackLayoutRenderer))]
|
|||
|
namespace Bit.Droid.Renderers
|
|||
|
{
|
|||
|
public class ExtendedStackLayoutRenderer : ViewRenderer
|
|||
|
{
|
|||
|
private static int? _bgResId;
|
|||
|
|
|||
|
public ExtendedStackLayoutRenderer(Context context) : base(context) { }
|
|||
|
|
|||
|
protected override void OnElementChanged(ElementChangedEventArgs<View> elementChangedEvent)
|
|||
|
{
|
|||
|
base.OnElementChanged(elementChangedEvent);
|
|||
|
if (elementChangedEvent.NewElement != null)
|
|||
|
{
|
|||
|
SetBackgroundResource(GetBgResId());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private int GetBgResId()
|
|||
|
{
|
|||
|
if (_bgResId == null)
|
|||
|
{
|
|||
|
if (ThemeManager.GetTheme(true) == "nord")
|
|||
|
{
|
|||
|
_bgResId = Resource.Drawable.list_item_bg_nord;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_bgResId ??= ThemeManager.UsingLightTheme ? Resource.Drawable.list_item_bg :
|
|||
|
Resource.Drawable.list_item_bg_dark;
|
|||
|
}
|
|||
|
}
|
|||
|
return _bgResId.Value;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|