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: ios:
name: Apple iOS name: Apple iOS
runs-on: macos-10.15 runs-on: macos-11
steps: steps:
- name: Print environment - name: Print environment
run: | run: |

View file

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

View file

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

View file

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

View file

@ -15,9 +15,9 @@ using Bit.Droid.Receivers;
using Bit.App.Models; using Bit.App.Models;
using Bit.Core.Enums; using Bit.Core.Enums;
using Android.Nfc; using Android.Nfc;
using Bit.App.Utilities;
using System.Threading.Tasks; using System.Threading.Tasks;
using AndroidX.Core.Content; using AndroidX.Core.Content;
using Bit.App.Utilities;
using ZXing.Net.Mobile.Android; using ZXing.Net.Mobile.Android;
namespace Bit.Droid namespace Bit.Droid
@ -30,7 +30,7 @@ namespace Bit.Droid
LaunchMode = LaunchMode.SingleTask, LaunchMode = LaunchMode.SingleTask,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation |
ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden |
ConfigChanges.Navigation)] ConfigChanges.Navigation | ConfigChanges.UiMode)]
[IntentFilter( [IntentFilter(
new[] { Intent.ActionSend }, new[] { Intent.ActionSend },
Categories = new[] { Intent.CategoryDefault }, Categories = new[] { Intent.CategoryDefault },
@ -81,7 +81,6 @@ namespace Bit.Droid
TabLayoutResource = Resource.Layout.Tabbar; TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar; ToolbarResource = Resource.Layout.Toolbar;
UpdateTheme(ThemeManager.GetTheme(true));
base.OnCreate(savedInstanceState); base.OnCreate(savedInstanceState);
if (!CoreHelpers.InDebugMode()) if (!CoreHelpers.InDebugMode())
{ {
@ -118,7 +117,7 @@ namespace Bit.Droid
} }
else if (message.Command == "updatedTheme") else if (message.Command == "updatedTheme")
{ {
RestartApp(); Xamarin.Forms.Device.BeginInvokeOnMainThread(() => AppearanceAdjustments());
} }
else if (message.Command == "exit") else if (message.Command == "exit")
{ {
@ -141,6 +140,7 @@ namespace Bit.Droid
{ {
base.OnResume(); base.OnResume();
Xamarin.Essentials.Platform.OnResume(); Xamarin.Essentials.Platform.OnResume();
AppearanceAdjustments();
if (_deviceActionService.SupportsNfc()) if (_deviceActionService.SupportsNfc())
{ {
try try
@ -382,45 +382,10 @@ namespace Bit.Droid
} }
} }
private void UpdateTheme(string theme) private void AppearanceAdjustments()
{ {
if (theme == "light") Window?.SetStatusBarColor(ThemeHelpers.NavBarBackgroundColor);
{ ThemeHelpers.SetAppearance(ThemeManager.GetTheme(true), ThemeManager.OsDarkModeEnabled());
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);
} }
private void ExitApp() 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 Android.Views.InputMethods;
using Bit.Droid.Renderers; using Bit.Droid.Renderers;
using Bit.Droid.Utilities;
using Xamarin.Forms; using Xamarin.Forms;
using Xamarin.Forms.Platform.Android; using Xamarin.Forms.Platform.Android;
@ -25,6 +28,7 @@ namespace Bit.Droid.Renderers
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e) protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
{ {
base.OnElementChanged(e); base.OnElementChanged(e);
UpdateBorderColor();
if (Control != null && e.NewElement != null) if (Control != null && e.NewElement != null)
{ {
Control.SetPadding(Control.PaddingLeft, Control.PaddingTop - 10, Control.PaddingRight, Control.SetPadding(Control.PaddingLeft, Control.PaddingTop - 10, Control.PaddingRight,
@ -33,5 +37,33 @@ namespace Bit.Droid.Renderers
(ImeAction)ImeFlags.NoExtractUi; (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 System.ComponentModel;
using Android.Content; using Android.Content;
using Android.Content.Res;
using Android.Graphics; using Android.Graphics;
using Android.Text; using Android.Text;
using Android.Views.InputMethods; using Android.Views.InputMethods;
using Android.Widget; using Android.Widget;
using Bit.Droid.Renderers; using Bit.Droid.Renderers;
using Bit.Droid.Utilities;
using Xamarin.Forms; using Xamarin.Forms;
using Xamarin.Forms.Platform.Android; using Xamarin.Forms.Platform.Android;
@ -20,6 +22,7 @@ namespace Bit.Droid.Renderers
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e) protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{ {
base.OnElementChanged(e); base.OnElementChanged(e);
UpdateBorderColor();
if (Control != null && e.NewElement != null) if (Control != null && e.NewElement != null)
{ {
Control.SetPadding(Control.PaddingLeft, Control.PaddingTop - 10, Control.PaddingRight, 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.Renderers;
using Bit.Droid.Utilities;
using Xamarin.Forms; using Xamarin.Forms;
using Xamarin.Forms.Platform.Android; using Xamarin.Forms.Platform.Android;
@ -15,11 +18,40 @@ namespace Bit.Droid.Renderers
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e) protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{ {
base.OnElementChanged(e); base.OnElementChanged(e);
UpdateBorderColor();
if (Control != null && e.NewElement != null) if (Control != null && e.NewElement != null)
{ {
Control.SetPadding(Control.PaddingLeft, Control.PaddingTop - 10, Control.PaddingRight, Control.SetPadding(Control.PaddingLeft, Control.PaddingTop - 10, Control.PaddingRight,
Control.PaddingBottom + 20); 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 Android.Content;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Utilities;
using Bit.Droid.Renderers; using Bit.Droid.Renderers;
using Xamarin.Forms; using Xamarin.Forms;
using Xamarin.Forms.Platform.Android; using Xamarin.Forms.Platform.Android;
@ -10,8 +9,6 @@ namespace Bit.Droid.Renderers
{ {
public class ExtendedGridRenderer : ViewRenderer public class ExtendedGridRenderer : ViewRenderer
{ {
private static int? _bgResId;
public ExtendedGridRenderer(Context context) : base(context) { } public ExtendedGridRenderer(Context context) : base(context) { }
protected override void OnElementChanged(ElementChangedEventArgs<View> elementChangedEvent) protected override void OnElementChanged(ElementChangedEventArgs<View> elementChangedEvent)
@ -19,25 +16,8 @@ namespace Bit.Droid.Renderers
base.OnElementChanged(elementChangedEvent); base.OnElementChanged(elementChangedEvent);
if (elementChangedEvent.NewElement != null) 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 Android.Graphics.Drawables;
using AndroidX.Core.Content.Resources; using AndroidX.Core.Content.Resources;
using Bit.App.Controls; using Bit.App.Controls;
@ -18,6 +19,21 @@ namespace Bit.Droid.Renderers
protected override void OnElementChanged(ElementChangedEventArgs<Slider> e) protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
{ {
base.OnElementChanged(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) if (Control != null && Element is ExtendedSlider view)
{ {
var t = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.slider_thumb, null); var t = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.slider_thumb, null);

View file

@ -1,6 +1,5 @@
using Android.Content; using Android.Content;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Utilities;
using Bit.Droid.Renderers; using Bit.Droid.Renderers;
using Xamarin.Forms; using Xamarin.Forms;
using Xamarin.Forms.Platform.Android; using Xamarin.Forms.Platform.Android;
@ -10,8 +9,6 @@ namespace Bit.Droid.Renderers
{ {
public class ExtendedStackLayoutRenderer : ViewRenderer public class ExtendedStackLayoutRenderer : ViewRenderer
{ {
private static int? _bgResId;
public ExtendedStackLayoutRenderer(Context context) : base(context) { } public ExtendedStackLayoutRenderer(Context context) : base(context) { }
protected override void OnElementChanged(ElementChangedEventArgs<View> elementChangedEvent) protected override void OnElementChanged(ElementChangedEventArgs<View> elementChangedEvent)
@ -19,25 +16,8 @@ namespace Bit.Droid.Renderers
base.OnElementChanged(elementChangedEvent); base.OnElementChanged(elementChangedEvent);
if (elementChangedEvent.NewElement != null) 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"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<color android:color="@color/lightgray"/> <color android:color="@color/white"/>
</item> </item>
<item <item
android:drawable="@drawable/logo" android:drawable="@drawable/logo"

View file

@ -1,5 +1,5 @@
<ripple xmlns:android="http://schemas.android.com/apk/res/android" <ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/itemPressed"> android:color="#8E8E93">
<item <item
android:id="@android:id/mask" 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"?> <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<color android:color="@color/lightgray"/> <color android:color="@color/white"/>
</item> </item>
<item> <item>
<bitmap android:src="@drawable/logo_legacy" android:tileMode="disabled" android:gravity="center"/> <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" ?> <?xml version="1.0" encoding="utf-8" ?>
<resources> <resources>
<!-- Launch theme (for auto dark/light based on system) --> <!-- 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:windowBackground">@drawable/splash_screen_dark</item>
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
</style> </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> </resources>

View file

@ -1,38 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<!-- Light theme --> <!-- Light System -->
<color name="colorPrimary">#175DDC</color> <color name="colorPrimary">#175DDC</color>
<color name="colorPrimaryDark">#1A3B66</color> <color name="colorPrimaryDark">#1A3B66</color>
<color name="primary">#175DDC</color> <color name="primary">#175DDC</color>
<color name="notificationBar">#1452BC</color> <color name="notificationBar">#1452BC</color>
<color name="border">#dddddd</color> <color name="border">#dddddd</color>
<color name="itemPressed">#bbbbbb</color>
<!-- Dark theme --> <!-- Dark System -->
<color name="dark_primary">#52bdfb</color> <color name="dark_primary">#52bdfb</color>
<color name="dark_notificationBar">#191919</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> <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 --> <!-- Other -->
<color name="launcher_background">#FFFFFF</color>
<color name="white">#FFFFFF</color> <color name="white">#FFFFFF</color>
<color name="black">#000000</color> <color name="black">#000000</color>
<color name="darkgray">#333333</color> <color name="darkgray">#333333</color>

View file

@ -1,21 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?> <?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) --> <!-- 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:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
</style> </style>
<!-- Light theme --> <style name="BaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<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">
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
<item name="colorPrimary">@color/primary</item> <item name="colorPrimary">@color/primary</item>
@ -27,70 +18,10 @@
<item name="android:colorActivatedHighlight">@android:color/transparent</item> <item name="android:colorActivatedHighlight">@android:color/transparent</item>
<item name="android:textCursorDrawable">@null</item> <item name="android:textCursorDrawable">@null</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item> <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="buttonStyle">@style/ButtonStyle</item>
</style> </style>
<!-- Dark theme --> <style name="ButtonStyle" parent="Widget.AppCompat.Button">
<style name="DarkTheme" parent="DarkTheme.Base"> <item name="android:textAllCaps">false</item>
</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>
</resources> </resources>

View file

@ -8,7 +8,6 @@ using Android.App;
using Android.App.Assist; using Android.App.Assist;
using Android.Content; using Android.Content;
using Android.Content.PM; using Android.Content.PM;
using Android.Content.Res;
using Android.Nfc; using Android.Nfc;
using Android.OS; using Android.OS;
using Android.Provider; using Android.Provider;
@ -640,19 +639,12 @@ namespace Bit.Droid.Services
} }
public bool AutofillAccessibilityServiceRunning() public bool AutofillAccessibilityServiceRunning()
{
try
{ {
var activity = (MainActivity)CrossCurrentActivity.Current.Activity; var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
var manager = activity.GetSystemService(Context.ActivityService) as ActivityManager; var enabledServices = Settings.Secure.GetString(activity.ContentResolver,
var services = manager.GetRunningServices(int.MaxValue); Settings.Secure.EnabledAccessibilityServices);
return services.Any(s => s.Process.ToLowerInvariant().Contains("bitwarden") && return Application.Context.PackageName != null &&
s.Service.ClassName.ToLowerInvariant().Contains("accessibilityservice")); (enabledServices?.Contains(Application.Context.PackageName) ?? false);
}
catch
{
return false;
}
} }
public bool AutofillAccessibilityOverlayPermitted() 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() public long GetActiveTime()
{ {
// Returns milliseconds since the system was booted, and includes deep sleep. This clock is guaranteed to // 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 OpenAccessibilitySettings();
void OpenAccessibilityOverlayPermissionSettings(); void OpenAccessibilityOverlayPermissionSettings();
void OpenAutofillSettings(); void OpenAutofillSettings();
bool UsingDarkTheme();
long GetActiveTime(); long GetActiveTime();
void CloseMainApp(); void CloseMainApp();
bool SupportsFido2(); bool SupportsFido2();

View file

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

View file

@ -5,7 +5,7 @@ namespace Bit.App.Controls
public class ExtendedSlider : Slider public class ExtendedSlider : Slider
{ {
public static readonly BindableProperty ThumbBorderColorProperty = BindableProperty.Create( 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 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> HorizontalTextAlignment="Center"></Label>
<StackLayout Spacing="5"> <StackLayout Spacing="5">
<Button Text="{u:I18n LogIn}" <Button Text="{u:I18n LogIn}"
Clicked="LogIn_Clicked"></Button> StyleClass="btn-primary"
Clicked="LogIn_Clicked" />
<Button Text="{u:I18n CreateAccount}" <Button Text="{u:I18n CreateAccount}"
Clicked="Register_Clicked"></Button> Clicked="Register_Clicked" />
<Button Text="{u:I18n LogInSso}" <Button Text="{u:I18n LogInSso}"
Clicked="LogInSso_Clicked"></Button> Clicked="LogInSso_Clicked" />
</StackLayout> </StackLayout>
</StackLayout> </StackLayout>
</StackLayout> </StackLayout>

View file

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

View file

@ -120,7 +120,9 @@
IsVisible="{Binding BiometricIntegrityValid, Converter={StaticResource inverseBool}}" /> IsVisible="{Binding BiometricIntegrityValid, Converter={StaticResource inverseBool}}" />
<Button Text="{Binding BiometricButtonText}" Clicked="Biometric_Clicked" <Button Text="{Binding BiometricButtonText}" Clicked="Biometric_Clicked"
IsVisible="{Binding BiometricButtonVisible}"></Button> 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>
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>

View file

@ -82,7 +82,9 @@
</Grid> </Grid>
</StackLayout> </StackLayout>
<StackLayout Padding="10, 0"> <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>
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>

View file

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

View file

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

View file

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

View file

@ -1,6 +1,8 @@
using Bit.App.Resources; using Bit.App.Resources;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using Xamarin.Forms; using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration; using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific; using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
@ -9,6 +11,8 @@ namespace Bit.App.Pages
{ {
public partial class GeneratorPage : BaseContentPage public partial class GeneratorPage : BaseContentPage
{ {
private readonly IBroadcasterService _broadcasterService;
private GeneratorPageViewModel _vm; private GeneratorPageViewModel _vm;
private readonly bool _fromTabPage; private readonly bool _fromTabPage;
private readonly Action<string> _selectAction; private readonly Action<string> _selectAction;
@ -18,6 +22,7 @@ namespace Bit.App.Pages
{ {
_tabsPage = tabsPage; _tabsPage = tabsPage;
InitializeComponent(); InitializeComponent();
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
_vm = BindingContext as GeneratorPageViewModel; _vm = BindingContext as GeneratorPageViewModel;
_vm.Page = this; _vm.Page = this;
_fromTabPage = fromTabPage; _fromTabPage = fromTabPage;
@ -60,6 +65,22 @@ namespace Bit.App.Pages
{ {
await InitAsync(); 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() protected override bool OnBackButtonPressed()

View file

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

View file

@ -54,26 +54,6 @@
x:Name="_deleteItem" x:Name="_deleteItem"
x:Key="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"> <ScrollView x:Key="scrollView" x:Name="_scrollView">
<StackLayout Spacing="20"> <StackLayout Spacing="20">
<StackLayout StyleClass="box"> <StackLayout StyleClass="box">
@ -131,51 +111,25 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button <Button
Text="{u:I18n TypeFile}" Text="{u:I18n TypeFile}"
StyleClass="segmented-button"
IsEnabled="{Binding IsText}" IsEnabled="{Binding IsText}"
HeightRequest="{Binding SegmentedButtonHeight}"
FontSize="{Binding SegmentedButtonFontSize}"
Clicked="FileType_Clicked" Clicked="FileType_Clicked"
AutomationProperties.IsInAccessibleTree="True" AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n File}" AutomationProperties.Name="{u:I18n File}"
Grid.Column="0"> 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>
<Button <Button
Text="{u:I18n TypeText}" Text="{u:I18n TypeText}"
StyleClass="segmented-button"
IsEnabled="{Binding IsFile}" IsEnabled="{Binding IsFile}"
HeightRequest="{Binding SegmentedButtonHeight}"
FontSize="{Binding SegmentedButtonFontSize}"
Clicked="TextType_Clicked" Clicked="TextType_Clicked"
AutomationProperties.IsInAccessibleTree="True" AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n Text}" AutomationProperties.Name="{u:I18n Text}"
Grid.Column="1"> 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> </Button>
</Grid> </Grid>
</StackLayout> </StackLayout>
@ -289,20 +243,20 @@
Text="{u:I18n Options}" Text="{u:I18n Options}"
x:Name="_btnOptions" x:Name="_btnOptions"
StyleClass="box-row-button" StyleClass="box-row-button"
TextColor="{StaticResource PrimaryColor}" TextColor="{DynamicResource PrimaryColor}"
Margin="0" /> Margin="0" />
<controls:FaButton <controls:FaButton
x:Name="_btnOptionsUp" x:Name="_btnOptionsUp"
Text="&#xf077;" Text="&#xf077;"
StyleClass="box-row-button" StyleClass="box-row-button"
TextColor="{StaticResource PrimaryColor}" TextColor="{DynamicResource PrimaryColor}"
Clicked="ToggleOptions_Clicked" Clicked="ToggleOptions_Clicked"
IsVisible="False" /> IsVisible="False" />
<controls:FaButton <controls:FaButton
x:Name="_btnOptionsDown" x:Name="_btnOptionsDown"
Text="&#xf078;" Text="&#xf078;"
StyleClass="box-row-button" StyleClass="box-row-button"
TextColor="{StaticResource PrimaryColor}" TextColor="{DynamicResource PrimaryColor}"
Clicked="ToggleOptions_Clicked" Clicked="ToggleOptions_Clicked"
IsVisible="False" /> IsVisible="False" />
</StackLayout> </StackLayout>
@ -421,7 +375,7 @@
MaxLength="9" MaxLength="9"
TextChanged="OnMaxAccessCountTextChanged" TextChanged="OnMaxAccessCountTextChanged"
HorizontalOptions="FillAndExpand" /> HorizontalOptions="FillAndExpand" />
<Stepper <controls:ExtendedStepper
x:Name="_maxAccessCountStepper" x:Name="_maxAccessCountStepper"
Value="{Binding MaxAccessCount}" Value="{Binding MaxAccessCount}"
Maximum="999999999" Maximum="999999999"

View file

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

View file

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

View file

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

View file

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

View file

@ -31,8 +31,7 @@
</StackLayout> </StackLayout>
<Label <Label
StyleClass="box-footer-label" StyleClass="box-footer-label"
Text="{u:I18n ThemeDescription}" Text="{u:I18n ThemeDescription}" />
x:Name="_themeDescriptionLabel" />
</StackLayout> </StackLayout>
<StackLayout StyleClass="box"> <StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-input, box-row-input-options-platform"> <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); ToolbarItems.RemoveAt(0);
_vm.ShowAndroidAutofillSettings = _deviceActionService.SupportsAutofillService(); _vm.ShowAndroidAutofillSettings = _deviceActionService.SupportsAutofillService();
_themeDescriptionLabel.Text = string.Concat(_themeDescriptionLabel.Text, " ",
AppResources.RestartIsRequired);
} }
else else
{ {

View file

@ -59,7 +59,7 @@ namespace Bit.App.Pages
} }
ThemeOptions = new List<KeyValuePair<string, string>> 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>("light", AppResources.Light),
new KeyValuePair<string, string>("dark", AppResources.Dark), new KeyValuePair<string, string>("dark", AppResources.Dark),
new KeyValuePair<string, string>("black", AppResources.Black), new KeyValuePair<string, string>("black", AppResources.Black),
@ -215,17 +215,8 @@ namespace Bit.App.Pages
{ {
var theme = ThemeOptions[ThemeSelectedIndex].Key; var theme = ThemeOptions[ThemeSelectedIndex].Key;
await _storageService.SaveAsync(Constants.ThemeKey, theme); await _storageService.SaveAsync(Constants.ThemeKey, theme);
if (Device.RuntimePlatform == Device.Android) ThemeManager.SetTheme(Device.RuntimePlatform == Device.Android, Application.Current.Resources);
{ _messagingService.Send("updatedTheme");
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);
}
} }
} }

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

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

View file

@ -6,46 +6,151 @@
<Style TargetType="Entry" <Style TargetType="Entry"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="PlaceholderColor" <Setter Property="PlaceholderColor"
Value="{StaticResource InputPlaceholderColor}" /> Value="{DynamicResource InputPlaceholderColor}" />
<Setter Property="TextColor"
Value="{DynamicResource TextColor}" />
<Setter Property="Margin" <Setter Property="Margin"
Value="-4, 0, -4, -4" /> Value="-4, 0, -4, -4" />
</Style> </Style>
<Style TargetType="Picker" <Style TargetType="Picker"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{DynamicResource TextColor}" />
<Setter Property="Margin" <Setter Property="Margin"
Value="-4, 0, -4, -4" /> Value="-4, 0, -4, -4" />
</Style> </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" <Style TargetType="Editor"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{DynamicResource TextColor}" />
<Setter Property="PlaceholderColor" <Setter Property="PlaceholderColor"
Value="{StaticResource InputPlaceholderColor}" /> Value="{DynamicResource InputPlaceholderColor}" />
<Setter Property="Margin" <Setter Property="Margin"
Value="-4, 0, -4, -4" /> Value="-4, 0, -4, -4" />
</Style> </Style>
<Style TargetType="Switch"
ApplyToDerivedTypes="True">
<Setter Property="OnColor"
Value="{DynamicResource SwitchOnColor}" />
</Style>
<Style TargetType="SearchBar" <Style TargetType="SearchBar"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor" <Setter Property="BackgroundColor"
Value="Transparent" /> Value="Transparent" />
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource TitleEntryTextColor}" /> Value="{DynamicResource TitleEntryTextColor}" />
<Setter Property="CancelButtonColor" <Setter Property="CancelButtonColor"
Value="{StaticResource TitleEntryTextColor}" /> Value="{DynamicResource TitleEntryTextColor}" />
<Setter Property="PlaceholderColor" <Setter Property="PlaceholderColor"
Value="{StaticResource TitleEntryPlaceholderColor}" /> Value="{DynamicResource TitleEntryPlaceholderColor}" />
</Style>
<Style TargetType="ContentPage"
ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor"
Value="{DynamicResource BackgroundColor}" />
</Style> </Style>
<Style TargetType="controls:ExtendedSlider"> <Style TargetType="controls:ExtendedSlider">
<Setter Property="MinimumTrackColor" <Setter Property="MinimumTrackColor"
Value="{StaticResource SliderTrackMinColor}" /> Value="{DynamicResource SliderTrackMinColor}" />
<Setter Property="MaximumTrackColor" <Setter Property="MaximumTrackColor"
Value="{StaticResource SliderTrackMinColor}" /> Value="{DynamicResource SliderTrackMinColor}" />
<Setter Property="ThumbColor" <Setter Property="ThumbColor"
Value="{StaticResource SliderThumbColor}" /> Value="{DynamicResource SliderThumbColor}" />
<Setter Property="ThumbBorderColor" <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> </Style>
<!-- Buttons --> <!-- 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" <Style TargetType="Button"
ApplyToDerivedTypes="True" ApplyToDerivedTypes="True"
Class="btn-icon-platform"> Class="btn-icon-platform">
@ -84,7 +189,7 @@
<Style TargetType="Label" <Style TargetType="Label"
Class="list-header-platform"> Class="list-header-platform">
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource ListHeaderTextColor}" /> Value="{DynamicResource ListHeaderTextColor}" />
<Setter Property="FontSize" <Setter Property="FontSize"
Value="Small" /> Value="Small" />
<Setter Property="FontAttributes" <Setter Property="FontAttributes"
@ -93,7 +198,7 @@
<Style TargetType="BoxView" <Style TargetType="BoxView"
Class="list-section-separator-top-platform"> Class="list-section-separator-top-platform">
<Setter Property="Color" <Setter Property="Color"
Value="{StaticResource ListItemBorderColor}" /> Value="{DynamicResource ListItemBorderColor}" />
</Style> </Style>
<Style TargetType="BoxView" <Style TargetType="BoxView"
Class="list-section-separator-bottom-platform"> Class="list-section-separator-bottom-platform">
@ -134,7 +239,7 @@
<Style TargetType="Label" <Style TargetType="Label"
Class="box-header-platform"> Class="box-header-platform">
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource BoxHeaderTextColor}" /> Value="{DynamicResource BoxHeaderTextColor}" />
<Setter Property="FontSize" <Setter Property="FontSize"
Value="Small" /> Value="Small" />
<Setter Property="FontAttributes" <Setter Property="FontAttributes"

View file

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

View file

@ -18,6 +18,8 @@
<Color x:Key="SplashBackgroundColor">#000000</Color> <Color x:Key="SplashBackgroundColor">#000000</Color>
<Color x:Key="BorderColor">#282828</Color> <Color x:Key="BorderColor">#282828</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</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="BoxBorderColor">#282828</Color>
<Color x:Key="BoxHeaderTextColor">#52bdfb</Color> <Color x:Key="BoxHeaderTextColor">#52bdfb</Color>
@ -38,9 +40,23 @@
<Color x:Key="SliderTrackMaxColor">#282828</Color> <Color x:Key="SliderTrackMaxColor">#282828</Color>
<Color x:Key="SwitchOnColor">#52bdfb</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="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="FabColor">#52bdfb</Color>
<Color x:Key="FabPressedColor">#3ea1da</Color> <Color x:Key="FabPressedColor">#3ea1da</Color>

View file

@ -18,6 +18,8 @@
<Color x:Key="SplashBackgroundColor">#222222</Color> <Color x:Key="SplashBackgroundColor">#222222</Color>
<Color x:Key="BorderColor">#191919</Color> <Color x:Key="BorderColor">#191919</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</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="BoxBorderColor">#191919</Color>
<Color x:Key="BoxHeaderTextColor">#52bdfb</Color> <Color x:Key="BoxHeaderTextColor">#52bdfb</Color>
@ -38,9 +40,23 @@
<Color x:Key="SliderTrackMaxColor">#191919</Color> <Color x:Key="SliderTrackMaxColor">#191919</Color>
<Color x:Key="SwitchOnColor">#52bdfb</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="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="FabColor">#52bdfb</Color>
<Color x:Key="FabPressedColor">#3ea1da</Color> <Color x:Key="FabPressedColor">#3ea1da</Color>

View file

@ -15,9 +15,11 @@
<Color x:Key="InputPlaceholderColor">#d0d0d0</Color> <Color x:Key="InputPlaceholderColor">#d0d0d0</Color>
<Color x:Key="BackgroundColor">#ffffff</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="BorderColor">#dddddd</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</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="BoxBorderColor">#dddddd</Color>
<Color x:Key="BoxHeaderTextColor">#175DDC</Color> <Color x:Key="BoxHeaderTextColor">#175DDC</Color>
@ -38,9 +40,23 @@
<Color x:Key="SliderTrackMaxColor">#dddddd</Color> <Color x:Key="SliderTrackMaxColor">#dddddd</Color>
<Color x:Key="SwitchOnColor">#175DDC</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="ButtonTextColor">#000000</Color>
<Color x:Key="ButtonBackgroundColor">#dddddd</Color> <Color x:Key="ButtonTextColorDisabled">#aaaaaa</Color>
<Color x:Key="FabColor">#175DDC</Color> <Color x:Key="FabColor">#175DDC</Color>
<Color x:Key="FabPressedColor">#3883af</Color> <Color x:Key="FabPressedColor">#3883af</Color>

View file

@ -18,6 +18,8 @@
<Color x:Key="SplashBackgroundColor">#2e3440</Color> <Color x:Key="SplashBackgroundColor">#2e3440</Color>
<Color x:Key="BorderColor">#2e3440</Color> <Color x:Key="BorderColor">#2e3440</Color>
<Color x:Key="DisabledIconColor">#d8dee9</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="BoxBorderColor">#2e3440</Color>
<Color x:Key="BoxHeaderTextColor">#81a1c1</Color> <Color x:Key="BoxHeaderTextColor">#81a1c1</Color>
@ -38,9 +40,23 @@
<Color x:Key="SliderTrackMaxColor">#2e3440</Color> <Color x:Key="SliderTrackMaxColor">#2e3440</Color>
<Color x:Key="SwitchOnColor">#81a1c1</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="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="FabColor">#81a1c1</Color>
<Color x:Key="FabPressedColor">#81a1c1</Color> <Color x:Key="FabPressedColor">#81a1c1</Color>

View file

@ -6,84 +6,171 @@
<Style TargetType="Entry" <Style TargetType="Entry"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="PlaceholderColor" <Setter Property="PlaceholderColor"
Value="{StaticResource InputPlaceholderColor}" /> Value="{DynamicResource InputPlaceholderColor}" />
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource TextColor}" /> Value="{DynamicResource TextColor}" />
<Setter Property="Margin" <Setter Property="Margin"
Value="0, 5, 0, 12" /> Value="0, 5, 0, 12" />
</Style> </Style>
<Style TargetType="Picker" <Style TargetType="Picker"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource TextColor}" /> Value="{DynamicResource TextColor}" />
<Setter Property="Margin" <Setter Property="Margin"
Value="0, 5, 0, 12" /> Value="0, 5, 0, 12" />
</Style> </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" <Style TargetType="Editor"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource TextColor}" /> Value="{DynamicResource TextColor}" />
<Setter Property="BackgroundColor" <Setter Property="BackgroundColor"
Value="{StaticResource BackgroundColor}" /> Value="{DynamicResource BackgroundColor}" />
<Setter Property="PlaceholderColor" <Setter Property="PlaceholderColor"
Value="{StaticResource InputPlaceholderColor}" /> Value="{DynamicResource InputPlaceholderColor}" />
<Setter Property="Margin" <Setter Property="Margin"
Value="0, 0, 0, 12" /> Value="0, 0, 0, 12" />
</Style> </Style>
<Style TargetType="Switch" <Style TargetType="Switch"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="OnColor" <Setter Property="OnColor"
Value="{StaticResource SwitchOnColor}" /> Value="{DynamicResource SwitchOnColor}" />
</Style> </Style>
<Style TargetType="SearchBar" <Style TargetType="SearchBar"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor" <Setter Property="BackgroundColor"
Value="{StaticResource ListHeaderBackgroundColor}" /> Value="{DynamicResource ListHeaderBackgroundColor}" />
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource TextColor}" /> Value="{DynamicResource TextColor}" />
<Setter Property="CancelButtonColor" <Setter Property="CancelButtonColor"
Value="{StaticResource PrimaryColor}" /> Value="{DynamicResource PrimaryColor}" />
<Setter Property="PlaceholderColor" <Setter Property="PlaceholderColor"
Value="#777777" /> Value="#777777" />
</Style> </Style>
<Style TargetType="ContentPage" <Style TargetType="ContentPage"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor" <Setter Property="BackgroundColor"
Value="{StaticResource BackgroundColor}" /> Value="{DynamicResource BackgroundColor}" />
</Style> </Style>
<Style TargetType="CollectionView" <Style TargetType="CollectionView"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor" <Setter Property="BackgroundColor"
Value="{StaticResource BackgroundColor}" /> Value="{DynamicResource BackgroundColor}" />
</Style> </Style>
<Style TargetType="RefreshView" <Style TargetType="RefreshView"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="RefreshColor" <Setter Property="RefreshColor"
Value="{StaticResource PrimaryColor}" /> Value="{DynamicResource PrimaryColor}" />
</Style> </Style>
<Style TargetType="ActivityIndicator" <Style TargetType="ActivityIndicator"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="Color" <Setter Property="Color"
Value="{StaticResource PrimaryColor}" /> Value="{DynamicResource PrimaryColor}" />
</Style> </Style>
<Style TargetType="controls:ExtendedSlider"> <Style TargetType="controls:ExtendedSlider">
<Setter Property="MinimumTrackColor" <Setter Property="MinimumTrackColor"
Value="{StaticResource SliderTrackMinColor}" /> Value="{DynamicResource SliderTrackMinColor}" />
<Setter Property="MaximumTrackColor" <Setter Property="MaximumTrackColor"
Value="{StaticResource SliderTrackMaxColor}" /> Value="{DynamicResource SliderTrackMaxColor}" />
<Setter Property="ThumbColor" <Setter Property="ThumbColor"
Value="{StaticResource SliderThumbColor}" /> Value="{DynamicResource SliderThumbColor}" />
</Style>
<Style TargetType="controls:ExtendedStepper">
<Setter Property="StepperForegroundColor"
Value="{DynamicResource StepperForegroundColor}" />
</Style> </Style>
<!-- Buttons --> <!-- Buttons -->
<Style TargetType="Button"> <Style TargetType="Button">
<Setter Property="BackgroundColor" <Setter Property="BackgroundColor"
Value="{StaticResource ButtonBackgroundColor}" /> Value="{DynamicResource ButtonBackgroundColor}" />
<Setter Property="BorderColor"
Value="{DynamicResource ButtonBorderColor}" />
<Setter Property="BorderWidth"
Value="1" />
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource ButtonTextColor}" /> Value="{DynamicResource ButtonTextColor}" />
<Setter Property="FontSize"
Value="18" />
<Setter Property="Margin" <Setter Property="Margin"
Value="0, 5, 0, 0" /> 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>
<Style TargetType="Button" <Style TargetType="Button"
ApplyToDerivedTypes="True" ApplyToDerivedTypes="True"
@ -100,12 +187,12 @@
Class="list-item-separator-bottom-platform" Class="list-item-separator-bottom-platform"
ApplyToDerivedTypes="True"> ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor" <Setter Property="BackgroundColor"
Value="{StaticResource ListItemBorderColor}" /> Value="{DynamicResource ListItemBorderColor}" />
</Style> </Style>
<Style TargetType="StackLayout" <Style TargetType="StackLayout"
Class="list-row-header-container-platform"> Class="list-row-header-container-platform">
<Setter Property="BackgroundColor" <Setter Property="BackgroundColor"
Value="{StaticResource ListHeaderBackgroundColor}" /> Value="{DynamicResource ListHeaderBackgroundColor}" />
</Style> </Style>
<Style TargetType="StackLayout" <Style TargetType="StackLayout"
Class="list-row-header-platform"> Class="list-row-header-platform">
@ -117,19 +204,19 @@
<Style TargetType="Label" <Style TargetType="Label"
Class="list-header-platform"> Class="list-header-platform">
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource MutedColor}" /> Value="{DynamicResource MutedColor}" />
<Setter Property="FontSize" <Setter Property="FontSize"
Value="Small" /> Value="Small" />
</Style> </Style>
<Style TargetType="BoxView" <Style TargetType="BoxView"
Class="list-section-separator-top-platform"> Class="list-section-separator-top-platform">
<Setter Property="Color" <Setter Property="Color"
Value="{StaticResource ListSectionBorderColor}" /> Value="{DynamicResource ListSectionBorderColor}" />
</Style> </Style>
<Style TargetType="BoxView" <Style TargetType="BoxView"
Class="list-section-separator-bottom-platform"> Class="list-section-separator-bottom-platform">
<Setter Property="Color" <Setter Property="Color"
Value="{StaticResource ListSectionBorderBottomColor}" /> Value="{DynamicResource ListSectionBorderBottomColor}" />
</Style> </Style>
<Style TargetType="StackLayout" <Style TargetType="StackLayout"
Class="list-row-platform"> Class="list-row-platform">
@ -163,7 +250,7 @@
<Style TargetType="Label" <Style TargetType="Label"
Class="box-header-platform"> Class="box-header-platform">
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource BoxHeaderTextColor}" /> Value="{DynamicResource BoxHeaderTextColor}" />
<Setter Property="FontSize" <Setter Property="FontSize"
Value="Small" /> Value="Small" />
<Setter Property="FontAttributes" <Setter Property="FontAttributes"

View file

@ -1,9 +1,8 @@
using System; using System;
using Bit.App.Abstractions; using Bit.App.Models;
using Bit.App.Services; using Bit.App.Services;
using Bit.App.Styles; using Bit.App.Styles;
using Bit.Core; using Bit.Core;
using Bit.Core.Utilities;
using Xamarin.Forms; using Xamarin.Forms;
namespace Bit.App.Utilities namespace Bit.App.Utilities
@ -47,8 +46,7 @@ namespace Bit.App.Utilities
} }
else else
{ {
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService", true); if (OsDarkModeEnabled())
if (deviceActionService?.UsingDarkTheme() ?? false)
{ {
resources.MergedDictionaries.Add(new Dark()); resources.MergedDictionaries.Add(new Dark());
UsingLightTheme = false; UsingLightTheme = false;
@ -86,6 +84,17 @@ namespace Bit.App.Utilities
!android ? "group.com.8bit.bitwarden" : default(string)); !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) public static void ApplyResourcesToPage(ContentPage page)
{ {
foreach (var resourceDict in Resources().MergedDictionaries) foreach (var resourceDict in Resources().MergedDictionaries)

View file

@ -336,7 +336,9 @@ namespace Bit.iOS.Autofill
_initedAppCenter = true; _initedAppCenter = true;
} }
iOSCoreHelpers.Bootstrap(); 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) => _nfcDelegate = new Core.NFCReaderDelegate((success, message) =>
messagingService.Send("gotYubiKeyOTP", message)); messagingService.Send("gotYubiKeyOTP", message));
iOSCoreHelpers.SubscribeBroadcastReceiver(this, _nfcSession, _nfcDelegate); iOSCoreHelpers.SubscribeBroadcastReceiver(this, _nfcSession, _nfcDelegate);

View file

@ -72,6 +72,8 @@
<string>FontAwesome.ttf</string> <string>FontAwesome.ttf</string>
<string>MaterialIcons_Regular.ttf</string> <string>MaterialIcons_Regular.ttf</string>
</array> </array>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIRequiredDeviceCapabilities</key> <key>UIRequiredDeviceCapabilities</key>
<dict> <dict>
<key>arm64</key> <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;
using Xamarin.Forms.Platform.iOS; using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(TabbedPage), typeof(CustomTabbedRenderer))] [assembly: ExportRenderer(typeof(TabbedPage), typeof(CustomTabbedRenderer))]
namespace Bit.iOS.Core.Renderers namespace Bit.iOS.Core.Renderers
{ {
public class CustomTabbedRenderer : TabbedRenderer 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) protected override void OnElementChanged(VisualElementChangedEventArgs e)
{ {
base.OnElementChanged(e); base.OnElementChanged(e);
TabBar.Translucent = false; TabBar.Translucent = false;
TabBar.Opaque = true; 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(); throw new NotImplementedException();
} }
public bool UsingDarkTheme()
{
try
{
if (SystemMajorVersion() > 12)
{
return UIScreen.MainScreen.TraitCollection.UserInterfaceStyle == UIUserInterfaceStyle.Dark;
}
}
catch { }
return false;
}
public long GetActiveTime() public long GetActiveTime()
{ {
// Fall back to UnixTimeMilliseconds in case this approach stops working. We'll lose clock-change // 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; using Xamarin.Forms.Platform.iOS;
namespace Bit.iOS.Core.Utilities namespace Bit.iOS.Core.Utilities
@ -6,24 +7,63 @@ namespace Bit.iOS.Core.Utilities
public static class ThemeHelpers public static class ThemeHelpers
{ {
public static bool LightTheme = true; 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; get => ThemeManager.GetResourceColor("SplashBackgroundColor").ToUIColor();
SetThemeVariables(theme); }
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.ShadowImage = new UIImage();
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
UIStepper.Appearance.TintColor = MutedColor; 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() public static UIFont GetDangerFont()
{ {
return Xamarin.Forms.Font.SystemFontOfSize(Xamarin.Forms.NamedSize.Small, return Xamarin.Forms.Font.SystemFontOfSize(Xamarin.Forms.NamedSize.Small,
Xamarin.Forms.FontAttributes.Bold).ToUIFont(); 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) && osDarkModeEnabled)
if (string.IsNullOrWhiteSpace(theme) && UsingOsDarkTheme)
{ {
theme = "dark"; theme = "dark";
} }
if (theme == "dark") if (theme == "dark" || theme == "black" || theme == "nord")
{ {
var whiteColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor(); LightTheme = false;
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();
} }
else else
{ {

View file

@ -84,9 +84,9 @@ namespace Bit.iOS.Core.Utilities
var bootstrapTask = BootstrapAsync(postBootstrapFunc); 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.StatusBarHidden = false;
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent; UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
} }

View file

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

View file

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

View file

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

View file

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

View file

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