diff --git a/src/iOS.Autofill/CredentialProviderViewController.cs b/src/iOS.Autofill/CredentialProviderViewController.cs index bdd77a0f5..c42acbdb6 100644 --- a/src/iOS.Autofill/CredentialProviderViewController.cs +++ b/src/iOS.Autofill/CredentialProviderViewController.cs @@ -243,6 +243,7 @@ namespace Bit.iOS.Autofill private void InitApp() { + iOSCoreHelpers.AppearanceAdjustments(); if(ServiceContainer.RegisteredServices.Count > 0) { return; @@ -251,7 +252,6 @@ namespace Bit.iOS.Autofill ServiceContainer.Init(); iOSCoreHelpers.RegisterHockeyApp(); iOSCoreHelpers.Bootstrap(); - iOSCoreHelpers.AppearanceAdjustments(); } } } \ No newline at end of file diff --git a/src/iOS.Autofill/LoginListViewController.cs b/src/iOS.Autofill/LoginListViewController.cs index cf22c4452..633e918ef 100644 --- a/src/iOS.Autofill/LoginListViewController.cs +++ b/src/iOS.Autofill/LoginListViewController.cs @@ -18,13 +18,6 @@ namespace Bit.iOS.Autofill public Context Context { get; set; } public CredentialProviderViewController CPViewController { get; set; } - public override void ViewWillAppear(bool animated) - { - UINavigationBar.Appearance.ShadowImage = new UIImage(); - UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); - base.ViewWillAppear(animated); - } - public async override void ViewDidLoad() { base.ViewDidLoad(); diff --git a/src/iOS.Autofill/LoginSearchViewController.cs b/src/iOS.Autofill/LoginSearchViewController.cs index c240e4895..55723f6c0 100644 --- a/src/iOS.Autofill/LoginSearchViewController.cs +++ b/src/iOS.Autofill/LoginSearchViewController.cs @@ -6,6 +6,7 @@ using Bit.iOS.Core.Controllers; using Bit.App.Resources; using Bit.iOS.Core.Views; using Bit.iOS.Autofill.Utilities; +using Bit.iOS.Core.Utilities; namespace Bit.iOS.Autofill { @@ -18,19 +19,16 @@ namespace Bit.iOS.Autofill public Context Context { get; set; } public CredentialProviderViewController CPViewController { get; set; } - public override void ViewWillAppear(bool animated) - { - UINavigationBar.Appearance.ShadowImage = new UIImage(); - UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); - base.ViewWillAppear(animated); - } - public async override void ViewDidLoad() { base.ViewDidLoad(); NavItem.Title = AppResources.SearchVault; CancelBarButton.Title = AppResources.Cancel; SearchBar.Placeholder = AppResources.Search; + if(!ThemeHelpers.LightTheme) + { + SearchBar.BackgroundColor = SearchBar.BarTintColor = ThemeHelpers.BackgroundColor; + } TableView.RowHeight = UITableView.AutomaticDimension; TableView.EstimatedRowHeight = 44; diff --git a/src/iOS.Autofill/SetupViewController.cs b/src/iOS.Autofill/SetupViewController.cs index 42af991fc..a7444d1ef 100644 --- a/src/iOS.Autofill/SetupViewController.cs +++ b/src/iOS.Autofill/SetupViewController.cs @@ -8,30 +8,24 @@ namespace Bit.iOS.Autofill { public partial class SetupViewController : ExtendedUIViewController { - public SetupViewController(IntPtr handle) : base(handle) + public SetupViewController(IntPtr handle) + : base(handle) { } public CredentialProviderViewController CPViewController { get; set; } - public override void ViewWillAppear(bool animated) - { - UINavigationBar.Appearance.ShadowImage = new UIImage(); - UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); - base.ViewWillAppear(animated); - } - public override void ViewDidLoad() { - View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); var descriptor = UIFontDescriptor.PreferredBody; DescriptionLabel.Text = $@"{AppResources.AutofillSetup} {AppResources.AutofillSetup2}"; DescriptionLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize); - DescriptionLabel.TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f); + DescriptionLabel.TextColor = ThemeHelpers.MutedColor; ActivatedLabel.Text = AppResources.AutofillActivated; ActivatedLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize * 1.3f); + ActivatedLabel.TextColor = ThemeHelpers.SuccessColor; BackButton.Title = AppResources.Back; base.ViewDidLoad(); diff --git a/src/iOS.Core/Controllers/ExtendedUITableViewCell.cs b/src/iOS.Core/Controllers/ExtendedUITableViewCell.cs new file mode 100644 index 000000000..b7156c038 --- /dev/null +++ b/src/iOS.Core/Controllers/ExtendedUITableViewCell.cs @@ -0,0 +1,27 @@ +using Bit.iOS.Core.Utilities; +using UIKit; + +namespace Bit.iOS.Core.Controllers +{ + public class ExtendedUITableViewCell : UITableViewCell + { + public ExtendedUITableViewCell() + { + BackgroundColor = ThemeHelpers.BackgroundColor; + if(!ThemeHelpers.LightTheme) + { + SelectionStyle = UITableViewCellSelectionStyle.None; + } + } + + public ExtendedUITableViewCell(UITableViewCellStyle style, string reusedId) + : base(style, reusedId) + { + BackgroundColor = ThemeHelpers.BackgroundColor; + if(!ThemeHelpers.LightTheme) + { + SelectionStyle = UITableViewCellSelectionStyle.None; + } + } + } +} diff --git a/src/iOS.Core/Controllers/ExtendedUITableViewController.cs b/src/iOS.Core/Controllers/ExtendedUITableViewController.cs index 6ca6893f1..c5d1922ca 100644 --- a/src/iOS.Core/Controllers/ExtendedUITableViewController.cs +++ b/src/iOS.Core/Controllers/ExtendedUITableViewController.cs @@ -1,3 +1,4 @@ +using Bit.iOS.Core.Utilities; using System; using UIKit; @@ -8,5 +9,36 @@ namespace Bit.iOS.Core.Controllers public ExtendedUITableViewController(IntPtr handle) : base(handle) { } + + public override void ViewWillAppear(bool animated) + { + UINavigationBar.Appearance.ShadowImage = new UIImage(); + UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); + base.ViewWillAppear(animated); + } + + public override void ViewDidLoad() + { + base.ViewDidLoad(); + if(View != null) + { + View.BackgroundColor = ThemeHelpers.BackgroundColor; + } + if(TableView != null) + { + TableView.BackgroundColor = ThemeHelpers.BackgroundColor; + TableView.SeparatorColor = ThemeHelpers.SeparatorColor; + } + if(NavigationController?.NavigationBar != null) + { + NavigationController.NavigationBar.BarTintColor = ThemeHelpers.NavBarBackgroundColor; + NavigationController.NavigationBar.BackgroundColor = ThemeHelpers.NavBarBackgroundColor; + NavigationController.NavigationBar.TintColor = ThemeHelpers.NavBarTextColor; + NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes + { + ForegroundColor = ThemeHelpers.NavBarTextColor + }; + } + } } } diff --git a/src/iOS.Core/Controllers/ExtendedUITableViewSource.cs b/src/iOS.Core/Controllers/ExtendedUITableViewSource.cs new file mode 100644 index 000000000..852f284ee --- /dev/null +++ b/src/iOS.Core/Controllers/ExtendedUITableViewSource.cs @@ -0,0 +1,25 @@ +using Bit.iOS.Core.Utilities; +using System; +using UIKit; + +namespace Bit.iOS.Core.Views +{ + public abstract class ExtendedUITableViewSource : UITableViewSource + { + public override void WillDisplayHeaderView(UITableView tableView, UIView headerView, nint section) + { + if(headerView != null && headerView is UITableViewHeaderFooterView hv && hv.TextLabel != null) + { + hv.TextLabel.TextColor = ThemeHelpers.MutedColor; + } + } + + public override void WillDisplayFooterView(UITableView tableView, UIView footerView, nint section) + { + if(footerView != null && footerView is UITableViewHeaderFooterView fv && fv.TextLabel != null) + { + fv.TextLabel.TextColor = ThemeHelpers.MutedColor; + } + } + } +} diff --git a/src/iOS.Core/Controllers/ExtendedUIViewController.cs b/src/iOS.Core/Controllers/ExtendedUIViewController.cs index 92ceba74e..3714464ad 100644 --- a/src/iOS.Core/Controllers/ExtendedUIViewController.cs +++ b/src/iOS.Core/Controllers/ExtendedUIViewController.cs @@ -1,3 +1,4 @@ +using Bit.iOS.Core.Utilities; using System; using UIKit; @@ -8,5 +9,31 @@ namespace Bit.iOS.Core.Controllers public ExtendedUIViewController(IntPtr handle) : base(handle) { } + + public override void ViewWillAppear(bool animated) + { + UINavigationBar.Appearance.ShadowImage = new UIImage(); + UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); + base.ViewWillAppear(animated); + } + + public override void ViewDidLoad() + { + base.ViewDidLoad(); + if(View != null) + { + View.BackgroundColor = ThemeHelpers.BackgroundColor; + } + if(NavigationController?.NavigationBar != null) + { + NavigationController.NavigationBar.BarTintColor = ThemeHelpers.NavBarBackgroundColor; + NavigationController.NavigationBar.BackgroundColor = ThemeHelpers.NavBarBackgroundColor; + NavigationController.NavigationBar.TintColor = ThemeHelpers.NavBarTextColor; + NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes + { + ForegroundColor = ThemeHelpers.NavBarTextColor + }; + } + } } } diff --git a/src/iOS.Core/Controllers/LockPasswordViewController.cs b/src/iOS.Core/Controllers/LockPasswordViewController.cs index d25f7d5bb..633f001e8 100644 --- a/src/iOS.Core/Controllers/LockPasswordViewController.cs +++ b/src/iOS.Core/Controllers/LockPasswordViewController.cs @@ -41,13 +41,6 @@ namespace Bit.iOS.Core.Controllers public FormEntryTableViewCell MasterPasswordCell { get; set; } = new FormEntryTableViewCell( AppResources.MasterPassword); - public override void ViewWillAppear(bool animated) - { - UINavigationBar.Appearance.ShadowImage = new UIImage(); - UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); - base.ViewWillAppear(animated); - } - public override void ViewDidLoad() { _lockService = ServiceContainer.Resolve("lockService"); @@ -66,7 +59,6 @@ namespace Bit.iOS.Core.Controllers BaseNavItem.Title = _pinLock ? AppResources.VerifyPIN : AppResources.VerifyMasterPassword; BaseCancelButton.Title = AppResources.Cancel; BaseSubmitButton.Title = AppResources.Submit; - View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); var descriptor = UIFontDescriptor.PreferredBody; @@ -238,7 +230,7 @@ namespace Bit.iOS.Core.Controllers PresentViewController(alert, true, null); } - public class TableSource : UITableViewSource + public class TableSource : ExtendedUITableViewSource { private LockPasswordViewController _controller; @@ -260,13 +252,13 @@ namespace Bit.iOS.Core.Controllers { if(indexPath.Row == 0) { - var cell = new UITableViewCell(); - cell.TextLabel.TextColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f); + var cell = new ExtendedUITableViewCell(); + cell.TextLabel.TextColor = ThemeHelpers.PrimaryColor; cell.TextLabel.Text = AppResources.UseFingerprintToUnlock; return cell; } } - return new UITableViewCell(); + return new ExtendedUITableViewCell(); } public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath) diff --git a/src/iOS.Core/Controllers/LoginAddViewController.cs b/src/iOS.Core/Controllers/LoginAddViewController.cs index c6abec734..57843a091 100644 --- a/src/iOS.Core/Controllers/LoginAddViewController.cs +++ b/src/iOS.Core/Controllers/LoginAddViewController.cs @@ -30,7 +30,7 @@ namespace Bit.iOS.Core.Controllers public FormEntryTableViewCell NameCell { get; set; } = new FormEntryTableViewCell(AppResources.Name); public FormEntryTableViewCell UsernameCell { get; set; } = new FormEntryTableViewCell(AppResources.Username); public FormEntryTableViewCell PasswordCell { get; set; } = new FormEntryTableViewCell(AppResources.Password); - public UITableViewCell GeneratePasswordCell { get; set; } = new UITableViewCell( + public UITableViewCell GeneratePasswordCell { get; set; } = new ExtendedUITableViewCell( UITableViewCellStyle.Subtitle, "GeneratePasswordCell"); public FormEntryTableViewCell UriCell { get; set; } = new FormEntryTableViewCell(AppResources.URI); public SwitchTableViewCell FavoriteCell { get; set; } = new SwitchTableViewCell(AppResources.Favorite); @@ -43,13 +43,6 @@ namespace Bit.iOS.Core.Controllers public abstract UIBarButtonItem BaseSaveButton { get; } public abstract Action Success { get; } - public override void ViewWillAppear(bool animated) - { - UINavigationBar.Appearance.ShadowImage = new UIImage(); - UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); - base.ViewWillAppear(animated); - } - public override void ViewDidLoad() { _cipherService = ServiceContainer.Resolve("cipherService"); @@ -58,7 +51,7 @@ namespace Bit.iOS.Core.Controllers BaseNavItem.Title = AppResources.AddItem; BaseCancelButton.Title = AppResources.Cancel; BaseSaveButton.Title = AppResources.Save; - View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); + View.BackgroundColor = ThemeHelpers.BackgroundColor; NameCell.TextField.Text = Context?.Uri?.Host ?? string.Empty; NameCell.TextField.ReturnKeyType = UIReturnKeyType.Next; @@ -87,6 +80,8 @@ namespace Bit.iOS.Core.Controllers }; GeneratePasswordCell.TextLabel.Text = AppResources.GeneratePassword; + GeneratePasswordCell.TextLabel.TextColor = GeneratePasswordCell.TextLabel.TintColor = + ThemeHelpers.TextColor; GeneratePasswordCell.Accessory = UITableViewCellAccessory.DisclosureIndicator; UriCell.TextField.Text = Context?.UrlString ?? string.Empty; @@ -206,7 +201,7 @@ namespace Bit.iOS.Core.Controllers AppResources.InternetConnectionRequiredMessage, AppResources.Ok); } - public class TableSource : UITableViewSource + public class TableSource : ExtendedUITableViewSource { private LoginAddViewController _controller; @@ -256,7 +251,7 @@ namespace Bit.iOS.Core.Controllers return _controller.NotesCell; } - return new UITableViewCell(); + return new ExtendedUITableViewCell(); } public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath) diff --git a/src/iOS.Core/Controllers/PasswordGeneratorViewController.cs b/src/iOS.Core/Controllers/PasswordGeneratorViewController.cs index bcee98c0d..6d967fc6a 100644 --- a/src/iOS.Core/Controllers/PasswordGeneratorViewController.cs +++ b/src/iOS.Core/Controllers/PasswordGeneratorViewController.cs @@ -26,9 +26,12 @@ namespace Bit.iOS.Core.Controllers public SwitchTableViewCell LowercaseCell { get; set; } = new SwitchTableViewCell("a-z"); public SwitchTableViewCell NumbersCell { get; set; } = new SwitchTableViewCell("0-9"); public SwitchTableViewCell SpecialCell { get; set; } = new SwitchTableViewCell("!@#$%^&*"); - public StepperTableViewCell MinNumbersCell { get; set; } = new StepperTableViewCell(AppResources.MinNumbers, 1, 0, 5, 1); - public StepperTableViewCell MinSpecialCell { get; set; } = new StepperTableViewCell(AppResources.MinSpecial, 1, 0, 5, 1); - public SliderTableViewCell LengthCell { get; set; } = new SliderTableViewCell(AppResources.Length, 10, 5, 64); + public StepperTableViewCell MinNumbersCell { get; set; } = new StepperTableViewCell( + AppResources.MinNumbers, 1, 0, 5, 1); + public StepperTableViewCell MinSpecialCell { get; set; } = new StepperTableViewCell( + AppResources.MinSpecial, 1, 0, 5, 1); + public SliderTableViewCell LengthCell { get; set; } = new SliderTableViewCell( + AppResources.Length, 10, 5, 64); public PasswordGenerationOptions PasswordOptions { get; set; } public abstract UINavigationItem BaseNavItem { get; } @@ -36,13 +39,6 @@ namespace Bit.iOS.Core.Controllers public abstract UIBarButtonItem BaseSelectBarButton { get; } public abstract UILabel BasePasswordLabel { get; } - public override void ViewWillAppear(bool animated) - { - UINavigationBar.Appearance.ShadowImage = new UIImage(); - UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); - base.ViewWillAppear(animated); - } - public async override void ViewDidLoad() { _passwordGenerationService = ServiceContainer.Resolve( @@ -51,13 +47,13 @@ namespace Bit.iOS.Core.Controllers BaseNavItem.Title = AppResources.PasswordGenerator; BaseCancelButton.Title = AppResources.Cancel; BaseSelectBarButton.Title = AppResources.Select; - View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); var descriptor = UIFontDescriptor.PreferredBody; BasePasswordLabel.Font = UIFont.FromName("Menlo-Regular", descriptor.PointSize * 1.3f); BasePasswordLabel.LineBreakMode = UILineBreakMode.TailTruncation; BasePasswordLabel.Lines = 1; BasePasswordLabel.AdjustsFontSizeToFitWidth = false; + BasePasswordLabel.TextColor = ThemeHelpers.TextColor; var controller = ChildViewControllers.LastOrDefault(); if(controller != null) @@ -71,7 +67,8 @@ namespace Bit.iOS.Core.Controllers OptionsTableViewController.TableView.EstimatedRowHeight = 70; OptionsTableViewController.TableView.Source = new TableSource(this); OptionsTableViewController.TableView.AllowsSelection = true; - OptionsTableViewController.View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); + OptionsTableViewController.View.BackgroundColor = ThemeHelpers.BackgroundColor; + OptionsTableViewController.TableView.SeparatorColor = ThemeHelpers.SeparatorColor; } var options = await _passwordGenerationService.GetOptionsAsync(); @@ -159,7 +156,8 @@ namespace Bit.iOS.Core.Controllers private bool InvalidState() { - return !LowercaseCell.Switch.On && !UppercaseCell.Switch.On && !NumbersCell.Switch.On && !SpecialCell.Switch.On; + return !LowercaseCell.Switch.On && !UppercaseCell.Switch.On && !NumbersCell.Switch.On && + !SpecialCell.Switch.On; } private async Task GeneratePasswordAsync() @@ -177,7 +175,7 @@ namespace Bit.iOS.Core.Controllers }); } - public class TableSource : UITableViewSource + public class TableSource : ExtendedUITableViewSource { private PasswordGeneratorViewController _controller; @@ -190,8 +188,8 @@ namespace Bit.iOS.Core.Controllers { if(indexPath.Section == 0) { - var cell = new UITableViewCell(); - cell.TextLabel.TextColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f); + var cell = new ExtendedUITableViewCell(); + cell.TextLabel.TextColor = ThemeHelpers.PrimaryColor; if(indexPath.Row == 0) { cell.TextLabel.Text = AppResources.RegeneratePassword; @@ -232,7 +230,7 @@ namespace Bit.iOS.Core.Controllers return _controller.MinSpecialCell; } - return new UITableViewCell(); + return new ExtendedUITableViewCell(); } public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath) diff --git a/src/iOS.Core/Utilities/ThemeHelpers.cs b/src/iOS.Core/Utilities/ThemeHelpers.cs index 16631698c..d26ec1b35 100644 --- a/src/iOS.Core/Utilities/ThemeHelpers.cs +++ b/src/iOS.Core/Utilities/ThemeHelpers.cs @@ -9,6 +9,13 @@ namespace Bit.iOS.Core.Utilities 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 PrimaryColor = Xamarin.Forms.Color.FromHex("#3c8dbc").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 NavBarBackgroundColor = Xamarin.Forms.Color.FromHex("#3c8dbc").ToUIColor(); + public static UIColor NavBarTextColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor(); public static void SetAppearance(string theme) { @@ -24,6 +31,24 @@ namespace Bit.iOS.Core.Utilities { SetAppearance(theme); 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; } private static void SetThemeVariables(string theme) @@ -31,21 +56,45 @@ namespace Bit.iOS.Core.Utilities LightTheme = false; if(theme == "dark") { + var whiteColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor(); MutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor(); + SuccessColor = Xamarin.Forms.Color.FromHex("#00a65a").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(); + 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(); - BackgroundColor = Xamarin.Forms.Color.FromHex("#000000").ToUIColor(); - SplashBackgroundColor = BackgroundColor; + SuccessColor = Xamarin.Forms.Color.FromHex("#00a65a").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(); + NavBarBackgroundColor = blackColor; + NavBarTextColor = whiteColor; } else if(theme == "nord") { MutedColor = Xamarin.Forms.Color.FromHex("#d8dee9").ToUIColor(); + SuccessColor = Xamarin.Forms.Color.FromHex("#a3be8c").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(); + NavBarBackgroundColor = Xamarin.Forms.Color.FromHex("#2e3440").ToUIColor(); + NavBarTextColor = Xamarin.Forms.Color.FromHex("#e5e9f0").ToUIColor(); } else { diff --git a/src/iOS.Core/Views/ExtensionTableSource.cs b/src/iOS.Core/Views/ExtensionTableSource.cs index 4beb22f60..f39203dfb 100644 --- a/src/iOS.Core/Views/ExtensionTableSource.cs +++ b/src/iOS.Core/Views/ExtensionTableSource.cs @@ -2,7 +2,9 @@ using Bit.Core.Abstractions; using Bit.Core.Models.View; using Bit.Core.Utilities; +using Bit.iOS.Core.Controllers; using Bit.iOS.Core.Models; +using Bit.iOS.Core.Utilities; using Foundation; using System; using System.Collections.Generic; @@ -14,7 +16,7 @@ using UIKit; namespace Bit.iOS.Core.Views { - public class ExtensionTableSource : UITableViewSource + public class ExtensionTableSource : ExtendedUITableViewSource { private const string CellIdentifier = "TableCell"; @@ -95,11 +97,12 @@ namespace Bit.iOS.Core.Views { if(Items == null || Items.Count() == 0) { - var noDataCell = new UITableViewCell(UITableViewCellStyle.Default, "NoDataCell"); + var noDataCell = new ExtendedUITableViewCell(UITableViewCellStyle.Default, "NoDataCell"); noDataCell.TextLabel.Text = AppResources.NoItemsTap; noDataCell.TextLabel.TextAlignment = UITextAlignment.Center; noDataCell.TextLabel.LineBreakMode = UILineBreakMode.WordWrap; noDataCell.TextLabel.Lines = 0; + noDataCell.TextLabel.TextColor = ThemeHelpers.TextColor; return noDataCell; } @@ -109,9 +112,9 @@ namespace Bit.iOS.Core.Views if(cell == null) { Debug.WriteLine("BW Log, Make new cell for list."); - cell = new UITableViewCell(UITableViewCellStyle.Subtitle, CellIdentifier); - cell.DetailTextLabel.TextColor = cell.DetailTextLabel.TintColor = - new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f); + cell = new ExtendedUITableViewCell(UITableViewCellStyle.Subtitle, CellIdentifier); + cell.TextLabel.TextColor = cell.TextLabel.TintColor = ThemeHelpers.TextColor; + cell.DetailTextLabel.TextColor = cell.DetailTextLabel.TintColor = ThemeHelpers.MutedColor; } return cell; } diff --git a/src/iOS.Core/Views/FormEntryTableViewCell.cs b/src/iOS.Core/Views/FormEntryTableViewCell.cs index 9088e7e0a..1f0fe8ac7 100644 --- a/src/iOS.Core/Views/FormEntryTableViewCell.cs +++ b/src/iOS.Core/Views/FormEntryTableViewCell.cs @@ -1,9 +1,11 @@ -using System; +using Bit.iOS.Core.Controllers; +using Bit.iOS.Core.Utilities; +using System; using UIKit; namespace Bit.iOS.Core.Views { - public class FormEntryTableViewCell : UITableViewCell, ISelectable + public class FormEntryTableViewCell : ExtendedUITableViewCell, ISelectable { public FormEntryTableViewCell( string labelName = null, @@ -22,7 +24,7 @@ namespace Bit.iOS.Core.Views Text = labelName, TranslatesAutoresizingMaskIntoConstraints = false, Font = UIFont.FromDescriptor(descriptor, 0.8f * pointSize), - TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f) + TextColor = ThemeHelpers.MutedColor }; ContentView.Add(Label); @@ -33,7 +35,10 @@ namespace Bit.iOS.Core.Views TextView = new UITextView { TranslatesAutoresizingMaskIntoConstraints = false, - Font = UIFont.FromDescriptor(descriptor, pointSize) + Font = UIFont.FromDescriptor(descriptor, pointSize), + TextColor = ThemeHelpers.TextColor, + TintColor = ThemeHelpers.TextColor, + BackgroundColor = ThemeHelpers.BackgroundColor }; ContentView.Add(TextView); @@ -67,7 +72,10 @@ namespace Bit.iOS.Core.Views TranslatesAutoresizingMaskIntoConstraints = false, BorderStyle = UITextBorderStyle.None, Font = UIFont.FromDescriptor(descriptor, pointSize), - ClearButtonMode = UITextFieldViewMode.WhileEditing + ClearButtonMode = UITextFieldViewMode.WhileEditing, + TextColor = ThemeHelpers.TextColor, + TintColor = ThemeHelpers.TextColor, + BackgroundColor = ThemeHelpers.BackgroundColor }; if(useLabelAsPlaceholder) diff --git a/src/iOS.Core/Views/PickerTableViewCell.cs b/src/iOS.Core/Views/PickerTableViewCell.cs index 84094b752..03cc39806 100644 --- a/src/iOS.Core/Views/PickerTableViewCell.cs +++ b/src/iOS.Core/Views/PickerTableViewCell.cs @@ -1,4 +1,6 @@ -using CoreGraphics; +using Bit.iOS.Core.Controllers; +using Bit.iOS.Core.Utilities; +using CoreGraphics; using System; using System.Collections.Generic; using System.Drawing; @@ -6,7 +8,7 @@ using UIKit; namespace Bit.iOS.Core.Views { - public class PickerTableViewCell : UITableViewCell, ISelectable + public class PickerTableViewCell : ExtendedUITableViewCell, ISelectable { private List _items = new List(); private int _selectedIndex = 0; @@ -24,7 +26,7 @@ namespace Bit.iOS.Core.Views Text = labelName, TranslatesAutoresizingMaskIntoConstraints = false, Font = UIFont.FromDescriptor(descriptor, 0.8f * pointSize), - TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f) + TextColor = ThemeHelpers.MutedColor }; ContentView.Add(Label); @@ -33,7 +35,10 @@ namespace Bit.iOS.Core.Views { BorderStyle = UITextBorderStyle.None, TranslatesAutoresizingMaskIntoConstraints = false, - Font = UIFont.FromDescriptor(descriptor, pointSize) + Font = UIFont.FromDescriptor(descriptor, pointSize), + TextColor = ThemeHelpers.TextColor, + TintColor = ThemeHelpers.TextColor, + BackgroundColor = ThemeHelpers.BackgroundColor }; var width = (float)UIScreen.MainScreen.Bounds.Width; diff --git a/src/iOS.Core/Views/SliderTableViewCell.cs b/src/iOS.Core/Views/SliderTableViewCell.cs index 30231d2dd..f31d54f45 100644 --- a/src/iOS.Core/Views/SliderTableViewCell.cs +++ b/src/iOS.Core/Views/SliderTableViewCell.cs @@ -1,9 +1,11 @@ -using System; +using Bit.iOS.Core.Controllers; +using Bit.iOS.Core.Utilities; +using System; using UIKit; namespace Bit.iOS.Core.Views { - public class SliderTableViewCell : UITableViewCell + public class SliderTableViewCell : ExtendedUITableViewCell { private string _detailRightSpace = "\t"; private int _value; @@ -12,14 +14,16 @@ namespace Bit.iOS.Core.Views : base(UITableViewCellStyle.Value1, nameof(SwitchTableViewCell)) { TextLabel.Text = labelName; - DetailTextLabel.TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f); + TextLabel.TextColor = ThemeHelpers.TextColor; + DetailTextLabel.TextColor = ThemeHelpers.MutedColor; Slider = new UISlider { MinValue = min, MaxValue = max, - TintColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f), - Frame = new CoreGraphics.CGRect(0, 0, 180, 30) + TintColor = ThemeHelpers.PrimaryColor, + Frame = new CoreGraphics.CGRect(0, 0, 180, 30), + BackgroundColor = ThemeHelpers.BackgroundColor }; Slider.ValueChanged += Slider_ValueChanged; Value = value; diff --git a/src/iOS.Core/Views/StepperTableViewCell.cs b/src/iOS.Core/Views/StepperTableViewCell.cs index 02bdf8ce1..4be03f39c 100644 --- a/src/iOS.Core/Views/StepperTableViewCell.cs +++ b/src/iOS.Core/Views/StepperTableViewCell.cs @@ -1,9 +1,11 @@ -using System; +using Bit.iOS.Core.Controllers; +using Bit.iOS.Core.Utilities; +using System; using UIKit; namespace Bit.iOS.Core.Views { - public class StepperTableViewCell : UITableViewCell + public class StepperTableViewCell : ExtendedUITableViewCell { // Give some space to the right of the detail in between the spacer. // This is a bit of a hack, but I did not see a way to specify a margin on the @@ -15,11 +17,12 @@ namespace Bit.iOS.Core.Views : base(UITableViewCellStyle.Value1, nameof(SwitchTableViewCell)) { TextLabel.Text = labelName; - DetailTextLabel.TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f); + TextLabel.TextColor = ThemeHelpers.TextColor; + DetailTextLabel.TextColor = ThemeHelpers.MutedColor; Stepper = new UIStepper { - TintColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f), + TintColor = ThemeHelpers.MutedColor, MinimumValue = min, MaximumValue = max }; diff --git a/src/iOS.Core/Views/SwitchTableViewCell.cs b/src/iOS.Core/Views/SwitchTableViewCell.cs index 9302f89e4..da2ce7ba3 100644 --- a/src/iOS.Core/Views/SwitchTableViewCell.cs +++ b/src/iOS.Core/Views/SwitchTableViewCell.cs @@ -1,14 +1,19 @@ -using System; +using Bit.iOS.Core.Controllers; +using Bit.iOS.Core.Utilities; +using System; using UIKit; namespace Bit.iOS.Core.Views { - public class SwitchTableViewCell : UITableViewCell + public class SwitchTableViewCell : ExtendedUITableViewCell { public SwitchTableViewCell(string labelName) : base(UITableViewCellStyle.Default, nameof(SwitchTableViewCell)) { TextLabel.Text = labelName; + TextLabel.TextColor = ThemeHelpers.TextColor; + Switch.TintColor = ThemeHelpers.MutedColor; + Switch.OnTintColor = ThemeHelpers.PrimaryColor; AccessoryView = Switch; Switch.ValueChanged += Switch_ValueChanged; diff --git a/src/iOS.Core/iOS.Core.csproj b/src/iOS.Core/iOS.Core.csproj index 9cefcf134..8f6a331b9 100644 --- a/src/iOS.Core/iOS.Core.csproj +++ b/src/iOS.Core/iOS.Core.csproj @@ -55,7 +55,9 @@ + + diff --git a/src/iOS.Extension/LoadingViewController.cs b/src/iOS.Extension/LoadingViewController.cs index be6250f34..379bbb647 100644 --- a/src/iOS.Extension/LoadingViewController.cs +++ b/src/iOS.Extension/LoadingViewController.cs @@ -378,6 +378,7 @@ namespace Bit.iOS.Extension private void InitApp() { + iOSCoreHelpers.AppearanceAdjustments(); if(ServiceContainer.RegisteredServices.Count > 0) { return; @@ -386,7 +387,6 @@ namespace Bit.iOS.Extension ServiceContainer.Init(); iOSCoreHelpers.RegisterHockeyApp(); iOSCoreHelpers.Bootstrap(); - iOSCoreHelpers.AppearanceAdjustments(); } private bool IsLocked() diff --git a/src/iOS.Extension/LockPasswordViewController.cs b/src/iOS.Extension/LockPasswordViewController.cs index 0b9bcffce..459a87247 100644 --- a/src/iOS.Extension/LockPasswordViewController.cs +++ b/src/iOS.Extension/LockPasswordViewController.cs @@ -1,3 +1,4 @@ +using Bit.iOS.Core.Utilities; using System; using UIKit; @@ -16,6 +17,13 @@ namespace Bit.iOS.Extension public override Action Success => () => LoadingController.DismissLockAndContinue(); public override Action Cancel => () => LoadingController.CompleteRequest(null); + public override void ViewDidLoad() + { + base.ViewDidLoad(); + CancelButton.TintColor = ThemeHelpers.NavBarTextColor; + SubmitButton.TintColor = ThemeHelpers.NavBarTextColor; + } + partial void SubmitButton_Activated(UIBarButtonItem sender) { var task = CheckPasswordAsync(); diff --git a/src/iOS.Extension/LoginAddViewController.cs b/src/iOS.Extension/LoginAddViewController.cs index c2739f604..dea6afe8f 100644 --- a/src/iOS.Extension/LoginAddViewController.cs +++ b/src/iOS.Extension/LoginAddViewController.cs @@ -1,4 +1,5 @@ using System; +using Bit.iOS.Core.Utilities; using Foundation; using UIKit; @@ -17,6 +18,13 @@ namespace Bit.iOS.Extension public override UIBarButtonItem BaseCancelButton => CancelBarButton; public override UIBarButtonItem BaseSaveButton => SaveBarButton; + public override void ViewDidLoad() + { + base.ViewDidLoad(); + SaveBarButton.TintColor = ThemeHelpers.NavBarTextColor; + CancelBarButton.TintColor = ThemeHelpers.NavBarTextColor; + } + public override Action Success => () => { if(LoginListController != null) diff --git a/src/iOS.Extension/LoginListViewController.cs b/src/iOS.Extension/LoginListViewController.cs index 3d23aac44..99c65609f 100644 --- a/src/iOS.Extension/LoginListViewController.cs +++ b/src/iOS.Extension/LoginListViewController.cs @@ -23,16 +23,11 @@ namespace Bit.iOS.Extension public Context Context { get; set; } public LoadingViewController LoadingController { get; set; } - public override void ViewWillAppear(bool animated) - { - UINavigationBar.Appearance.ShadowImage = new UIImage(); - UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); - base.ViewWillAppear(animated); - } - public async override void ViewDidLoad() { base.ViewDidLoad(); + AddBarButton.TintColor = ThemeHelpers.NavBarTextColor; + CancelBarButton.TintColor = ThemeHelpers.NavBarTextColor; NavItem.Title = AppResources.Items; if(!CanAutoFill()) { diff --git a/src/iOS.Extension/MainInterface.storyboard b/src/iOS.Extension/MainInterface.storyboard index da6e453d3..6aa28bb3e 100644 --- a/src/iOS.Extension/MainInterface.storyboard +++ b/src/iOS.Extension/MainInterface.storyboard @@ -21,7 +21,6 @@ - @@ -63,11 +62,6 @@ - - - - - @@ -85,10 +79,6 @@ - - - - @@ -105,8 +95,6 @@ - - @@ -115,13 +103,11 @@ - - @@ -145,7 +131,6 @@ - @@ -158,14 +143,12 @@ - @@ -180,13 +163,11 @@ - - @@ -211,11 +192,6 @@ - - - - - @@ -239,16 +215,13 @@ - @@ -264,13 +237,11 @@ - - @@ -296,7 +267,6 @@ - @@ -318,11 +288,6 @@ - - - - - @@ -339,7 +304,6 @@ - @@ -382,23 +346,18 @@ - @@ -437,15 +396,11 @@ - - - - - + diff --git a/src/iOS.Extension/PasswordGeneratorViewController.cs b/src/iOS.Extension/PasswordGeneratorViewController.cs index 074f3d7bf..ddec501f9 100644 --- a/src/iOS.Extension/PasswordGeneratorViewController.cs +++ b/src/iOS.Extension/PasswordGeneratorViewController.cs @@ -1,3 +1,4 @@ +using Bit.iOS.Core.Utilities; using System; using UIKit; @@ -15,6 +16,13 @@ namespace Bit.iOS.Extension public override UIBarButtonItem BaseSelectBarButton => SelectBarButton; public override UILabel BasePasswordLabel => PasswordLabel; + public override void ViewDidLoad() + { + base.ViewDidLoad(); + CancelBarButton.TintColor = ThemeHelpers.NavBarTextColor; + SelectBarButton.TintColor = ThemeHelpers.NavBarTextColor; + } + partial void SelectBarButton_Activated(UIBarButtonItem sender) { DismissViewController(true, () => Parent.PasswordCell.TextField.Text = PasswordLabel.Text); diff --git a/src/iOS.Extension/SetupViewController.cs b/src/iOS.Extension/SetupViewController.cs index c955ba1b9..3fd70a8e9 100644 --- a/src/iOS.Extension/SetupViewController.cs +++ b/src/iOS.Extension/SetupViewController.cs @@ -3,6 +3,7 @@ using Bit.iOS.Extension.Models; using UIKit; using Bit.iOS.Core.Controllers; using Bit.App.Resources; +using Bit.iOS.Core.Utilities; namespace Bit.iOS.Extension { @@ -15,26 +16,20 @@ namespace Bit.iOS.Extension public Context Context { get; set; } public LoadingViewController LoadingController { get; set; } - public override void ViewWillAppear(bool animated) - { - UINavigationBar.Appearance.ShadowImage = new UIImage(); - UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); - base.ViewWillAppear(animated); - } - public override void ViewDidLoad() { - View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); var descriptor = UIFontDescriptor.PreferredBody; DescriptionLabel.Text = $@"{AppResources.ExtensionSetup} {AppResources.ExtensionSetup2}"; DescriptionLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize); - DescriptionLabel.TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f); + DescriptionLabel.TextColor = ThemeHelpers.MutedColor; ActivatedLabel.Text = AppResources.ExtensionActivated; ActivatedLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize * 1.3f); + ActivatedLabel.TextColor = ThemeHelpers.SuccessColor; + BackButton.TintColor = ThemeHelpers.NavBarTextColor; BackButton.Title = AppResources.Back; base.ViewDidLoad(); }