Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #1493: Themes / Dark Mode Support (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhreis authored Sep 6, 2019
1 parent 791a106 commit 45787a9
Show file tree
Hide file tree
Showing 56 changed files with 1,055 additions and 522 deletions.
8 changes: 8 additions & 0 deletions BraveShared/BraveStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,14 @@ extension Strings {
public static let ShareWithMenuItem = NSLocalizedString("ShareWithMenuItem", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Share with...", comment: "Title for sharing url menu item")
public static let DownloadsMenuItem = NSLocalizedString("DownloadsMenuItem", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Downloads", comment: "Title for downloads menu item")
public static let DownloadsPanelEmptyStateTitle = NSLocalizedString("DownloadsPanelEmptyStateTitle", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Downloaded files will show up here.", comment: "Title for when a user has nothing downloaded onto their device, and the list is empty.")

// MARK: - Themes

public static let ThemesDisplayBrightness = NSLocalizedString("ThemesDisplayBrightness", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Display & Brightness", comment: "Setting to choose the user interface theme for normal browsing mode, contains choices like 'light' or 'dark' themes")
public static let ThemesDisplayBrightnessFooter = NSLocalizedString("ThemesDisplayBrightnessFooter", tableName: "BraveShared", bundle: Bundle.braveShared, value: "These settings are not applied in private browsing mode.", comment: "Text specifying that the above setting does not impact the user interface while they user is in private browsing mode.")
public static let ThemesAutomaticOption = NSLocalizedString("ThemesAutomaticOption", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Automatic", comment: "Selection to automatically color/style the user interface.")
public static let ThemesLightOption = NSLocalizedString("ThemesLightOption", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Light", comment: "Selection to color/style the user interface with a light theme.")
public static let ThemesDarkOption = NSLocalizedString("ThemesDarkOption", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Dark", comment: "Selection to color/style the user interface with a dark theme")
}

// MARK: - Quick Actions
Expand Down
18 changes: 17 additions & 1 deletion Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +494,15 @@
5D1DC57220AE005400905E5A /* JSInjector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D1DC56820AE005400905E5A /* JSInjector.swift */; };
5D1DC57320AE005400905E5A /* SyncSite.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D1DC56920AE005400905E5A /* SyncSite.swift */; };
5D1DC57420AE005400905E5A /* ios-sync.js in Resources */ = {isa = PBXBuildFile; fileRef = 5D1DC56A20AE005400905E5A /* ios-sync.js */; };
5D21AE082303B70E00B30D97 /* Themes in Resources */ = {isa = PBXBuildFile; fileRef = 5D21AE002303B70E00B30D97 /* Themes */; };
5D24AF8221BA459000F9506A /* BlocklistName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D24AF8121BA459000F9506A /* BlocklistName.swift */; };
5D24AF8421BA489A00F9506A /* ContentBlocker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D24AF8321BA489A00F9506A /* ContentBlocker.swift */; };
5D24AF9021BA4D7700F9506A /* ContentBlockerRegion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D24AF8F21BA4D7700F9506A /* ContentBlockerRegion.swift */; };
5D6DDEF3214003A6001FF0AE /* DAU.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D6DDEE6214003A6001FF0AE /* DAU.swift */; };
5D6DDEFE2141B6A1001FF0AE /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D6DDEF62141B6A0001FF0AE /* Preferences.swift */; };
5D6DDF0021428CF0001FF0AE /* DAUTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D6DDEFF21428CF0001FF0AE /* DAUTests.swift */; };
5D7001C222249F7B00E576FB /* ShortNameToFileMapping.json in Resources */ = {isa = PBXBuildFile; fileRef = 5D7001BA22249F7A00E576FB /* ShortNameToFileMapping.json */; };
5D8AE6AF230C76B60096C845 /* AppearanceExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D8AE6AE230C76B60096C845 /* AppearanceExtensions.swift */; };
5DE5250D218CE92C000DFAA6 /* block-ads.json in Resources */ = {isa = PBXBuildFile; fileRef = 5DE52508218CE92B000DFAA6 /* block-ads.json */; };
5DE5250E218CE92C000DFAA6 /* block-images.json in Resources */ = {isa = PBXBuildFile; fileRef = 5DE52509218CE92B000DFAA6 /* block-images.json */; };
5DE5250F218CE92C000DFAA6 /* upgrade-http.json in Resources */ = {isa = PBXBuildFile; fileRef = 5DE5250A218CE92B000DFAA6 /* upgrade-http.json */; };
Expand Down Expand Up @@ -1866,13 +1868,15 @@
5D1DC56820AE005400905E5A /* JSInjector.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSInjector.swift; sourceTree = "<group>"; };
5D1DC56920AE005400905E5A /* SyncSite.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SyncSite.swift; sourceTree = "<group>"; };
5D1DC56A20AE005400905E5A /* ios-sync.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "ios-sync.js"; sourceTree = "<group>"; };
5D21AE002303B70E00B30D97 /* Themes */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Themes; sourceTree = "<group>"; };
5D24AF8121BA459000F9506A /* BlocklistName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlocklistName.swift; sourceTree = "<group>"; };
5D24AF8321BA489A00F9506A /* ContentBlocker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentBlocker.swift; sourceTree = "<group>"; };
5D24AF8F21BA4D7700F9506A /* ContentBlockerRegion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentBlockerRegion.swift; sourceTree = "<group>"; };
5D6DDEE6214003A6001FF0AE /* DAU.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DAU.swift; sourceTree = "<group>"; };
5D6DDEF62141B6A0001FF0AE /* Preferences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = "<group>"; };
5D6DDEFF21428CF0001FF0AE /* DAUTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DAUTests.swift; sourceTree = "<group>"; };
5D7001BA22249F7A00E576FB /* ShortNameToFileMapping.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = ShortNameToFileMapping.json; sourceTree = "<group>"; };
5D8AE6AE230C76B60096C845 /* AppearanceExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppearanceExtensions.swift; path = Extensions/AppearanceExtensions.swift; sourceTree = "<group>"; };
5DE52508218CE92B000DFAA6 /* block-ads.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "block-ads.json"; sourceTree = "<group>"; };
5DE52509218CE92B000DFAA6 /* block-images.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "block-images.json"; sourceTree = "<group>"; };
5DE5250A218CE92B000DFAA6 /* upgrade-http.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "upgrade-http.json"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2772,6 +2776,7 @@
595E0EE021CAEF5B00813D49 /* FileManagerExtension.swift */,
592F521D2217327B0078395E /* HttpCookieExtension.swift */,
F930CDAD2270015C00A23FE1 /* U2FExtensions.swift */,
5D8AE6AE230C76B60096C845 /* AppearanceExtensions.swift */,
);
indentWidth = 4;
name = Extensions;
Expand Down Expand Up @@ -3401,6 +3406,14 @@
path = sync;
sourceTree = "<group>";
};
5D26E89C22E117660015D7E9 /* Themes */ = {
isa = PBXGroup;
children = (
7B3631E91C244FEE00D12AF9 /* Theme.swift */,
);
path = Themes;
sourceTree = "<group>";
};
5D6DDEDF214003A6001FF0AE /* Analytics */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3712,7 +3725,7 @@
E65607601C08B4E200534B02 /* SearchInputView.swift */,
E63ED7D71BFCD9990097D08E /* LoginTableViewCell.swift */,
C4E3984B1D21F2FD004E89BA /* TabTrayButtonExtensions.swift */,
7B3631E91C244FEE00D12AF9 /* Theme.swift */,
5D26E89C22E117660015D7E9 /* Themes */,
59A68B1F857A8638598A63A0 /* TwoLineCell.swift */,
D863C8E31F68BFC20058D95F /* GradientProgressBar.swift */,
27D87C2D2152B50200FB55C6 /* GradientView.swift */,
Expand Down Expand Up @@ -4262,6 +4275,7 @@
D03F8F22200EAC1E003C2224 /* AllFramesAtDocumentStart.js */,
D0FCF8041FE4772D004A7995 /* MainFrameAtDocumentEnd.js */,
D0FCF8051FE4772D004A7995 /* MainFrameAtDocumentStart.js */,
5D21AE002303B70E00B30D97 /* Themes */,
3BC659581E5BA505006D560F /* top_sites.json */,
3BC659481E5BA4AE006D560F /* TopSites */,
C6345ECA2113B3A000CFB983 /* SearchPlugins */,
Expand Down Expand Up @@ -5229,6 +5243,7 @@
4422D4AD21BFFB7600BF1855 /* LICENSE in Resources */,
5EB57D0222FDC0CB00A07325 /* FullscreenHelper.js in Resources */,
E4B7B7641A793CF20022C5E0 /* CharisSILR.ttf in Resources */,
5D21AE082303B70E00B30D97 /* Themes in Resources */,
4422D56D21BFFB7F00BF1855 /* make_unicode_groups.py in Resources */,
E4B7B7681A793CF20022C5E0 /* FiraSans-Bold.ttf in Resources */,
E4B7B7781A793CF20022C5E0 /* FiraSans-Italic.ttf in Resources */,
Expand Down Expand Up @@ -5879,6 +5894,7 @@
A83E5AB71C1D993D0026D912 /* UIPasteboardExtensions.swift in Sources */,
C6B81B8A212D84BD00996084 /* ImageCacheType.swift in Sources */,
D8EFFA0C1FF5B1FA001D3A09 /* NavigationRouter.swift in Sources */,
5D8AE6AF230C76B60096C845 /* AppearanceExtensions.swift in Sources */,
D0E55C4F1FB4FD23006DC274 /* FormPostHelper.swift in Sources */,
E650754E1E37F6AE006961AC /* GeometryExtensions.swift in Sources */,
D3972BF41C22412B00035B87 /* TitleActivityItemProvider.swift in Sources */,
Expand Down
14 changes: 7 additions & 7 deletions Client/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati
// Override point for customization after application launch.
var shouldPerformAdditionalDelegateHandling = true

// BVC generally handles theme applying, but in some instances views are established
// before then (e.g. passcode, so can be privacy concern, meaning this should be called ASAP)
// In order to properly apply background and align this with the rest of the UI (keyboard / header)
// this needs to be called. UI could be handled internally to view systems,
// but then keyboard may misalign with Brave selected theme override
Theme.of(nil).applyAppearanceProperties()

UIScrollView.doBadSwizzleStuff()

#if BUDDYBUILD
Expand Down Expand Up @@ -266,13 +273,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati
}

AdblockResourceDownloader.shared.startLoading()

UINavigationBar.appearance().tintColor = BraveUX.BraveOrange

(UISwitch.appearance() as UISwitch).do {
$0.tintColor = BraveUX.SwitchTintColor
$0.onTintColor = BraveUX.BraveOrange
}

return shouldPerformAdditionalDelegateHandling
}
Expand Down
5 changes: 4 additions & 1 deletion Client/Application/ClientPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ extension Preferences {
static let blockPopups = Option<Bool>(key: "general.block-popups", default: true)
/// Controls how the tab bar should be shown (or not shown)
static let tabBarVisibility = Option<Int>(key: "general.tab-bar-visiblity", default: TabBarVisibility.always.rawValue)
/// Defines the user's normal browsing theme
/// `system`, follows the current OS display mode
static let themeNormalMode = Option<String>(key: "general.normal-mode-theme", default: Theme.DefaultTheme.system.rawValue)
static let themePrivateMode = Option<String>(key: "general.private-mode-theme", default: Theme.DefaultTheme.private.rawValue)
/// Specifies whether the bookmark button is present on toolbar
static let showBookmarkToolbarShortcut = Option<Bool>(key: "general.show-bookmark-toolbar-shortcut", default: UIDevice.isIpad)
/// Sets Desktop UA for iPad by default (iOS 13+ & iPad only)
static let alwaysRequestDesktopSite = Option<Bool>(key: "general.always-request-desktop-site", default: UIDevice.isIpad)

/// Whether or not a user has enabled Night Mode.
///
/// Currently unused
Expand Down
39 changes: 39 additions & 0 deletions Client/Assets/Themes/ACE618A3-D6FC-45A4-94F2-1793C40AE927.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"uuid": "ACE618A3-D6FC-45A4-94F2-1793C40AE927",
"title": "Default light",
"url": "www.brave.com",
"description": "The standard default light theme",
"thumbnail": "https://www.google.com",
"isDark": false,
"enabled": true,

"colors": {
"header": "0xf4f4f4",
"footer": "0xf8f8f8",
"home": "0xe8e8e8",
"addressBar": "0xffffff",
"border": "0x000000",
"accent": "0xfb542b",
"tints": {
"home": "0x434351",
"header": "0x434351",
"footer": "0x434351",
"addressBar": "0x434351"
},
"transparencies": {
"addressBarAlpha": 1.0,
"borderAlpha": 0.2,
},
"stats": {
"ads": "0xFA4214",
"trackers": "0x742BC4",
"httpse": "0x9339D4",
"timeSaved": "0x222326"
}
},
"images": {
"header": "https://www.google.com",
"footer": "https://www.google.com",
"home": "https://www.google.com",
}
}
40 changes: 40 additions & 0 deletions Client/Assets/Themes/B900A41F-2C02-4664-9DE4-C170956339AC.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"uuid": "B900A41F-2C02-4664-9DE4-C170956339AC",
"title": "Default dark",
"url": "www.brave.com",
"description": "The standard default dark theme",
"thumbnail": "https://www.google.com",
"isDark": true,
"enabled": true,

"colors": {
"header": "0x282828",
"footer": "0x282828",
"home": "0x1c1c1c",
"addressBar": "0x444444",
"border": "0xffffff",
"accent": "0xff631c",
"tints": {
"home": "0xE7E6E9",
"header": "0xE7E6E9",
"footer": "0xE7E6E9",
"addressBar": "0xE7E6E9"
},
"transparencies": {
"addressBarAlpha": 1.0,
"borderAlpha": 0.2,
},
"stats": {
"ads": "0xFA4214",
"trackers": "0x1bc760",
"httpse": "0x9339D4",
"timeSaved": "0xffffff"
}
},
"images": {
"header": "https://www.google.com",
"footer": "https://www.google.com",
"home": "https://www.google.com",
}
}

39 changes: 39 additions & 0 deletions Client/Assets/Themes/C5CB0D9A-5467-432C-AB35-1A78C55CFB41.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"uuid": "C5CB0D9A-5467-432C-AB35-1A78C55CFB41",
"title": "Default private",
"url": "www.brave.com",
"description": "The standard default private theme",
"thumbnail": "https://www.google.com",
"isDark": true,
"enabled": true,

"colors": {
"header": "0x1B0C32",
"footer": "0x1B0C32",
"home": "0x301B5A",
"addressBar": "0x3D2742",
"border": "0xffffff",
"accent": "0xcf68ff",
"tints": {
"home": "0xE7E6E9",
"header": "0xE7E6E9",
"footer": "0xE7E6E9",
"addressBar": "0xE7E6E9"
},
"transparencies": {
"addressBarAlpha": 1.0,
"borderAlpha": 0.2,
},
"stats": {
"ads": "0xFA4214",
"trackers": "0x1bc760",
"httpse": "0x9339D4",
"timeSaved": "0xffffff"
}
},
"images": {
"header": "https://www.google.com",
"footer": "https://www.google.com",
"home": "https://www.google.com",
}
}
Loading

0 comments on commit 45787a9

Please sign in to comment.