Dynamic theme switching and visual tweaks (#1556)

* Dynamic theme switching and visual tweaks

* update action runner to use macos-11 for iOS 15 support

* additional tweaks

* refinements

* refinements

* formatting and tweaks
This commit is contained in:
Matt Portune 2021-10-08 08:47:40 -04:00 committed by GitHub
parent 73eb3c2c1e
commit 4aad34cd75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 4193 additions and 5433 deletions

View File

@ -330,7 +330,7 @@ jobs:
ios:
name: Apple iOS
runs-on: macos-10.15
runs-on: macos-11
steps:
- name: Print environment
run: |

View File

@ -9,7 +9,7 @@ using Bit.Core.Utilities;
namespace Bit.Droid.Accessibility
{
[Activity(Theme = "@style/LightTheme.Splash", WindowSoftInputMode = SoftInput.StateHidden)]
[Activity(Theme = "@style/BaseTheme", WindowSoftInputMode = SoftInput.StateHidden)]
public class AccessibilityActivity : Activity
{
private DateTime? _lastLaunch = null;

View File

@ -76,11 +76,11 @@
<PackageReference Include="Portable.BouncyCastle">
<Version>1.8.10</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.AutoFill" Version="1.1.0.7" />
<PackageReference Include="Xamarin.AndroidX.CardView" Version="1.0.0.9" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.8" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.5" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.3.1.3" />
<PackageReference Include="Xamarin.AndroidX.AutoFill" Version="1.1.0.9" />
<PackageReference Include="Xamarin.AndroidX.CardView" Version="1.0.0.11" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.10" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.5.2" />
<PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.8" />
<PackageReference Include="Xamarin.Essentials">
<Version>1.7.0</Version>
@ -88,7 +88,7 @@
<PackageReference Include="Xamarin.Firebase.Messaging">
<Version>122.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.4.0.2" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.4.0.4" />
<PackageReference Include="Xamarin.Google.Dagger" Version="2.37.0" />
<PackageReference Include="Xamarin.GooglePlayServices.SafetyNet">
<Version>117.0.1</Version>
@ -122,6 +122,8 @@
<Compile Include="Renderers\ExtendedDatePickerRenderer.cs" />
<Compile Include="Renderers\CustomTabbedRenderer.cs" />
<Compile Include="Renderers\ExtendedStackLayoutRenderer.cs" />
<Compile Include="Renderers\ExtendedStepperRenderer.cs" />
<Compile Include="Renderers\CustomSwitchRenderer.cs" />
<Compile Include="Renderers\ExtendedTimePickerRenderer.cs" />
<Compile Include="Renderers\ExtendedSliderRenderer.cs" />
<Compile Include="Renderers\CustomEditorRenderer.cs" />
@ -144,6 +146,7 @@
<Compile Include="Tiles\MyVaultTileService.cs" />
<Compile Include="Utilities\AndroidHelpers.cs" />
<Compile Include="Utilities\AppCenterHelper.cs" />
<Compile Include="Utilities\ThemeHelpers.cs" />
<Compile Include="WebAuthCallbackActivity.cs" />
</ItemGroup>
<ItemGroup>
@ -171,8 +174,6 @@
<AndroidResource Include="Resources\drawable\id.xml" />
<AndroidResource Include="Resources\drawable\info.xml" />
<AndroidResource Include="Resources\drawable\list_item_bg.xml" />
<AndroidResource Include="Resources\drawable\list_item_bg_dark.xml" />
<AndroidResource Include="Resources\drawable\list_item_bg_nord.xml" />
<AndroidResource Include="Resources\drawable\lock.xml" />
<AndroidResource Include="Resources\drawable\login.xml" />
<AndroidResource Include="Resources\drawable\logo.xml" />
@ -185,6 +186,7 @@
<AndroidResource Include="Resources\drawable\shield.xml" />
<AndroidResource Include="Resources\drawable-v23\splash_screen.xml" />
<AndroidResource Include="Resources\drawable-v23\splash_screen_dark.xml" />
<AndroidResource Include="Resources\drawable\switch_thumb.xml" />
<AndroidResource Include="Resources\layout\Tabbar.axml" />
<AndroidResource Include="Resources\layout\Toolbar.axml" />
<AndroidResource Include="Resources\mipmap-anydpi-v26\ic_launcher.xml" />

View File

@ -1,6 +1,6 @@
using Android.Graphics.Drawables;
using Bit.App.Utilities;
using Bit.Droid.Effects;
using Bit.Droid.Utilities;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
@ -14,7 +14,7 @@ namespace Bit.Droid.Effects
if (Control is Android.Widget.Button button)
{
var gd = new GradientDrawable();
gd.SetColor(ThemeManager.GetResourceColor("FabColor").ToAndroid());
gd.SetColor(ThemeHelpers.FabColor);
gd.SetCornerRadius(100);
button.SetBackground(gd);

View File

@ -15,9 +15,9 @@ using Bit.Droid.Receivers;
using Bit.App.Models;
using Bit.Core.Enums;
using Android.Nfc;
using Bit.App.Utilities;
using System.Threading.Tasks;
using AndroidX.Core.Content;
using Bit.App.Utilities;
using ZXing.Net.Mobile.Android;
namespace Bit.Droid
@ -30,7 +30,7 @@ namespace Bit.Droid
LaunchMode = LaunchMode.SingleTask,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation |
ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden |
ConfigChanges.Navigation)]
ConfigChanges.Navigation | ConfigChanges.UiMode)]
[IntentFilter(
new[] { Intent.ActionSend },
Categories = new[] { Intent.CategoryDefault },
@ -81,7 +81,6 @@ namespace Bit.Droid
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
UpdateTheme(ThemeManager.GetTheme(true));
base.OnCreate(savedInstanceState);
if (!CoreHelpers.InDebugMode())
{
@ -118,7 +117,7 @@ namespace Bit.Droid
}
else if (message.Command == "updatedTheme")
{
RestartApp();
Xamarin.Forms.Device.BeginInvokeOnMainThread(() => AppearanceAdjustments());
}
else if (message.Command == "exit")
{
@ -141,6 +140,7 @@ namespace Bit.Droid
{
base.OnResume();
Xamarin.Essentials.Platform.OnResume();
AppearanceAdjustments();
if (_deviceActionService.SupportsNfc())
{
try
@ -382,45 +382,10 @@ namespace Bit.Droid
}
}
private void UpdateTheme(string theme)
private void AppearanceAdjustments()
{
if (theme == "light")
{
SetTheme(Resource.Style.LightTheme);
}
else if (theme == "dark")
{
SetTheme(Resource.Style.DarkTheme);
}
else if (theme == "black")
{
SetTheme(Resource.Style.BlackTheme);
}
else if (theme == "nord")
{
SetTheme(Resource.Style.NordTheme);
}
else
{
if (_deviceActionService.UsingDarkTheme())
{
SetTheme(Resource.Style.DarkTheme);
}
else
{
SetTheme(Resource.Style.LightTheme);
}
}
}
private void RestartApp()
{
var intent = new Intent(this, typeof(MainActivity));
var pendingIntent = PendingIntent.GetActivity(this, 5923650, intent, PendingIntentFlags.CancelCurrent);
var alarmManager = GetSystemService(AlarmService) as AlarmManager;
var triggerMs = Java.Lang.JavaSystem.CurrentTimeMillis() + 500;
alarmManager.Set(AlarmType.Rtc, triggerMs, pendingIntent);
Java.Lang.JavaSystem.Exit(0);
Window?.SetStatusBarColor(ThemeHelpers.NavBarBackgroundColor);
ThemeHelpers.SetAppearance(ThemeManager.GetTheme(true), ThemeManager.OsDarkModeEnabled());
}
private void ExitApp()

View File

@ -1,6 +1,9 @@
using Android.Content;
using System.ComponentModel;
using Android.Content;
using Android.Content.Res;
using Android.Views.InputMethods;
using Bit.Droid.Renderers;
using Bit.Droid.Utilities;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
@ -25,6 +28,7 @@ namespace Bit.Droid.Renderers
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
{
base.OnElementChanged(e);
UpdateBorderColor();
if (Control != null && e.NewElement != null)
{
Control.SetPadding(Control.PaddingLeft, Control.PaddingTop - 10, Control.PaddingRight,
@ -33,5 +37,33 @@ namespace Bit.Droid.Renderers
(ImeAction)ImeFlags.NoExtractUi;
}
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == Entry.TextColorProperty.PropertyName)
{
UpdateBorderColor();
}
}
private void UpdateBorderColor()
{
if (Control != null)
{
var states = new[]
{
new[] { Android.Resource.Attribute.StateFocused }, // focused
new[] { -Android.Resource.Attribute.StateFocused }, // unfocused
};
var colors = new int[]
{
ThemeHelpers.PrimaryColor,
ThemeHelpers.MutedColor
};
Control.BackgroundTintList = new ColorStateList(states, colors);
}
}
}
}

View File

@ -1,10 +1,12 @@
using System.ComponentModel;
using Android.Content;
using Android.Content.Res;
using Android.Graphics;
using Android.Text;
using Android.Views.InputMethods;
using Android.Widget;
using Bit.Droid.Renderers;
using Bit.Droid.Utilities;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
@ -20,6 +22,7 @@ namespace Bit.Droid.Renderers
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
UpdateBorderColor();
if (Control != null && e.NewElement != null)
{
Control.SetPadding(Control.PaddingLeft, Control.PaddingTop - 10, Control.PaddingRight,
@ -68,6 +71,28 @@ namespace Bit.Droid.Renderers
}
}
}
else if (e.PropertyName == Entry.TextColorProperty.PropertyName)
{
UpdateBorderColor();
}
}
private void UpdateBorderColor()
{
if (Control != null)
{
var states = new[]
{
new[] { Android.Resource.Attribute.StateFocused }, // focused
new[] { -Android.Resource.Attribute.StateFocused }, // unfocused
};
var colors = new int[]
{
ThemeHelpers.PrimaryColor,
ThemeHelpers.MutedColor
};
Control.BackgroundTintList = new ColorStateList(states, colors);
}
}
}
}

View File

@ -1,5 +1,8 @@
using Android.Content;
using System.ComponentModel;
using Android.Content;
using Android.Content.Res;
using Bit.Droid.Renderers;
using Bit.Droid.Utilities;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
@ -15,11 +18,40 @@ namespace Bit.Droid.Renderers
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
UpdateBorderColor();
if (Control != null && e.NewElement != null)
{
Control.SetPadding(Control.PaddingLeft, Control.PaddingTop - 10, Control.PaddingRight,
Control.PaddingBottom + 20);
}
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == Picker.TextColorProperty.PropertyName)
{
UpdateBorderColor();
}
}
private void UpdateBorderColor()
{
if (Control != null)
{
var states = new[]
{
new[] { Android.Resource.Attribute.StateFocused }, // focused
new[] { -Android.Resource.Attribute.StateFocused }, // unfocused
};
var colors = new int[]
{
ThemeHelpers.PrimaryColor,
ThemeHelpers.MutedColor
};
Control.BackgroundTintList = new ColorStateList(states, colors);
}
}
}
}

View File

@ -0,0 +1,59 @@
using System.ComponentModel;
using Android.Content;
using Android.Content.Res;
using Android.Graphics.Drawables;
using AndroidX.Core.Content.Resources;
using Bit.Droid.Renderers;
using Bit.Droid.Utilities;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(Switch), typeof(CustomSwitchRenderer))]
namespace Bit.Droid.Renderers
{
public class CustomSwitchRenderer : SwitchRenderer
{
public CustomSwitchRenderer(Context context)
: base(context)
{}
protected override void OnElementChanged(ElementChangedEventArgs<Switch> e)
{
base.OnElementChanged(e);
UpdateColors();
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == Switch.OnColorProperty.PropertyName)
{
UpdateColors();
}
}
private void UpdateColors()
{
if (Control != null)
{
var t = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.switch_thumb, null);
if (t is GradientDrawable thumb)
{
Control.ThumbDrawable = thumb;
}
var thumbStates = new[]
{
new[] { Android.Resource.Attribute.StateChecked }, // checked
new[] { -Android.Resource.Attribute.StateChecked }, // unchecked
};
var thumbColors = new int[]
{
ThemeHelpers.SwitchOnColor,
ThemeHelpers.SwitchThumbColor
};
Control.ThumbTintList = new ColorStateList(thumbStates, thumbColors);
}
}
}
}

View File

@ -1,6 +1,5 @@
using Android.Content;
using Bit.App.Controls;
using Bit.App.Utilities;
using Bit.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
@ -10,8 +9,6 @@ namespace Bit.Droid.Renderers
{
public class ExtendedGridRenderer : ViewRenderer
{
private static int? _bgResId;
public ExtendedGridRenderer(Context context) : base(context) { }
protected override void OnElementChanged(ElementChangedEventArgs<View> elementChangedEvent)
@ -19,25 +16,8 @@ namespace Bit.Droid.Renderers
base.OnElementChanged(elementChangedEvent);
if (elementChangedEvent.NewElement != null)
{
SetBackgroundResource(GetBgResId());
SetBackgroundResource(Resource.Drawable.list_item_bg);
}
}
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;
}
}
}

View File

@ -1,4 +1,5 @@
using Android.Content;
using System.ComponentModel;
using Android.Content;
using Android.Graphics.Drawables;
using AndroidX.Core.Content.Resources;
using Bit.App.Controls;
@ -18,6 +19,21 @@ namespace Bit.Droid.Renderers
protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
{
base.OnElementChanged(e);
UpdateColor();
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == ExtendedSlider.ThumbBorderColorProperty.PropertyName)
{
UpdateColor();
}
}
private void UpdateColor()
{
if (Control != null && Element is ExtendedSlider view)
{
var t = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.slider_thumb, null);

View File

@ -1,6 +1,5 @@
using Android.Content;
using Bit.App.Controls;
using Bit.App.Utilities;
using Bit.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
@ -10,8 +9,6 @@ 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)
@ -19,25 +16,8 @@ namespace Bit.Droid.Renderers
base.OnElementChanged(elementChangedEvent);
if (elementChangedEvent.NewElement != null)
{
SetBackgroundResource(GetBgResId());
SetBackgroundResource(Resource.Drawable.list_item_bg);
}
}
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;
}
}
}

View File

@ -0,0 +1,72 @@
using System.ComponentModel;
using Android.Content;
using Android.Graphics;
using Android.OS;
using Bit.App.Controls;
using Bit.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(ExtendedStepper), typeof(ExtendedStepperRenderer))]
namespace Bit.Droid.Renderers
{
public class ExtendedStepperRenderer : StepperRenderer
{
public ExtendedStepperRenderer(Context context)
: base(context)
{}
protected override void OnElementChanged(ElementChangedEventArgs<Stepper> e)
{
base.OnElementChanged(e);
UpdateBgColor();
UpdateFgColor();
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == ExtendedStepper.StepperBackgroundColorProperty.PropertyName)
{
UpdateBgColor();
}
else if (e.PropertyName == ExtendedStepper.StepperForegroundColorProperty.PropertyName)
{
UpdateFgColor();
}
}
private void UpdateBgColor()
{
if (Control != null && Element is ExtendedStepper view)
{
if (Build.VERSION.SdkInt >= BuildVersionCodes.Q)
{
Control.GetChildAt(0)?.Background?.SetColorFilter(
new BlendModeColorFilter(view.StepperBackgroundColor.ToAndroid(), BlendMode.Multiply));
Control.GetChildAt(1)?.Background?.SetColorFilter(
new BlendModeColorFilter(view.StepperBackgroundColor.ToAndroid(), BlendMode.Multiply));
}
else
{
Control.GetChildAt(0)?.Background?.SetColorFilter(
view.StepperBackgroundColor.ToAndroid(), PorterDuff.Mode.Multiply);
Control.GetChildAt(1)?.Background?.SetColorFilter(
view.StepperBackgroundColor.ToAndroid(), PorterDuff.Mode.Multiply);
}
}
}
private void UpdateFgColor()
{
if (Control != null && Element is ExtendedStepper view)
{
var btn0 = Control.GetChildAt(0) as Android.Widget.Button;
btn0?.SetTextColor(view.StepperForegroundColor.ToAndroid());
var btn1 = Control.GetChildAt(1) as Android.Widget.Button;
btn1?.SetTextColor(view.StepperForegroundColor.ToAndroid());
}
}
}
}

View File

@ -6,7 +6,7 @@ TODO: When API 23 becomes our new minimum, replace 'splash_screen.xml' in 'drawa
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/lightgray"/>
<color android:color="@color/white"/>
</item>
<item
android:drawable="@drawable/logo"

View File

@ -1,5 +1,5 @@
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/itemPressed">
android:color="#8E8E93">
<item
android:id="@android:id/mask"

View File

@ -1,7 +0,0 @@
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/dark_primary">
<item
android:id="@android:id/mask"
android:drawable="@android:color/white" />
</ripple>

View File

@ -1,7 +0,0 @@
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/nord_primary">
<item
android:id="@android:id/mask"
android:drawable="@android:color/white" />
</ripple>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/lightgray"/>
<color android:color="@color/white"/>
</item>
<item>
<bitmap android:src="@drawable/logo_legacy" android:tileMode="disabled" android:gravity="center"/>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<solid android:color="@color/white"/>
<size android:width="20dp" android:height="20dp"/>
</shape>

View File

@ -1,8 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<!-- Launch theme (for auto dark/light based on system) -->
<style name="LaunchTheme" parent="DarkTheme.Base">
<style name="LaunchTheme" parent="BaseTheme">
<item name="android:windowBackground">@drawable/splash_screen_dark</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="BaseTheme" parent="Theme.AppCompat">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimaryDark">@color/dark_notificationBar</item>
<item name="colorAccent">@color/dark_primary</item>
<item name="colorControlNormal">@color/dark_border</item>
<item name="android:navigationBarColor">@color/dark_navigationBarBackground</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:colorActivatedHighlight">@android:color/transparent</item>
<item name="android:textCursorDrawable">@null</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat</item>
<item name="buttonStyle">@style/ButtonStyle</item>
</style>
<style name="ButtonStyle" parent="Widget.AppCompat.Button">
<item name="android:textAllCaps">false</item>
</style>
</resources>

View File

@ -1,38 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Light theme -->
<!-- Light System -->
<color name="colorPrimary">#175DDC</color>
<color name="colorPrimaryDark">#1A3B66</color>
<color name="primary">#175DDC</color>
<color name="notificationBar">#1452BC</color>
<color name="border">#dddddd</color>
<color name="itemPressed">#bbbbbb</color>
<!-- Dark theme -->
<!-- Dark System -->
<color name="dark_primary">#52bdfb</color>
<color name="dark_notificationBar">#191919</color>
<color name="dark_border">#191919</color>
<color name="dark_border">#666666</color>
<color name="dark_navigationBarBackground">#191919</color>
<!-- Black theme -->
<color name="black_border">#282828</color>
<!-- Nord theme -->
<color name="nord_background">#3b4252</color>
<color name="nord_text">#e5e9f0</color>
<color name="nord_primary">#81a1c1</color>
<color name="nord_actionBar">#2e3440</color>
<color name="nord_actionBarText">#e5e9f0</color>
<color name="nord_notificationBar">#20242D</color>
<color name="nord_dialogBackground">#3b4252</color>
<color name="nord_border">#2e3440</color>
<color name="nord_popupBackground">#4c566a</color>
<color name="nord_popupText">#e5e9f0</color>
<color name="nord_buttonBackground">#4c566a</color>
<color name="nord_navigationBarBackground">#20242D</color>
<!-- Other -->
<color name="launcher_background">#FFFFFF</color>
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
<color name="darkgray">#333333</color>

View File

@ -1,21 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>
<!-- Launch theme (for auto dark/light based on system) -->
<style name="LaunchTheme" parent="LightTheme.Base">
<style name="LaunchTheme" parent="BaseTheme">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
</style>
<!-- Light theme -->
<style name="LightTheme" parent="LightTheme.Base">
</style>
<style name="LightTheme.Splash" parent="LightTheme.Base">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="LightTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="BaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/primary</item>
@ -27,70 +18,10 @@
<item name="android:colorActivatedHighlight">@android:color/transparent</item>
<item name="android:textCursorDrawable">@null</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="buttonStyle">@style/ButtonStyle</item>
</style>
<!-- Dark theme -->
<style name="DarkTheme" parent="DarkTheme.Base">
</style>
<style name="DarkTheme.Splash" parent="DarkTheme.Base">
<item name="android:windowBackground">@drawable/splash_screen_dark</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="DarkTheme.Base" parent="Theme.AppCompat">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimaryDark">@color/dark_notificationBar</item>
<item name="colorAccent">@color/dark_primary</item>
<item name="colorControlNormal">@color/dark_border</item>
<item name="android:navigationBarColor">@color/dark_navigationBarBackground</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:colorActivatedHighlight">@android:color/transparent</item>
<item name="android:textCursorDrawable">@null</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat</item>
</style>
<!-- Black theme -->
<style name="BlackTheme" parent="BlackTheme.Base">
</style>
<style name="BlackTheme.Splash" parent="DarkTheme.Splash">
</style>
<style name="BlackTheme.Base" parent="DarkTheme.Base">
<item name="android:windowBackground">@android:color/black</item>
<item name="colorPrimary">@android:color/black</item>
<item name="colorPrimaryDark">@android:color/black</item>
<item name="colorControlNormal">@color/black_border</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
<!-- Nord theme -->
<style name="NordTheme" parent="NordTheme.Base">
</style>
<style name="NordTheme.Splash" parent="DarkTheme.Splash">
</style>
<style name="NordTheme.Base" parent="DarkTheme.Base">
<item name="android:windowBackground">@color/nord_background</item>
<item name="android:actionMenuTextColor">@color/nord_actionBarText</item>
<item name="android:textColor">@color/nord_text</item>
<item name="colorAccent">@color/nord_primary</item>
<item name="colorPrimary">@color/nord_actionBar</item>
<item name="colorPrimaryDark">@color/nord_notificationBar</item>
<item name="colorControlNormal">@color/nord_border</item>
<item name="android:navigationBarColor">@color/nord_navigationBarBackground</item>
<item name="colorBackgroundFloating">@color/nord_dialogBackground</item>
<item name="android:colorBackgroundFloating" tools:targetApi="23">@color/nord_dialogBackground</item>
<item name="popupTheme">@style/NordTheme.Popup</item>
<item name="colorButtonNormal">@color/nord_buttonBackground</item>
<item name="android:colorButtonNormal">@color/nord_buttonBackground</item>
</style>
<style name="NordTheme.Popup" parent="ThemeOverlay.AppCompat">
<item name="android:colorBackground">@color/nord_popupBackground</item>
<item name="android:textColor">@color/nord_popupText</item>
</style>
<style name="ButtonStyle" parent="Widget.AppCompat.Button">
<item name="android:textAllCaps">false</item>
</style>
</resources>

View File

@ -8,7 +8,6 @@ using Android.App;
using Android.App.Assist;
using Android.Content;
using Android.Content.PM;
using Android.Content.Res;
using Android.Nfc;
using Android.OS;
using Android.Provider;
@ -641,18 +640,11 @@ namespace Bit.Droid.Services
public bool AutofillAccessibilityServiceRunning()
{
try
{
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
var manager = activity.GetSystemService(Context.ActivityService) as ActivityManager;
var services = manager.GetRunningServices(int.MaxValue);
return services.Any(s => s.Process.ToLowerInvariant().Contains("bitwarden") &&
s.Service.ClassName.ToLowerInvariant().Contains("accessibilityservice"));
}
catch
{
return false;
}
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
var enabledServices = Settings.Secure.GetString(activity.ContentResolver,
Settings.Secure.EnabledAccessibilityServices);
return Application.Context.PackageName != null &&
(enabledServices?.Contains(Application.Context.PackageName) ?? false);
}
public bool AutofillAccessibilityOverlayPermitted()
@ -741,21 +733,6 @@ namespace Bit.Droid.Services
}
}
public bool UsingDarkTheme()
{
try
{
if (Build.VERSION.SdkInt >= BuildVersionCodes.Q)
{
var app = CrossCurrentActivity.Current.AppContext;
var uiModeFlags = app.Resources.Configuration.UiMode & UiMode.NightMask;
return uiModeFlags == UiMode.NightYes;
}
}
catch { }
return false;
}
public long GetActiveTime()
{
// Returns milliseconds since the system was booted, and includes deep sleep. This clock is guaranteed to

View File

@ -0,0 +1,67 @@
using Android.Graphics;
using Bit.App.Utilities;
using Xamarin.Forms.Platform.Android;
namespace Bit.Droid.Utilities
{
public class ThemeHelpers
{
public static bool LightTheme = true;
public static Color PrimaryColor
{
get => ThemeManager.GetResourceColor("PrimaryColor").ToAndroid();
}
public static Color MutedColor
{
get => ThemeManager.GetResourceColor("MutedColor").ToAndroid();
}
public static Color NavBarBackgroundColor
{
get => ThemeManager.GetResourceColor("NavigationBarBackgroundColor").ToAndroid();
}
public static Color FabColor
{
get => ThemeManager.GetResourceColor("FabColor").ToAndroid();
}
public static Color SwitchOnColor
{
get => ThemeManager.GetResourceColor("SwitchOnColor").ToAndroid();
}
public static Color SwitchThumbColor
{
get => ThemeManager.GetResourceColor("SwitchThumbColor").ToAndroid();
}
public static void SetAppearance(string theme, bool osDarkModeEnabled)
{
SetThemeVariables(theme, osDarkModeEnabled);
}
public static int GetDialogTheme()
{
if (LightTheme)
{
return Android.Resource.Style.ThemeMaterialLightDialog;
}
return Android.Resource.Style.ThemeMaterialDialog;
}
private static void SetThemeVariables(string theme, bool osDarkModeEnabled)
{
if (string.IsNullOrWhiteSpace(theme) && osDarkModeEnabled)
{
theme = "dark";
}
if (theme == "dark" || theme == "black" || theme == "nord")
{
LightTheme = false;
}
else
{
LightTheme = true;
}
}
}
}

View File

@ -42,7 +42,6 @@ namespace Bit.App.Abstractions
void OpenAccessibilitySettings();
void OpenAccessibilityOverlayPermissionSettings();
void OpenAutofillSettings();
bool UsingDarkTheme();
long GetActiveTime();
void CloseMainApp();
bool SupportsFido2();

View File

@ -200,6 +200,7 @@ namespace Bit.App
private async void ResumedAsync()
{
UpdateTheme();
await _vaultTimeoutService.CheckVaultTimeoutAsync();
_messagingService.Send("startEventTimer");
await ClearCacheIfNeededAsync();
@ -337,6 +338,10 @@ namespace Bit.App
InitializeComponent();
SetCulture();
ThemeManager.SetTheme(Device.RuntimePlatform == Device.Android, Current.Resources);
Current.RequestedThemeChanged += (s, a) =>
{
UpdateTheme();
};
Current.MainPage = new HomePage();
var mainPageTask = SetMainPageAsync();
ServiceContainer.Resolve<MobilePlatformUtilsService>("platformUtilsService").Init();
@ -359,6 +364,15 @@ namespace Bit.App
});
}
private void UpdateTheme()
{
Device.BeginInvokeOnMainThread(() =>
{
ThemeManager.SetTheme(Device.RuntimePlatform == Device.Android, Current.Resources);
_messagingService.Send("updatedTheme");
});
}
private async Task LockedAsync(bool autoPromptBiometric)
{
await _stateService.PurgeAsync();

View File

@ -5,7 +5,7 @@ namespace Bit.App.Controls
public class ExtendedSlider : Slider
{
public static readonly BindableProperty ThumbBorderColorProperty = BindableProperty.Create(
nameof(ThumbBorderColor), typeof(Color), typeof(ExtendedSlider), Color.Gray);
nameof(ThumbBorderColor), typeof(Color), typeof(ExtendedSlider), Color.Default);
public Color ThumbBorderColor
{

View File

@ -0,0 +1,25 @@
using Xamarin.Forms;
namespace Bit.App.Controls
{
public class ExtendedStepper : Stepper
{
public static readonly BindableProperty StepperBackgroundColorProperty = BindableProperty.Create(
nameof(StepperBackgroundColor), typeof(Color), typeof(ExtendedStepper), Color.Default);
public static readonly BindableProperty StepperForegroundColorProperty = BindableProperty.Create(
nameof(StepperForegroundColor), typeof(Color), typeof(ExtendedStepper), Color.Default);
public Color StepperBackgroundColor
{
get => (Color)GetValue(StepperBackgroundColorProperty);
set => SetValue(StepperBackgroundColorProperty, value);
}
public Color StepperForegroundColor
{
get => (Color)GetValue(StepperForegroundColorProperty);
set => SetValue(StepperForegroundColorProperty, value);
}
}
}

View File

@ -40,11 +40,12 @@
HorizontalTextAlignment="Center"></Label>
<StackLayout Spacing="5">
<Button Text="{u:I18n LogIn}"
Clicked="LogIn_Clicked"></Button>
StyleClass="btn-primary"
Clicked="LogIn_Clicked" />
<Button Text="{u:I18n CreateAccount}"
Clicked="Register_Clicked"></Button>
Clicked="Register_Clicked" />
<Button Text="{u:I18n LogInSso}"
Clicked="LogInSso_Clicked"></Button>
Clicked="LogInSso_Clicked" />
</StackLayout>
</StackLayout>
</StackLayout>

View File

@ -13,11 +13,13 @@ namespace Bit.App.Pages
private readonly HomeViewModel _vm;
private readonly AppOptions _appOptions;
private IMessagingService _messagingService;
private IBroadcasterService _broadcasterService;
public HomePage(AppOptions appOptions = null)
{
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
_messagingService.Send("showStatusBar", false);
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
_appOptions = appOptions;
InitializeComponent();
_vm = BindingContext as HomeViewModel;
@ -26,7 +28,7 @@ namespace Bit.App.Pages
_vm.StartRegisterAction = () => Device.BeginInvokeOnMainThread(async () => await StartRegisterAsync());
_vm.StartSsoLoginAction = () => Device.BeginInvokeOnMainThread(async () => await StartSsoLoginAsync());
_vm.StartEnvironmentAction = () => Device.BeginInvokeOnMainThread(async () => await StartEnvironmentAsync());
_logo.Source = !ThemeManager.UsingLightTheme ? "logo_white.png" : "logo.png";
UpdateLogo();
}
public async Task DismissRegisterPageAndLogInAsync(string email)
@ -39,6 +41,27 @@ namespace Bit.App.Pages
{
base.OnAppearing();
_messagingService.Send("showStatusBar", false);
_broadcasterService.Subscribe(nameof(HomePage), async (message) =>
{
if (message.Command == "updatedTheme")
{
Device.BeginInvokeOnMainThread(() =>
{
UpdateLogo();
});
}
});
}
protected override void OnDisappearing()
{
base.OnDisappearing();
_broadcasterService.Unsubscribe(nameof(HomePage));
}
private void UpdateLogo()
{
_logo.Source = !ThemeManager.UsingLightTheme ? "logo_white.png" : "logo.png";
}
private void Close_Clicked(object sender, EventArgs e)

View File

@ -120,7 +120,9 @@
IsVisible="{Binding BiometricIntegrityValid, Converter={StaticResource inverseBool}}" />
<Button Text="{Binding BiometricButtonText}" Clicked="Biometric_Clicked"
IsVisible="{Binding BiometricButtonVisible}"></Button>
<Button Text="{u:I18n Unlock}" Clicked="Unlock_Clicked"></Button>
<Button Text="{u:I18n Unlock}"
StyleClass="btn-primary"
Clicked="Unlock_Clicked" />
</StackLayout>
</StackLayout>
</ScrollView>

View File

@ -82,7 +82,9 @@
</Grid>
</StackLayout>
<StackLayout Padding="10, 0">
<Button Text="{u:I18n LogIn}" Clicked="LogIn_Clicked" />
<Button Text="{u:I18n LogIn}"
StyleClass="btn-primary"
Clicked="LogIn_Clicked" />
</StackLayout>
</StackLayout>
</ScrollView>

View File

@ -37,7 +37,8 @@
</StackLayout>
<StackLayout Padding="10, 0">
<Button Text="{u:I18n LogIn}"
Clicked="LogIn_Clicked"></Button>
StyleClass="btn-primary"
Clicked="LogIn_Clicked"></Button>
</StackLayout>
</StackLayout>
</ScrollView>

View File

@ -4,6 +4,7 @@ using Bit.Core.Utilities;
using System;
using System.Threading.Tasks;
using Bit.App.Abstractions;
using Bit.App.Utilities;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
@ -52,7 +53,8 @@ namespace Bit.App.Pages
{
IsRunning = true,
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.Center
HorizontalOptions = LayoutOptions.Center,
Color = ThemeManager.GetResourceColor("PrimaryColor"),
};
if (targetView != null)
{

View File

@ -71,6 +71,7 @@
HorizontalOptions="CenterAndExpand"
LineBreakMode="CharacterWrap" />
<Button Text="{u:I18n RegeneratePassword}"
StyleClass="btn-primary"
HorizontalOptions="FillAndExpand"
Clicked="Regenerate_Clicked"></Button>
<Button Text="{u:I18n CopyPassword}"
@ -108,7 +109,7 @@
HorizontalTextAlignment="End"
VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center" />
<Stepper
<controls:ExtendedStepper
Value="{Binding NumWords}"
Maximum="20"
Minimum="3"
@ -239,7 +240,7 @@
HorizontalTextAlignment="End"
VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center" />
<Stepper
<controls:ExtendedStepper
Value="{Binding MinNumber}"
Maximum="5"
Minimum="0"
@ -259,7 +260,7 @@
HorizontalTextAlignment="End"
VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center" />
<Stepper
<controls:ExtendedStepper
Value="{Binding MinSpecial}"
Maximum="5"
Minimum="0"

View File

@ -1,6 +1,8 @@
using Bit.App.Resources;
using System;
using System.Threading.Tasks;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
@ -9,6 +11,8 @@ namespace Bit.App.Pages
{
public partial class GeneratorPage : BaseContentPage
{
private readonly IBroadcasterService _broadcasterService;
private GeneratorPageViewModel _vm;
private readonly bool _fromTabPage;
private readonly Action<string> _selectAction;
@ -18,6 +22,7 @@ namespace Bit.App.Pages
{
_tabsPage = tabsPage;
InitializeComponent();
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
_vm = BindingContext as GeneratorPageViewModel;
_vm.Page = this;
_fromTabPage = fromTabPage;
@ -60,6 +65,22 @@ namespace Bit.App.Pages
{
await InitAsync();
}
_broadcasterService.Subscribe(nameof(GeneratorPage), async (message) =>
{
if (message.Command == "updatedTheme")
{
Device.BeginInvokeOnMainThread(() =>
{
_vm.RedrawPassword();
});
}
});
}
protected override void OnDisappearing()
{
base.OnDisappearing();
_broadcasterService.Unsubscribe(nameof(GeneratorPage));
}
protected override bool OnBackButtonPressed()

View File

@ -262,6 +262,14 @@ namespace Bit.App.Pages
await _passwordGenerationService.AddHistoryAsync(Password);
}
public void RedrawPassword()
{
if (!string.IsNullOrEmpty(_password))
{
TriggerPropertyChanged(nameof(ColoredPassword));
}
}
public async Task SaveOptionsAsync(bool regenerate = true)
{
if (!_doneIniting)

View File

@ -54,26 +54,6 @@
x:Name="_deleteItem"
x:Key="deleteItem" />
<Style x:Key="segmentedButtonBase" TargetType="Button">
<Setter Property="HeightRequest" Value="{Binding SegmentedButtonHeight}" />
<Setter Property="FontSize" Value="{Binding SegmentedButtonFontSize}" />
<Setter Property="CornerRadius" Value="0" />
</Style>
<Style x:Key="segmentedButtonNormal" BaseResourceKey="segmentedButtonBase" TargetType="Button">
<Setter Property="TextColor" Value="{StaticResource PrimaryColor}" />
<Setter Property="FontAttributes" Value="None" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="BorderColor" Value="{StaticResource PrimaryColor}" />
<Setter Property="BorderWidth" Value="1" />
</Style>
<Style x:Key="segmentedButtonDisabled" BaseResourceKey="segmentedButtonBase" TargetType="Button">
<Setter Property="TextColor" Value="{StaticResource TitleTextColor}" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="BackgroundColor" Value="{StaticResource PrimaryColor}" />
<Setter Property="BorderWidth" Value="0" />
</Style>
<ScrollView x:Key="scrollView" x:Name="_scrollView">
<StackLayout Spacing="20">
<StackLayout StyleClass="box">
@ -131,51 +111,25 @@
</Grid.ColumnDefinitions>
<Button
Text="{u:I18n TypeFile}"
StyleClass="segmented-button"
IsEnabled="{Binding IsText}"
HeightRequest="{Binding SegmentedButtonHeight}"
FontSize="{Binding SegmentedButtonFontSize}"
Clicked="FileType_Clicked"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n File}"
Grid.Column="0">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="Style"
Value="{StaticResource segmentedButtonNormal}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="Style"
Value="{StaticResource segmentedButtonDisabled}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Button>
<Button
Text="{u:I18n TypeText}"
StyleClass="segmented-button"
IsEnabled="{Binding IsFile}"
HeightRequest="{Binding SegmentedButtonHeight}"
FontSize="{Binding SegmentedButtonFontSize}"
Clicked="TextType_Clicked"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n Text}"
Grid.Column="1">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="Style"
Value="{StaticResource segmentedButtonNormal}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="Style"
Value="{StaticResource segmentedButtonDisabled}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Button>
</Grid>
</StackLayout>
@ -289,20 +243,20 @@
Text="{u:I18n Options}"
x:Name="_btnOptions"
StyleClass="box-row-button"
TextColor="{StaticResource PrimaryColor}"
TextColor="{DynamicResource PrimaryColor}"
Margin="0" />
<controls:FaButton
x:Name="_btnOptionsUp"
Text="&#xf077;"
StyleClass="box-row-button"
TextColor="{StaticResource PrimaryColor}"
TextColor="{DynamicResource PrimaryColor}"
Clicked="ToggleOptions_Clicked"
IsVisible="False" />
<controls:FaButton
x:Name="_btnOptionsDown"
Text="&#xf078;"
StyleClass="box-row-button"
TextColor="{StaticResource PrimaryColor}"
TextColor="{DynamicResource PrimaryColor}"
Clicked="ToggleOptions_Clicked"
IsVisible="False" />
</StackLayout>
@ -421,7 +375,7 @@
MaxLength="9"
TextChanged="OnMaxAccessCountTextChanged"
HorizontalOptions="FillAndExpand" />
<Stepper
<controls:ExtendedStepper
x:Name="_maxAccessCountStepper"
Value="{Binding MaxAccessCount}"
Maximum="999999999"

View File

@ -61,7 +61,6 @@ namespace Bit.App.Pages
protected override async void OnAppearing()
{
base.OnAppearing();
await _vm.InitAsync();
if (_syncService.SyncInProgress)
{
IsBusy = true;

View File

@ -110,11 +110,6 @@ namespace Bit.App.Pages
public Command<SendView> SendOptionsCommand { get; set; }
public bool LoadedOnce { get; set; }
public async Task InitAsync()
{
SendEnabled = ! await AppHelpers.IsSendDisabledByPolicyAsync();
}
public async Task LoadAsync()
{
if (_doingLoad)
@ -142,6 +137,7 @@ namespace Bit.App.Pages
ShowNoData = false;
Loading = true;
ShowList = false;
SendEnabled = ! await AppHelpers.IsSendDisabledByPolicyAsync();
var groupedSends = new List<SendGroupingsPageListGroup>();
var page = Page as SendGroupingsPage;

View File

@ -29,7 +29,7 @@
HorizontalOptions="End" />
<Button
Clicked="ToggleAutofillService"
BackgroundColor="Transparent"
StyleClass="box-overlay"
RelativeLayout.XConstraint="0"
RelativeLayout.YConstraint="0"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=AutofillServiceSwitch, Property=Width}"
@ -58,8 +58,7 @@
HorizontalOptions="End" />
<Button
Clicked="ToggleInlineAutofill"
IsEnabled="{Binding InlineAutofillEnabled}"
BackgroundColor="Transparent"
StyleClass="box-overlay"
RelativeLayout.XConstraint="0"
RelativeLayout.YConstraint="0"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=InlineAutofillSwitch, Property=Width}"
@ -85,7 +84,7 @@
HorizontalOptions="End" />
<Button
Clicked="ToggleAccessibility"
BackgroundColor="Transparent"
StyleClass="box-overlay"
RelativeLayout.XConstraint="0"
RelativeLayout.YConstraint="0"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=AccessibilitySwitch, Property=Width}"
@ -114,8 +113,7 @@
HorizontalOptions="End" />
<Button
Clicked="ToggleDrawOver"
IsEnabled="{Binding DrawOverEnabled}"
BackgroundColor="Transparent"
StyleClass="box-overlay"
RelativeLayout.XConstraint="0"
RelativeLayout.YConstraint="0"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=DrawOverSwitch, Property=Width}"

View File

@ -170,6 +170,10 @@ namespace Bit.App.Pages
public void ToggleInlineAutofill()
{
if (!InlineAutofillEnabled)
{
return;
}
InlineAutofillToggled = !InlineAutofillToggled;
}
@ -180,6 +184,10 @@ namespace Bit.App.Pages
public void ToggleDrawOver()
{
if (!DrawOverEnabled)
{
return;
}
_deviceActionService.OpenAccessibilityOverlayPermissionSettings();
}

View File

@ -31,8 +31,7 @@
</StackLayout>
<Label
StyleClass="box-footer-label"
Text="{u:I18n ThemeDescription}"
x:Name="_themeDescriptionLabel" />
Text="{u:I18n ThemeDescription}" />
</StackLayout>
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-input, box-row-input-options-platform">

View File

@ -25,8 +25,6 @@ namespace Bit.App.Pages
{
ToolbarItems.RemoveAt(0);
_vm.ShowAndroidAutofillSettings = _deviceActionService.SupportsAutofillService();
_themeDescriptionLabel.Text = string.Concat(_themeDescriptionLabel.Text, " ",
AppResources.RestartIsRequired);
}
else
{

View File

@ -59,7 +59,7 @@ namespace Bit.App.Pages
}
ThemeOptions = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>(null, AppResources.Default),
new KeyValuePair<string, string>(null, AppResources.ThemeDefault),
new KeyValuePair<string, string>("light", AppResources.Light),
new KeyValuePair<string, string>("dark", AppResources.Dark),
new KeyValuePair<string, string>("black", AppResources.Black),
@ -215,17 +215,8 @@ namespace Bit.App.Pages
{
var theme = ThemeOptions[ThemeSelectedIndex].Key;
await _storageService.SaveAsync(Constants.ThemeKey, theme);
if (Device.RuntimePlatform == Device.Android)
{
await _deviceActionService.ShowLoadingAsync(AppResources.Restarting);
await Task.Delay(1000);
}
_messagingService.Send("updatedTheme", theme);
if (Device.RuntimePlatform == Device.iOS)
{
await Task.Delay(500);
await _platformUtilsService.ShowDialogAsync(AppResources.ThemeAppliedOnRestart);
}
ThemeManager.SetTheme(Device.RuntimePlatform == Device.Android, Application.Current.Resources);
_messagingService.Send("updatedTheme");
}
}

View File

@ -1,18 +1,24 @@
using Bit.App.Effects;
using Bit.App.Models;
using Bit.App.Resources;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using Xamarin.Forms;
namespace Bit.App.Pages
{
public class TabsPage : TabbedPage
{
private readonly IMessagingService _messagingService;
private NavigationPage _groupingsPage;
private NavigationPage _sendGroupingsPage;
private NavigationPage _generatorPage;
public TabsPage(AppOptions appOptions = null, PreviousPageInfo previousPage = null)
{
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
_groupingsPage = new NavigationPage(new GroupingsPage(true, previousPage: previousPage))
{
Title = AppResources.MyVault,
@ -85,6 +91,7 @@ namespace Bit.App.Pages
{
if (CurrentPage is NavigationPage navPage)
{
_messagingService.Send("updatedTheme");
if (navPage.RootPage is GroupingsPage groupingsPage)
{
// Load something?

View File

@ -563,7 +563,7 @@
StyleClass="box-row-button, box-row-button-platform"
Text="&#xf29c;"
Command="{Binding PasswordPromptHelpCommand}"
TextColor="{StaticResource MutedColor}"
TextColor="{DynamicResource MutedColor}"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ToggleVisibility}"
HorizontalOptions="StartAndExpand" />

File diff suppressed because it is too large Load Diff

View File

@ -1510,12 +1510,8 @@
<data name="ThemeDescription" xml:space="preserve">
<value>Change the application's color theme.</value>
</data>
<data name="RestartIsRequired" xml:space="preserve">
<value>Restart is required.</value>
<comment>Referring to restarting the application.</comment>
</data>
<data name="Restarting" xml:space="preserve">
<value>Restarting...</value>
<data name="ThemeDefault" xml:space="preserve">
<value>Default (System)</value>
</data>
<data name="CopyNotes" xml:space="preserve">
<value>Copy Notes</value>

View File

@ -6,46 +6,151 @@
<Style TargetType="Entry"
ApplyToDerivedTypes="True">
<Setter Property="PlaceholderColor"
Value="{StaticResource InputPlaceholderColor}" />
Value="{DynamicResource InputPlaceholderColor}" />
<Setter Property="TextColor"
Value="{DynamicResource TextColor}" />
<Setter Property="Margin"
Value="-4, 0, -4, -4" />
</Style>
<Style TargetType="Picker"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{DynamicResource TextColor}" />
<Setter Property="Margin"
Value="-4, 0, -4, -4" />
</Style>
<Style TargetType="DatePicker"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{DynamicResource TextColor}" />
<Setter Property="BackgroundColor"
Value="{DynamicResource BackgroundColor}" />
</Style>
<Style TargetType="TimePicker"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{DynamicResource TextColor}" />
<Setter Property="BackgroundColor"
Value="{DynamicResource BackgroundColor}" />
</Style>
<Style TargetType="Editor"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{DynamicResource TextColor}" />
<Setter Property="PlaceholderColor"
Value="{StaticResource InputPlaceholderColor}" />
Value="{DynamicResource InputPlaceholderColor}" />
<Setter Property="Margin"
Value="-4, 0, -4, -4" />
</Style>
<Style TargetType="Switch"
ApplyToDerivedTypes="True">
<Setter Property="OnColor"
Value="{DynamicResource SwitchOnColor}" />
</Style>
<Style TargetType="SearchBar"
ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor"
Value="Transparent" />
<Setter Property="TextColor"
Value="{StaticResource TitleEntryTextColor}" />
Value="{DynamicResource TitleEntryTextColor}" />
<Setter Property="CancelButtonColor"
Value="{StaticResource TitleEntryTextColor}" />
Value="{DynamicResource TitleEntryTextColor}" />
<Setter Property="PlaceholderColor"
Value="{StaticResource TitleEntryPlaceholderColor}" />
Value="{DynamicResource TitleEntryPlaceholderColor}" />
</Style>
<Style TargetType="ContentPage"
ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor"
Value="{DynamicResource BackgroundColor}" />
</Style>
<Style TargetType="controls:ExtendedSlider">
<Setter Property="MinimumTrackColor"
Value="{StaticResource SliderTrackMinColor}" />
Value="{DynamicResource SliderTrackMinColor}" />
<Setter Property="MaximumTrackColor"
Value="{StaticResource SliderTrackMinColor}" />
Value="{DynamicResource SliderTrackMinColor}" />
<Setter Property="ThumbColor"
Value="{StaticResource SliderThumbColor}" />
Value="{DynamicResource SliderThumbColor}" />
<Setter Property="ThumbBorderColor"
Value="{StaticResource SliderThumbBorderColor}" />
Value="{DynamicResource SliderThumbBorderColor}" />
</Style>
<Style TargetType="controls:ExtendedStepper">
<Setter Property="StepperBackgroundColor"
Value="{DynamicResource StepperBackgroundColor}" />
<Setter Property="StepperForegroundColor"
Value="{DynamicResource StepperForegroundColor}" />
</Style>
<!-- Buttons -->
<Style TargetType="Button">
<Setter Property="BackgroundColor"
Value="{DynamicResource ButtonBackgroundColor}" />
<Setter Property="BorderColor"
Value="{DynamicResource ButtonBorderColor}" />
<Setter Property="BorderWidth"
Value="1" />
<Setter Property="TextColor"
Value="{DynamicResource ButtonTextColor}" />
<Setter Property="FontSize"
Value="18" />
<Setter Property="CornerRadius"
Value="5" />
<Setter Property="Margin"
Value="0, 5, 0, 0" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="{DynamicResource ButtonBackgroundColorDisabled}" />
<Setter Property="BorderWidth"
Value="0" />
<Setter Property="TextColor"
Value="{DynamicResource ButtonTextColorDisabled}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="Button"
Class="btn-primary">
<Setter Property="BackgroundColor"
Value="{DynamicResource PrimaryColor}" />
<Setter Property="BorderColor"
Value="{DynamicResource PrimaryColor}" />
<Setter Property="BorderWidth"
Value="1" />
<Setter Property="TextColor"
Value="{DynamicResource ButtonPrimaryTextColor}" />
<Setter Property="FontSize"
Value="18" />
<Setter Property="FontAttributes"
Value="Bold" />
<Setter Property="CornerRadius"
Value="5" />
<Setter Property="Margin"
Value="0, 5, 0, 0" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor"
Value="{DynamicResource ButtonPrimaryTextColorDisabled}" />
<Setter Property="BackgroundColor"
Value="{DynamicResource ButtonPrimaryBackgroundColorDisabled}" />
<Setter Property="BorderColor"
Value="{DynamicResource ButtonPrimaryBackgroundColorDisabled}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="Button"
ApplyToDerivedTypes="True"
Class="btn-icon-platform">
@ -84,7 +189,7 @@
<Style TargetType="Label"
Class="list-header-platform">
<Setter Property="TextColor"
Value="{StaticResource ListHeaderTextColor}" />
Value="{DynamicResource ListHeaderTextColor}" />
<Setter Property="FontSize"
Value="Small" />
<Setter Property="FontAttributes"
@ -93,7 +198,7 @@
<Style TargetType="BoxView"
Class="list-section-separator-top-platform">
<Setter Property="Color"
Value="{StaticResource ListItemBorderColor}" />
Value="{DynamicResource ListItemBorderColor}" />
</Style>
<Style TargetType="BoxView"
Class="list-section-separator-bottom-platform">
@ -134,7 +239,7 @@
<Style TargetType="Label"
Class="box-header-platform">
<Setter Property="TextColor"
Value="{StaticResource BoxHeaderTextColor}" />
Value="{DynamicResource BoxHeaderTextColor}" />
<Setter Property="FontSize"
Value="Small" />
<Setter Property="FontAttributes"

View File

@ -10,38 +10,38 @@
<Setter Property="FontSize"
Value="Medium" />
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
Value="{DynamicResource TextColor}" />
</Style>
<Style TargetType="Label"
x:Key="text-default">
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
Value="{DynamicResource TextColor}" />
</Style>
<Style TargetType="Label"
Class="text-default">
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
Value="{DynamicResource TextColor}" />
</Style>
<Style TargetType="Label"
Class="text-muted"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
Value="{DynamicResource MutedColor}" />
</Style>
<Style TargetType="Label"
x:Key="text-danger">
<Setter Property="TextColor"
Value="{StaticResource DangerColor}" />
Value="{DynamicResource DangerColor}" />
</Style>
<Style TargetType="Label"
Class="text-danger">
<Setter Property="TextColor"
Value="{StaticResource DangerColor}" />
Value="{DynamicResource DangerColor}" />
</Style>
<Style TargetType="Label"
Class="text-success">
<Setter Property="TextColor"
Value="{StaticResource SuccessColor}" />
Value="{DynamicResource SuccessColor}" />
</Style>
<Style TargetType="Label"
Class="text-sm">
@ -64,18 +64,18 @@
<Style TargetType="TabbedPage"
ApplyToDerivedTypes="True">
<Setter Property="BarBackgroundColor"
Value="{StaticResource TabBarBackgroundColor}" />
Value="{DynamicResource TabBarBackgroundColor}" />
<Setter Property="SelectedTabColor"
Value="{StaticResource TabBarSelectedItemColor}" />
Value="{DynamicResource TabBarSelectedItemColor}" />
<Setter Property="UnselectedTabColor"
Value="{StaticResource TabBarItemColor}" />
Value="{DynamicResource TabBarItemColor}" />
</Style>
<Style TargetType="NavigationPage"
ApplyToDerivedTypes="True">
<Setter Property="BarTextColor"
Value="{StaticResource NavigationBarTextColor}" />
Value="{DynamicResource NavigationBarTextColor}" />
<Setter Property="BarBackgroundColor"
Value="{StaticResource NavigationBarBackgroundColor}" />
Value="{DynamicResource NavigationBarBackgroundColor}" />
</Style>
<!-- Buttons -->
@ -89,13 +89,13 @@
Class="btn-muted"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
Value="{DynamicResource MutedColor}" />
</Style>
<Style TargetType="Button"
Class="btn-disabled"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{StaticResource DisabledIconColor}" />
Value="{DynamicResource DisabledIconColor}" />
</Style>
<Style x:Key="btn-fab" TargetType="Button">
<Setter Property="HeightRequest"
@ -110,6 +110,10 @@
Value="16" />
<Setter Property="Margin"
Value="16" />
<Setter Property="CornerRadius"
Value="100" />
<Setter Property="BackgroundColor"
Value="{DynamicResource FabColor}" />
</Style>
<!-- Title -->
@ -121,7 +125,7 @@
<Setter Property="Padding"
Value="0" />
<Setter Property="TextColor"
Value="{StaticResource TitleTextColor}" />
Value="{DynamicResource TitleTextColor}" />
</Style>
<!-- List -->
@ -151,7 +155,7 @@
<Setter Property="VerticalTextAlignment"
Value="Center" />
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
Value="{DynamicResource MutedColor}" />
<Setter Property="HorizontalOptions"
Value="End" />
<Setter Property="VerticalOptions"
@ -200,7 +204,7 @@
<Setter Property="FontSize"
Value="Small" />
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
Value="{DynamicResource MutedColor}" />
</Style>
<Style TargetType="Label"
ApplyToDerivedTypes="True"
@ -208,14 +212,14 @@
<Setter Property="FontSize"
Value="Small" />
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
Value="{DynamicResource MutedColor}" />
</Style>
<Style TargetType="Label"
Class="list-subtitle">
<Setter Property="FontSize"
Value="Small" />
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
Value="{DynamicResource MutedColor}" />
</Style>
<Style TargetType="Label"
Class="list-icon"
@ -229,7 +233,7 @@
<Setter Property="VerticalTextAlignment"
Value="Center" />
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
Value="{DynamicResource MutedColor}" />
</Style>
<Style TargetType="Button"
ApplyToDerivedTypes="True"
@ -239,7 +243,42 @@
<Setter Property="Padding"
Value="0" />
<Setter Property="TextColor"
Value="{StaticResource ButtonColor}" />
Value="{DynamicResource ButtonColor}" />
</Style>
<Style TargetType="Button"
ApplyToDerivedTypes="True"
Class="segmented-button">
<Setter Property="BackgroundColor"
Value="Transparent" />
<Setter Property="BorderColor"
Value="{DynamicResource PrimaryColor}" />
<Setter Property="BorderWidth"
Value="1" />
<Setter Property="CornerRadius"
Value="0" />
<Setter Property="TextColor"
Value="{DynamicResource PrimaryColor}" />
<Setter Property="FontAttributes"
Value="None" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="{DynamicResource PrimaryColor}" />
<Setter Property="BorderWidth"
Value="0" />
<Setter Property="TextColor"
Value="{DynamicResource TitleTextColor}" />
<Setter Property="FontAttributes"
Value="Bold" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<!-- Box -->
@ -316,21 +355,46 @@
Class="box-row-button">
<Setter Property="BackgroundColor"
Value="Transparent" />
<Setter Property="BorderWidth"
Value="0" />
<Setter Property="Padding"
Value="0" />
<Setter Property="TextColor"
Value="{StaticResource ButtonColor}" />
Value="{DynamicResource ButtonColor}" />
<Setter Property="HorizontalOptions"
Value="End" />
<Setter Property="VerticalOptions"
Value="CenterAndExpand" />
</Style>
<Style TargetType="Button"
ApplyToDerivedTypes="True"
Class="box-overlay">
<Setter Property="BackgroundColor"
Value="Transparent" />
<Setter Property="BorderWidth"
Value="0" />
<Setter Property="Padding"
Value="0" />
<Setter Property="TextColor"
Value="Transparent" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled" />
<VisualState x:Name="Focused" />
<VisualState x:Name="Selected" />
<VisualState x:Name="Pressed" />
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="BoxView"
Class="box-row-separator">
<Setter Property="HeightRequest"
Value="1" />
<Setter Property="Color"
Value="{StaticResource BoxBorderColor}" />
Value="{DynamicResource BoxBorderColor}" />
</Style>
<Style TargetType="Label"
Class="box-label">
@ -339,14 +403,14 @@
<Setter Property="FontAttributes"
Value="Bold" />
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
Value="{DynamicResource MutedColor}" />
</Style>
<Style TargetType="Label"
Class="box-label-regular">
<Setter Property="FontSize"
Value="Medium" />
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
Value="{DynamicResource TextColor}" />
<Setter Property="VerticalOptions"
Value="Center" />
</Style>
@ -363,14 +427,14 @@
<Setter Property="FontSize"
Value="Small" />
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
Value="{DynamicResource MutedColor}" />
</Style>
<Style TargetType="Label"
Class="box-footer-label">
<Setter Property="FontSize"
Value="Small" />
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
Value="{DynamicResource MutedColor}" />
</Style>
<Style TargetType="Label"
Class="box-footer-label-switch">
@ -382,6 +446,6 @@
<Setter Property="FontSize"
Value="Medium" />
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
Value="{DynamicResource TextColor}" />
</Style>
</ResourceDictionary>

View File

@ -18,6 +18,8 @@
<Color x:Key="SplashBackgroundColor">#000000</Color>
<Color x:Key="BorderColor">#282828</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</Color>
<Color x:Key="SeparatorColor">#282828</Color>
<Color x:Key="TouchColor">#52bdfb</Color>
<Color x:Key="BoxBorderColor">#282828</Color>
<Color x:Key="BoxHeaderTextColor">#52bdfb</Color>
@ -38,9 +40,23 @@
<Color x:Key="SliderTrackMaxColor">#282828</Color>
<Color x:Key="SwitchOnColor">#52bdfb</Color>
<Color x:Key="SwitchThumbColor">#B9B9B9</Color>
<Color x:Key="StepperBackgroundColor">#5A595B</Color>
<Color x:Key="StepperForegroundColor">#ffffff</Color>
<Color x:Key="ButtonPrimaryBackgroundColor">#52bdfb</Color>
<Color x:Key="ButtonPrimaryBackgroundColorPressed">#058AD8</Color>
<Color x:Key="ButtonPrimaryBackgroundColorDisabled">#777777</Color>
<Color x:Key="ButtonPrimaryTextColor">#ffffff</Color>
<Color x:Key="ButtonPrimaryTextColorDisabled">#cccccc</Color>
<Color x:Key="ButtonTextColor">#ffffff</Color>
<Color x:Key="ButtonBackgroundColor">#5A595B</Color>
<Color x:Key="ButtonBackgroundColorPressed">#414042</Color>
<Color x:Key="ButtonBackgroundColorDisabled">#5A595B</Color>
<Color x:Key="ButtonBorderColor">#898989</Color>
<Color x:Key="ButtonTextColor">#ffffff</Color>
<Color x:Key="ButtonTextColorDisabled">#aaaaaa</Color>
<Color x:Key="FabColor">#52bdfb</Color>
<Color x:Key="FabPressedColor">#3ea1da</Color>

View File

@ -18,6 +18,8 @@
<Color x:Key="SplashBackgroundColor">#222222</Color>
<Color x:Key="BorderColor">#191919</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</Color>
<Color x:Key="SeparatorColor">#191919</Color>
<Color x:Key="TouchColor">#52bdfb</Color>
<Color x:Key="BoxBorderColor">#191919</Color>
<Color x:Key="BoxHeaderTextColor">#52bdfb</Color>
@ -38,9 +40,23 @@
<Color x:Key="SliderTrackMaxColor">#191919</Color>
<Color x:Key="SwitchOnColor">#52bdfb</Color>
<Color x:Key="SwitchThumbColor">#B9B9B9</Color>
<Color x:Key="StepperBackgroundColor">#5A595B</Color>
<Color x:Key="StepperForegroundColor">#ffffff</Color>
<Color x:Key="ButtonPrimaryBackgroundColor">#52bdfb</Color>
<Color x:Key="ButtonPrimaryBackgroundColorPressed">#058AD8</Color>
<Color x:Key="ButtonPrimaryBackgroundColorDisabled">#777777</Color>
<Color x:Key="ButtonPrimaryTextColor">#ffffff</Color>
<Color x:Key="ButtonPrimaryTextColorDisabled">#cccccc</Color>
<Color x:Key="ButtonTextColor">#ffffff</Color>
<Color x:Key="ButtonBackgroundColor">#5A595B</Color>
<Color x:Key="ButtonBackgroundColorPressed">#414042</Color>
<Color x:Key="ButtonBackgroundColorDisabled">#5A595B</Color>
<Color x:Key="ButtonBorderColor">#898989</Color>
<Color x:Key="ButtonTextColor">#ffffff</Color>
<Color x:Key="ButtonTextColorDisabled">#aaaaaa</Color>
<Color x:Key="FabColor">#52bdfb</Color>
<Color x:Key="FabPressedColor">#3ea1da</Color>

View File

@ -15,9 +15,11 @@
<Color x:Key="InputPlaceholderColor">#d0d0d0</Color>
<Color x:Key="BackgroundColor">#ffffff</Color>
<Color x:Key="SplashBackgroundColor">#efeff4</Color>
<Color x:Key="SplashBackgroundColor">#ffffff</Color>
<Color x:Key="BorderColor">#dddddd</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</Color>
<Color x:Key="SeparatorColor">#dddddd</Color>
<Color x:Key="TouchColor">#bbbbbb</Color>
<Color x:Key="BoxBorderColor">#dddddd</Color>
<Color x:Key="BoxHeaderTextColor">#175DDC</Color>
@ -38,9 +40,23 @@
<Color x:Key="SliderTrackMaxColor">#dddddd</Color>
<Color x:Key="SwitchOnColor">#175DDC</Color>
<Color x:Key="SwitchThumbColor">#ECECEC</Color>
<Color x:Key="StepperBackgroundColor">#eeeeee</Color>
<Color x:Key="StepperForegroundColor">#000000</Color>
<Color x:Key="ButtonPrimaryBackgroundColor">#175DDC</Color>
<Color x:Key="ButtonPrimaryBackgroundColorPressed">#1249AC</Color>
<Color x:Key="ButtonPrimaryBackgroundColorDisabled">#bbbbbb</Color>
<Color x:Key="ButtonPrimaryTextColor">#ffffff</Color>
<Color x:Key="ButtonPrimaryTextColorDisabled">#ffffff</Color>
<Color x:Key="ButtonBackgroundColor">#eeeeee</Color>
<Color x:Key="ButtonBackgroundColorPressed">#cccccc</Color>
<Color x:Key="ButtonBackgroundColorDisabled">#eeeeee</Color>
<Color x:Key="ButtonBorderColor">#aaaaaa</Color>
<Color x:Key="ButtonTextColor">#000000</Color>
<Color x:Key="ButtonBackgroundColor">#dddddd</Color>
<Color x:Key="ButtonTextColorDisabled">#aaaaaa</Color>
<Color x:Key="FabColor">#175DDC</Color>
<Color x:Key="FabPressedColor">#3883af</Color>

View File

@ -18,6 +18,8 @@
<Color x:Key="SplashBackgroundColor">#2e3440</Color>
<Color x:Key="BorderColor">#2e3440</Color>
<Color x:Key="DisabledIconColor">#d8dee9</Color>
<Color x:Key="SeparatorColor">#2e3440</Color>
<Color x:Key="TouchColor">#81a1c1</Color>
<Color x:Key="BoxBorderColor">#2e3440</Color>
<Color x:Key="BoxHeaderTextColor">#81a1c1</Color>
@ -38,9 +40,23 @@
<Color x:Key="SliderTrackMaxColor">#2e3440</Color>
<Color x:Key="SwitchOnColor">#81a1c1</Color>
<Color x:Key="SwitchThumbColor">#e5e9f0</Color>
<Color x:Key="StepperBackgroundColor">#4c566a</Color>
<Color x:Key="StepperForegroundColor">#e5e9f0</Color>
<Color x:Key="ButtonPrimaryBackgroundColor">#81a1c1</Color>
<Color x:Key="ButtonPrimaryBackgroundColorPressed">#4E769E</Color>
<Color x:Key="ButtonPrimaryBackgroundColorDisabled">#5C6C7B</Color>
<Color x:Key="ButtonPrimaryTextColor">#e5e9f0</Color>
<Color x:Key="ButtonPrimaryTextColorDisabled">#ACB5C5</Color>
<Color x:Key="ButtonTextColor">#e5e9f0</Color>
<Color x:Key="ButtonBackgroundColor">#4c566a</Color>
<Color x:Key="ButtonBackgroundColorPressed">#3A4251</Color>
<Color x:Key="ButtonBackgroundColorDisabled">#454951</Color>
<Color x:Key="ButtonBorderColor">#5E6A82</Color>
<Color x:Key="ButtonTextColor">#e5e9f0</Color>
<Color x:Key="ButtonTextColorDisabled">#aaaaaa</Color>
<Color x:Key="FabColor">#81a1c1</Color>
<Color x:Key="FabPressedColor">#81a1c1</Color>

View File

@ -6,84 +6,171 @@
<Style TargetType="Entry"
ApplyToDerivedTypes="True">
<Setter Property="PlaceholderColor"
Value="{StaticResource InputPlaceholderColor}" />
Value="{DynamicResource InputPlaceholderColor}" />
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
Value="{DynamicResource TextColor}" />
<Setter Property="Margin"
Value="0, 5, 0, 12" />
</Style>
<Style TargetType="Picker"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
Value="{DynamicResource TextColor}" />
<Setter Property="Margin"
Value="0, 5, 0, 12" />
</Style>
<Style TargetType="DatePicker"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{DynamicResource TextColor}" />
<Setter Property="BackgroundColor"
Value="{DynamicResource BackgroundColor}" />
</Style>
<Style TargetType="TimePicker"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{DynamicResource TextColor}" />
<Setter Property="BackgroundColor"
Value="{DynamicResource BackgroundColor}" />
</Style>
<Style TargetType="Editor"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
Value="{DynamicResource TextColor}" />
<Setter Property="BackgroundColor"
Value="{StaticResource BackgroundColor}" />
Value="{DynamicResource BackgroundColor}" />
<Setter Property="PlaceholderColor"
Value="{StaticResource InputPlaceholderColor}" />
Value="{DynamicResource InputPlaceholderColor}" />
<Setter Property="Margin"
Value="0, 0, 0, 12" />
</Style>
<Style TargetType="Switch"
ApplyToDerivedTypes="True">
<Setter Property="OnColor"
Value="{StaticResource SwitchOnColor}" />
Value="{DynamicResource SwitchOnColor}" />
</Style>
<Style TargetType="SearchBar"
ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor"
Value="{StaticResource ListHeaderBackgroundColor}" />
Value="{DynamicResource ListHeaderBackgroundColor}" />
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
Value="{DynamicResource TextColor}" />
<Setter Property="CancelButtonColor"
Value="{StaticResource PrimaryColor}" />
Value="{DynamicResource PrimaryColor}" />
<Setter Property="PlaceholderColor"
Value="#777777" />
</Style>
<Style TargetType="ContentPage"
ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor"
Value="{StaticResource BackgroundColor}" />
Value="{DynamicResource BackgroundColor}" />
</Style>
<Style TargetType="CollectionView"
ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor"
Value="{StaticResource BackgroundColor}" />
Value="{DynamicResource BackgroundColor}" />
</Style>
<Style TargetType="RefreshView"
ApplyToDerivedTypes="True">
<Setter Property="RefreshColor"
Value="{StaticResource PrimaryColor}" />
Value="{DynamicResource PrimaryColor}" />
</Style>
<Style TargetType="ActivityIndicator"
ApplyToDerivedTypes="True">
<Setter Property="Color"
Value="{StaticResource PrimaryColor}" />
Value="{DynamicResource PrimaryColor}" />
</Style>
<Style TargetType="controls:ExtendedSlider">
<Setter Property="MinimumTrackColor"
Value="{StaticResource SliderTrackMinColor}" />
Value="{DynamicResource SliderTrackMinColor}" />
<Setter Property="MaximumTrackColor"
Value="{StaticResource SliderTrackMaxColor}" />
Value="{DynamicResource SliderTrackMaxColor}" />
<Setter Property="ThumbColor"
Value="{StaticResource SliderThumbColor}" />
Value="{DynamicResource SliderThumbColor}" />
</Style>
<Style TargetType="controls:ExtendedStepper">
<Setter Property="StepperForegroundColor"
Value="{DynamicResource StepperForegroundColor}" />
</Style>
<!-- Buttons -->
<Style TargetType="Button">
<Setter Property="BackgroundColor"
Value="{StaticResource ButtonBackgroundColor}" />
Value="{DynamicResource ButtonBackgroundColor}" />
<Setter Property="BorderColor"
Value="{DynamicResource ButtonBorderColor}" />
<Setter Property="BorderWidth"
Value="1" />
<Setter Property="TextColor"
Value="{StaticResource ButtonTextColor}" />
Value="{DynamicResource ButtonTextColor}" />
<Setter Property="FontSize"
Value="18" />
<Setter Property="Margin"
Value="0, 5, 0, 0" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="{DynamicResource ButtonBackgroundColorPressed}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="{DynamicResource ButtonBackgroundColorDisabled}" />
<Setter Property="BorderWidth"
Value="0" />
<Setter Property="TextColor"
Value="{DynamicResource ButtonTextColorDisabled}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="Button"
Class="btn-primary">
<Setter Property="BackgroundColor"
Value="{DynamicResource PrimaryColor}" />
<Setter Property="BorderColor"
Value="{DynamicResource PrimaryColor}" />
<Setter Property="BorderWidth"
Value="1" />
<Setter Property="TextColor"
Value="{DynamicResource ButtonPrimaryTextColor}" />
<Setter Property="FontSize"
Value="18" />
<Setter Property="FontAttributes"
Value="Bold" />
<Setter Property="Margin"
Value="0, 5, 0, 0" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="{DynamicResource ButtonPrimaryBackgroundColorPressed}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor"
Value="{DynamicResource ButtonPrimaryTextColorDisabled}" />
<Setter Property="BackgroundColor"
Value="{DynamicResource ButtonPrimaryBackgroundColorDisabled}" />
<Setter Property="BorderColor"
Value="{DynamicResource ButtonPrimaryBackgroundColorDisabled}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="Button"
ApplyToDerivedTypes="True"
@ -100,12 +187,12 @@
Class="list-item-separator-bottom-platform"
ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor"
Value="{StaticResource ListItemBorderColor}" />
Value="{DynamicResource ListItemBorderColor}" />
</Style>
<Style TargetType="StackLayout"
Class="list-row-header-container-platform">
<Setter Property="BackgroundColor"
Value="{StaticResource ListHeaderBackgroundColor}" />
Value="{DynamicResource ListHeaderBackgroundColor}" />
</Style>
<Style TargetType="StackLayout"
Class="list-row-header-platform">
@ -117,19 +204,19 @@
<Style TargetType="Label"
Class="list-header-platform">
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
Value="{DynamicResource MutedColor}" />
<Setter Property="FontSize"
Value="Small" />
</Style>
<Style TargetType="BoxView"
Class="list-section-separator-top-platform">
<Setter Property="Color"
Value="{StaticResource ListSectionBorderColor}" />
Value="{DynamicResource ListSectionBorderColor}" />
</Style>
<Style TargetType="BoxView"
Class="list-section-separator-bottom-platform">
<Setter Property="Color"
Value="{StaticResource ListSectionBorderBottomColor}" />
Value="{DynamicResource ListSectionBorderBottomColor}" />
</Style>
<Style TargetType="StackLayout"
Class="list-row-platform">
@ -163,7 +250,7 @@
<Style TargetType="Label"
Class="box-header-platform">
<Setter Property="TextColor"
Value="{StaticResource BoxHeaderTextColor}" />
Value="{DynamicResource BoxHeaderTextColor}" />
<Setter Property="FontSize"
Value="Small" />
<Setter Property="FontAttributes"

View File

@ -1,9 +1,8 @@
using System;
using Bit.App.Abstractions;
using Bit.App.Models;
using Bit.App.Services;
using Bit.App.Styles;
using Bit.Core;
using Bit.Core.Utilities;
using Xamarin.Forms;
namespace Bit.App.Utilities
@ -47,8 +46,7 @@ namespace Bit.App.Utilities
}
else
{
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService", true);
if (deviceActionService?.UsingDarkTheme() ?? false)
if (OsDarkModeEnabled())
{
resources.MergedDictionaries.Add(new Dark());
UsingLightTheme = false;
@ -86,6 +84,17 @@ namespace Bit.App.Utilities
!android ? "group.com.8bit.bitwarden" : default(string));
}
public static bool OsDarkModeEnabled()
{
if (Application.Current == null)
{
// called from iOS extension
var app = new App(new AppOptions { IosExtension = true });
return app.RequestedTheme == OSAppTheme.Dark;
}
return Application.Current.RequestedTheme == OSAppTheme.Dark;
}
public static void ApplyResourcesToPage(ContentPage page)
{
foreach (var resourceDict in Resources().MergedDictionaries)

View File

@ -336,7 +336,9 @@ namespace Bit.iOS.Autofill
_initedAppCenter = true;
}
iOSCoreHelpers.Bootstrap();
iOSCoreHelpers.AppearanceAdjustments(deviceActionService);
var app = new App.App(new AppOptions { IosExtension = true });
ThemeManager.SetTheme(false, app.Resources);
iOSCoreHelpers.AppearanceAdjustments();
_nfcDelegate = new Core.NFCReaderDelegate((success, message) =>
messagingService.Send("gotYubiKeyOTP", message));
iOSCoreHelpers.SubscribeBroadcastReceiver(this, _nfcSession, _nfcDelegate);

View File

@ -72,6 +72,8 @@
<string>FontAwesome.ttf</string>
<string>MaterialIcons_Regular.ttf</string>
</array>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<dict>
<key>arm64</key>

View File

@ -1,17 +1,68 @@
using Bit.iOS.Core.Renderers;
using Bit.App.Abstractions;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using Bit.iOS.Core.Renderers;
using Bit.iOS.Core.Utilities;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(TabbedPage), typeof(CustomTabbedRenderer))]
namespace Bit.iOS.Core.Renderers
{
public class CustomTabbedRenderer : TabbedRenderer
{
private IBroadcasterService _broadcasterService;
public CustomTabbedRenderer()
{
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
_broadcasterService.Subscribe(nameof(CustomTabbedRenderer), async (message) =>
{
if (message.Command == "updatedTheme")
{
Device.BeginInvokeOnMainThread(() =>
{
iOSCoreHelpers.AppearanceAdjustments();
UpdateTabBarAppearance();
});
}
});
}
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
TabBar.Translucent = false;
TabBar.Opaque = true;
UpdateTabBarAppearance();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
_broadcasterService.Unsubscribe(nameof(CustomTabbedRenderer));
}
base.Dispose(disposing);
}
private void UpdateTabBarAppearance()
{
// https://developer.apple.com/forums/thread/682420
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
if (deviceActionService.SystemMajorVersion() >= 15)
{
var appearance = new UITabBarAppearance();
appearance.ConfigureWithOpaqueBackground();
appearance.BackgroundColor = ThemeHelpers.TabBarBackgroundColor;
appearance.StackedLayoutAppearance.Normal.IconColor = ThemeHelpers.TabBarItemColor;
appearance.StackedLayoutAppearance.Normal.TitleTextAttributes =
new UIStringAttributes { ForegroundColor = ThemeHelpers.TabBarItemColor };
TabBar.StandardAppearance = appearance;
TabBar.ScrollEdgeAppearance = TabBar.StandardAppearance;
}
}
}
}

View File

@ -0,0 +1,45 @@
using System.ComponentModel;
using Bit.App.Controls;
using Bit.iOS.Core.Renderers;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(ExtendedStepper), typeof(ExtendedStepperRenderer))]
namespace Bit.iOS.Core.Renderers
{
public class ExtendedStepperRenderer : StepperRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Stepper> e)
{
base.OnElementChanged(e);
UpdateFgColor();
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == ExtendedStepper.StepperForegroundColorProperty.PropertyName)
{
UpdateFgColor();
}
else
{
base.OnElementPropertyChanged(sender, e);
}
}
private void UpdateFgColor()
{
if (Control != null && Element is ExtendedStepper view)
{
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
// https://developer.apple.com/forums/thread/121495
Control.SetIncrementImage(Control.GetIncrementImage(UIControlState.Normal), UIControlState.Normal);
Control.SetDecrementImage(Control.GetDecrementImage(UIControlState.Normal), UIControlState.Normal);
}
Control.TintColor = view.StepperForegroundColor.ToUIColor();
}
}
}
}

View File

@ -422,19 +422,6 @@ namespace Bit.iOS.Core.Services
throw new NotImplementedException();
}
public bool UsingDarkTheme()
{
try
{
if (SystemMajorVersion() > 12)
{
return UIScreen.MainScreen.TraitCollection.UserInterfaceStyle == UIUserInterfaceStyle.Dark;
}
}
catch { }
return false;
}
public long GetActiveTime()
{
// Fall back to UnixTimeMilliseconds in case this approach stops working. We'll lose clock-change

View File

@ -1,4 +1,5 @@
using UIKit;
using Bit.App.Utilities;
using UIKit;
using Xamarin.Forms.Platform.iOS;
namespace Bit.iOS.Core.Utilities
@ -6,24 +7,63 @@ namespace Bit.iOS.Core.Utilities
public static class ThemeHelpers
{
public static bool LightTheme = true;
public static bool UsingOsDarkTheme = false;
public static UIColor SplashBackgroundColor = Xamarin.Forms.Color.FromHex("#efeff4").ToUIColor();
public static UIColor BackgroundColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();
public static UIColor MutedColor = Xamarin.Forms.Color.FromHex("#777777").ToUIColor();
public static UIColor SuccessColor = Xamarin.Forms.Color.FromHex("#00a65a").ToUIColor();
public static UIColor DangerColor = Xamarin.Forms.Color.FromHex("dd4b39").ToUIColor();
public static UIColor PrimaryColor = Xamarin.Forms.Color.FromHex("#175DDC").ToUIColor();
public static UIColor TextColor = Xamarin.Forms.Color.FromHex("#000000").ToUIColor();
public static UIColor PlaceholderColor = Xamarin.Forms.Color.FromHex("#d0d0d0").ToUIColor();
public static UIColor SeparatorColor = Xamarin.Forms.Color.FromHex("#dddddd").ToUIColor();
public static UIColor ListHeaderBackgroundColor = Xamarin.Forms.Color.FromHex("#efeff4").ToUIColor();
public static UIColor NavBarBackgroundColor = Xamarin.Forms.Color.FromHex("#175DDC").ToUIColor();
public static UIColor NavBarTextColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();
public static void SetAppearance(string theme, bool usingOsDarkTheme)
public static UIColor SplashBackgroundColor
{
UsingOsDarkTheme = usingOsDarkTheme;
SetThemeVariables(theme);
get => ThemeManager.GetResourceColor("SplashBackgroundColor").ToUIColor();
}
public static UIColor BackgroundColor
{
get => ThemeManager.GetResourceColor("BackgroundColor").ToUIColor();
}
public static UIColor MutedColor
{
get => ThemeManager.GetResourceColor("MutedColor").ToUIColor();
}
public static UIColor SuccessColor
{
get => ThemeManager.GetResourceColor("SuccessColor").ToUIColor();
}
public static UIColor DangerColor
{
get => ThemeManager.GetResourceColor("DangerColor").ToUIColor();
}
public static UIColor PrimaryColor
{
get => ThemeManager.GetResourceColor("PrimaryColor").ToUIColor();
}
public static UIColor TextColor
{
get => ThemeManager.GetResourceColor("TextColor").ToUIColor();
}
public static UIColor SeparatorColor
{
get => ThemeManager.GetResourceColor("SeparatorColor").ToUIColor();
}
public static UIColor ListHeaderBackgroundColor
{
get => ThemeManager.GetResourceColor("ListHeaderBackgroundColor").ToUIColor();
}
public static UIColor NavBarBackgroundColor
{
get => ThemeManager.GetResourceColor("NavigationBarBackgroundColor").ToUIColor();
}
public static UIColor NavBarTextColor
{
get => ThemeManager.GetResourceColor("NavigationBarTextColor").ToUIColor();
}
public static UIColor TabBarBackgroundColor
{
get => ThemeManager.GetResourceColor("TabBarBackgroundColor").ToUIColor();
}
public static UIColor TabBarItemColor
{
get => ThemeManager.GetResourceColor("TabBarItemColor").ToUIColor();
}
public static void SetAppearance(string theme, bool osDarkModeEnabled)
{
SetThemeVariables(theme, osDarkModeEnabled);
UINavigationBar.Appearance.ShadowImage = new UIImage();
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
UIStepper.Appearance.TintColor = MutedColor;
@ -33,91 +73,22 @@ namespace Bit.iOS.Core.Utilities
}
}
public static void SetExtensionAppearance(string theme, bool usingOsDarkTheme)
{
SetAppearance(theme, usingOsDarkTheme);
UIView.Appearance.BackgroundColor = BackgroundColor;
UILabel.Appearance.TextColor = TextColor;
UITextField.Appearance.TintColor = TextColor;
UITextView.Appearance.TintColor = TextColor;
UITextField.Appearance.BackgroundColor = BackgroundColor;
UITextView.Appearance.BackgroundColor = BackgroundColor;
UITableView.Appearance.BackgroundColor = BackgroundColor;
UITableView.Appearance.SeparatorColor = SeparatorColor;
UINavigationBar.Appearance.BackgroundColor = NavBarBackgroundColor;
UINavigationBar.Appearance.BarTintColor = NavBarBackgroundColor;
UINavigationBar.Appearance.TintColor = NavBarTextColor;
UINavigationBar.Appearance.Translucent = false;
UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes()
{
TextColor = NavBarTextColor
});
UIBarButtonItem.Appearance.TintColor = NavBarTextColor;
UIButton.Appearance.TintColor = TextColor;
UILabel.AppearanceWhenContainedIn(typeof(UITableViewHeaderFooterView)).TextColor = MutedColor;
}
public static UIFont GetDangerFont()
{
return Xamarin.Forms.Font.SystemFontOfSize(Xamarin.Forms.NamedSize.Small,
Xamarin.Forms.FontAttributes.Bold).ToUIFont();
}
private static void SetThemeVariables(string theme)
private static void SetThemeVariables(string theme, bool osDarkModeEnabled)
{
LightTheme = false;
if (string.IsNullOrWhiteSpace(theme) && UsingOsDarkTheme)
if (string.IsNullOrWhiteSpace(theme) && osDarkModeEnabled)
{
theme = "dark";
}
if (theme == "dark")
if (theme == "dark" || theme == "black" || theme == "nord")
{
var whiteColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();
MutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor();
SuccessColor = Xamarin.Forms.Color.FromHex("#00a65a").ToUIColor();
DangerColor = Xamarin.Forms.Color.FromHex("ff3e24").ToUIColor();
BackgroundColor = Xamarin.Forms.Color.FromHex("#303030").ToUIColor();
SplashBackgroundColor = Xamarin.Forms.Color.FromHex("#222222").ToUIColor();
PrimaryColor = Xamarin.Forms.Color.FromHex("#52bdfb").ToUIColor();
TextColor = whiteColor;
PlaceholderColor = Xamarin.Forms.Color.FromHex("#707070").ToUIColor();
SeparatorColor = Xamarin.Forms.Color.FromHex("#191919").ToUIColor();
ListHeaderBackgroundColor = Xamarin.Forms.Color.FromHex("#222222").ToUIColor();
NavBarBackgroundColor = Xamarin.Forms.Color.FromHex("#212121").ToUIColor();
NavBarTextColor = whiteColor;
}
else if (theme == "black")
{
var blackColor = Xamarin.Forms.Color.FromHex("#000000").ToUIColor();
var whiteColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();
MutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor();
SuccessColor = Xamarin.Forms.Color.FromHex("#00a65a").ToUIColor();
DangerColor = Xamarin.Forms.Color.FromHex("ff3e24").ToUIColor();
BackgroundColor = blackColor;
SplashBackgroundColor = blackColor;
PrimaryColor = Xamarin.Forms.Color.FromHex("#52bdfb").ToUIColor();
TextColor = whiteColor;
PlaceholderColor = Xamarin.Forms.Color.FromHex("#707070").ToUIColor();
SeparatorColor = Xamarin.Forms.Color.FromHex("#282828").ToUIColor();
ListHeaderBackgroundColor = blackColor;
NavBarBackgroundColor = blackColor;
NavBarTextColor = whiteColor;
}
else if (theme == "nord")
{
MutedColor = Xamarin.Forms.Color.FromHex("#d8dee9").ToUIColor();
SuccessColor = Xamarin.Forms.Color.FromHex("#a3be8c").ToUIColor();
DangerColor = Xamarin.Forms.Color.FromHex("bf616a").ToUIColor();
BackgroundColor = Xamarin.Forms.Color.FromHex("#3b4252").ToUIColor();
SplashBackgroundColor = Xamarin.Forms.Color.FromHex("#2e3440").ToUIColor();
PrimaryColor = Xamarin.Forms.Color.FromHex("#81a1c1").ToUIColor();
TextColor = Xamarin.Forms.Color.FromHex("#e5e9f0").ToUIColor();
PlaceholderColor = Xamarin.Forms.Color.FromHex("#7b88a1").ToUIColor();
SeparatorColor = Xamarin.Forms.Color.FromHex("#2e3440").ToUIColor();
ListHeaderBackgroundColor = Xamarin.Forms.Color.FromHex("#2e3440").ToUIColor();
NavBarBackgroundColor = Xamarin.Forms.Color.FromHex("#2e3440").ToUIColor();
NavBarTextColor = Xamarin.Forms.Color.FromHex("#e5e9f0").ToUIColor();
LightTheme = false;
}
else
{

View File

@ -84,9 +84,9 @@ namespace Bit.iOS.Core.Utilities
var bootstrapTask = BootstrapAsync(postBootstrapFunc);
}
public static void AppearanceAdjustments(IDeviceActionService deviceActionService)
public static void AppearanceAdjustments()
{
ThemeHelpers.SetAppearance(ThemeManager.GetTheme(false), deviceActionService.UsingDarkTheme());
ThemeHelpers.SetAppearance(ThemeManager.GetTheme(false), ThemeManager.OsDarkModeEnabled());
UIApplication.SharedApplication.StatusBarHidden = false;
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
}

View File

@ -162,6 +162,7 @@
<Compile Include="Renderers\CustomPickerRenderer.cs" />
<Compile Include="Renderers\CustomSearchBarRenderer.cs" />
<Compile Include="Renderers\CustomTabbedRenderer.cs" />
<Compile Include="Renderers\ExtendedStepperRenderer.cs" />
<Compile Include="Renderers\ExtendedTimePickerRenderer.cs" />
<Compile Include="Renderers\CustomViewCellRenderer.cs" />
<Compile Include="Renderers\HybridWebViewRenderer.cs" />

View File

@ -70,6 +70,8 @@
<string>FontAwesome.ttf</string>
<string>MaterialIcons_Regular.ttf</string>
</array>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<dict>
<key>arm64</key>

View File

@ -414,7 +414,7 @@ namespace Bit.iOS.Extension
_initedAppCenter = true;
}
iOSCoreHelpers.Bootstrap();
iOSCoreHelpers.AppearanceAdjustments(deviceActionService);
iOSCoreHelpers.AppearanceAdjustments();
_nfcDelegate = new NFCReaderDelegate((success, message) =>
messagingService.Send("gotYubiKeyOTP", message));
iOSCoreHelpers.SubscribeBroadcastReceiver(this, _nfcSession, _nfcDelegate);

View File

@ -51,7 +51,7 @@ namespace Bit.iOS
_eventService = ServiceContainer.Resolve<IEventService>("eventService");
LoadApplication(new App.App(null));
iOSCoreHelpers.AppearanceAdjustments(_deviceActionService);
iOSCoreHelpers.AppearanceAdjustments();
ZXing.Net.Mobile.Forms.iOS.Platform.Init();
_broadcasterService.Subscribe(nameof(AppDelegate), async (message) =>
@ -66,7 +66,10 @@ namespace Bit.iOS
}
else if (message.Command == "updatedTheme")
{
// ThemeManager.SetThemeStyle(message.Data as string);
Device.BeginInvokeOnMainThread(() =>
{
iOSCoreHelpers.AppearanceAdjustments();
});
}
else if (message.Command == "copiedToClipboard")
{
@ -182,6 +185,9 @@ namespace Bit.iOS
public override void DidEnterBackground(UIApplication uiApplication)
{
_storageService.SaveAsync(Constants.LastActiveTimeKey, _deviceActionService.GetActiveTime());
_messagingService.Send("slept");
var view = new UIView(UIApplication.SharedApplication.KeyWindow.Frame)
{
Tag = 4321
@ -201,8 +207,6 @@ namespace Bit.iOS
UIApplication.SharedApplication.KeyWindow.BringSubviewToFront(view);
UIApplication.SharedApplication.KeyWindow.EndEditing(true);
UIApplication.SharedApplication.SetStatusBarHidden(true, false);
_storageService.SaveAsync(Constants.LastActiveTimeKey, _deviceActionService.GetActiveTime());
_messagingService.Send("slept");
base.DidEnterBackground(uiApplication);
}

View File

@ -113,6 +113,8 @@
<key>arm64</key>
<true/>
</dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>XSAppIconAssets</key>
<string>Resources/Assets.xcassets/AppIcons.appiconset</string>
<key>ITSAppUsesNonExemptEncryption</key>