mirror of
https://github.com/bitwarden/mobile
synced 2026-01-10 20:43:41 +00:00
* Initial commit of LockService name refactor (#831) * [Auto-Logout] Update Service layer logic (#835) * Initial commit of service logic update * Added default value for action * Updated ToggleTokensAsync conditional * Removed unused variables, updated action conditional * Initial commit: lockOption/lock refactor app layer (#840) * [Auto-Logout] Settings Refactor - Application Layer Part 2 (#844) * Initial commit of app layer part 2 * Updated biometrics position * Reverted resource name refactor * LockOptions refactor revert * Updated method casing :: Removed VaultTimeout prefix for timeouts * Fixed dupe string resource (#854) * Updated dependency to use VaultTimeoutService (#896) * [Auto Logout] Xamarin Forms in AutoFill flow (iOS) (#902) * fix typo in PINRequireMasterPasswordRestart (#900) * initial commit for xf usage in autofill * Fixed databinding for hint button * Updated Two Factor page launch - removed unused imports * First pass at broadcast/messenger implentation for autofill * setting theme in extension using theme manager * extension app resources * App resources from main app * fix ref to twoFactorPage * apply resources to page * load empty app for sytling in extension * move ios renderers to ios core * static ref to resources and GetResourceColor helper * fix method ref * move application.current.resources refs to helper * switch login page alerts to device action dialogs * run on main thread * showDialog with device action service * abstract action sheet to device action service * add support for yubikey * add yubikey iimages to extension * support close button action * add support to action extension * remove empty lines Co-authored-by: Jonas Kittner <54631600+theendlessriver13@users.noreply.github.com> Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com> * [Auto Logout] Update lock option to be default value (#929) * Initial commit - make lock action default * Removed extra whitespace Co-authored-by: Jonas Kittner <54631600+theendlessriver13@users.noreply.github.com> Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com> Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com>
103 lines
3.1 KiB
C#
103 lines
3.1 KiB
C#
using System;
|
|
using Bit.App.Abstractions;
|
|
using Bit.App.Services;
|
|
using Bit.App.Styles;
|
|
using Bit.Core;
|
|
using Bit.Core.Utilities;
|
|
using Xamarin.Forms;
|
|
|
|
namespace Bit.App.Utilities
|
|
{
|
|
public static class ThemeManager
|
|
{
|
|
public static bool UsingLightTheme = true;
|
|
public static Func<ResourceDictionary> Resources = () => null;
|
|
|
|
public static void SetThemeStyle(string name, ResourceDictionary resources)
|
|
{
|
|
Resources = () => resources;
|
|
|
|
// Reset styles
|
|
resources.Clear();
|
|
resources.MergedDictionaries.Clear();
|
|
|
|
// Variables
|
|
resources.MergedDictionaries.Add(new Variables());
|
|
|
|
// Themed variables
|
|
if (name == "dark")
|
|
{
|
|
resources.MergedDictionaries.Add(new Dark());
|
|
UsingLightTheme = false;
|
|
}
|
|
else if (name == "black")
|
|
{
|
|
resources.MergedDictionaries.Add(new Black());
|
|
UsingLightTheme = false;
|
|
}
|
|
else if (name == "nord")
|
|
{
|
|
resources.MergedDictionaries.Add(new Nord());
|
|
UsingLightTheme = false;
|
|
}
|
|
else if (name == "light")
|
|
{
|
|
resources.MergedDictionaries.Add(new Light());
|
|
UsingLightTheme = true;
|
|
}
|
|
else
|
|
{
|
|
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService", true);
|
|
if (deviceActionService?.UsingDarkTheme() ?? false)
|
|
{
|
|
resources.MergedDictionaries.Add(new Dark());
|
|
UsingLightTheme = false;
|
|
}
|
|
else
|
|
{
|
|
resources.MergedDictionaries.Add(new Light());
|
|
UsingLightTheme = true;
|
|
}
|
|
}
|
|
|
|
// Base styles
|
|
resources.MergedDictionaries.Add(new Base());
|
|
|
|
// Platform styles
|
|
if (Device.RuntimePlatform == Device.Android)
|
|
{
|
|
resources.MergedDictionaries.Add(new Android());
|
|
}
|
|
else if (Device.RuntimePlatform == Device.iOS)
|
|
{
|
|
resources.MergedDictionaries.Add(new iOS());
|
|
}
|
|
}
|
|
|
|
public static void SetTheme(bool android, ResourceDictionary resources)
|
|
{
|
|
SetThemeStyle(GetTheme(android), resources);
|
|
}
|
|
|
|
public static string GetTheme(bool android)
|
|
{
|
|
return Xamarin.Essentials.Preferences.Get(
|
|
string.Format(PreferencesStorageService.KeyFormat, Constants.ThemeKey), default(string),
|
|
!android ? "group.com.8bit.bitwarden" : default(string));
|
|
}
|
|
|
|
public static void ApplyResourcesToPage(ContentPage page)
|
|
{
|
|
foreach (var resourceDict in Resources().MergedDictionaries)
|
|
{
|
|
page.Resources.Add(resourceDict);
|
|
}
|
|
}
|
|
|
|
public static Color GetResourceColor(string color)
|
|
{
|
|
return (Color)Resources()[color];
|
|
}
|
|
}
|
|
}
|