Skip to content

Commit

Permalink
#5199 fix some automatic color values, if the branding color is brigh…
Browse files Browse the repository at this point in the history
…t. Before we only had a look if the branding color is white, but this does not work. Introduced a new welcome style for informal button, because the general informal button color does not work for the login screen in all cases (#1132)

Co-authored-by: Matthias Hühne <>
  • Loading branch information
hosy authored Aug 1, 2022
1 parent c1f857e commit adf1ccc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
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

0 comments on commit adf1ccc

Please sign in to comment.