Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix/bright-branding-color] Branding: Color issues #1132

Merged
merged 1 commit into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class StaticLoginSetupViewController : StaticLoginStepViewController {

onboardingSection = StaticTableViewSection(headerTitle: nil, identifier: "onboardingSection")
if let message = profile.promptForHelpURL, let title = profile.helpURLButtonString {
let (proceedButton, _) = onboardingSection.addButtonFooter(message: message, messageItemStyle: .welcomeMessage, proceedLabel: title, proceedItemStyle: .informal, cancelLabel: nil)
let (proceedButton, _) = onboardingSection.addButtonFooter(message: message, messageItemStyle: .welcomeMessage, proceedLabel: title, proceedItemStyle: .welcomeInformal, cancelLabel: nil)
proceedButton?.addTarget(self, action: #selector(self.helpAction), for: .touchUpInside)
}

Expand Down
6 changes: 6 additions & 0 deletions ownCloudAppShared/UIKit Extension/UIColor+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,10 @@ extension UIColor {

return (String(format: "\(leadIn)%02x%02x%02x", Int(selfRed*255.0), Int(selfGreen*255.0), Int(selfBlue*255.0)))
}

public func isLight() -> Bool {
guard let components = cgColor.components, components.count > 2 else {return false}
let brightness = ((components[0] * 299) + (components[1] * 587) + (components[2] * 114)) / 1000
return (brightness > 0.5)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public enum ThemeItemStyle {

case purchase
case welcome
case welcomeInformal
}

public enum ThemeItemState {
Expand Down Expand Up @@ -86,9 +87,14 @@ public extension NSObject {

case .purchase:
themeButton.themeColorCollection = collection.purchaseColors

case .welcome:
themeButton.themeColorCollection = collection.loginColors.filledColorPairCollection

case .welcome:
themeButton.themeColorCollection = collection.loginColors.filledColorPairCollection

case .welcomeInformal:
let fromPair = collection.loginColors.filledColorPairCollection
let normal = ThemeColorPair(foreground: fromPair.normal.foreground.lighter(0.25), background: fromPair.normal.background.lighter(0.25))
themeButton.themeColorCollection = ThemeColorPairCollection(fromPair: normal)

case .informal:
themeButton.themeColorCollection = collection.informalColors.filledColorPairCollection
Expand Down Expand Up @@ -210,6 +216,7 @@ public extension NSObject {

case .welcomeMessage:
normalColor = collection.loginColors.secondaryLabelColor
normalColor = collection.loginColors.secondaryLabelColor
highlightColor = collection.loginColors.secondaryLabelColor

case .message, .bigMessage:
Expand Down
15 changes: 12 additions & 3 deletions ownCloudAppShared/User Interface/Theme/ThemeCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,16 @@ public class ThemeCollection : NSObject {
self.loginColors = colors.resolveThemeColorCollection("Login", self.darkBrandColors)

// Bar styles
self.statusBarStyle = styleResolver.resolveStatusBarStyle(for: "statusBarStyle", fallback: .lightContent)
var defaultStatusBarStyle : UIStatusBarStyle = .lightContent
if let backgroundColor = self.navigationBarColors.backgroundColor, backgroundColor.isLight() {
if #available(iOSApplicationExtension 13.0, *) {
defaultStatusBarStyle = .darkContent
} else {
defaultStatusBarStyle = .default
}
}

self.statusBarStyle = styleResolver.resolveStatusBarStyle(for: "statusBarStyle", fallback: defaultStatusBarStyle)
self.loginStatusBarStyle = styleResolver.resolveStatusBarStyle(for: "loginStatusBarStyle", fallback: self.statusBarStyle)
self.barStyle = styleResolver.resolveBarStyle(fallback: .black)

Expand All @@ -411,10 +420,10 @@ public class ThemeCollection : NSObject {
// Logo fill color
logoFillColor = UIColor.lightGray

if lightBrandColor.isEqual(UIColor(hex: 0xFFFFFF)) {
if lightBrandColor.isLight() {
self.neutralColors.normal.background = self.darkBrandColor
self.lightBrandColors.filledColorPairCollection.normal.background = self.darkBrandColor
}
}
}

self.informalColors = colors.resolveThemeColorCollection("Informal", self.lightBrandColors)
Expand Down