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

feat: [HCPSDKFIORIUIKIT-2157, 2162] new ColorPaletteV7. #426

Merged
merged 10 commits into from
May 9, 2022
2 changes: 1 addition & 1 deletion Sources/FioriSwiftUICore/DataTable/LayoutData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class LayoutData {
if let styleName = tmpUIFont.fontDescriptor.fontAttributes[.textStyle] as? String {
let textStyle = UIFont.TextStyle(rawValue: styleName)
uifont = UIFont.preferredFont(forTextStyle: textStyle)
}else {
} else {
uifont = tmpUIFont
}
} else if let _font = item.font {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Foundation

struct ColorCompatibilityMapV6: ColorStyleCompatibilityProvider {
let uuid = UUID()

static let `default` = ColorCompatibilityMap(ColorCompatibilityMapV6())

let version: PaletteVersion = .v6

private init() {}

var compatibleColorDefinitions: [ColorStyle: ColorStyle] = [:]

func compatibleStyle(from style: ColorStyle) -> ColorStyle? {
self.compatibleColorDefinitions[style]
}
}
617 changes: 473 additions & 144 deletions Sources/FioriThemeManager/Colors/ColorStyle.swift

Large diffs are not rendered by default.

212 changes: 212 additions & 0 deletions Sources/FioriThemeManager/Palettes/PaletteV7.swift

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion Sources/FioriThemeManager/Palettes/PaletteVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ extension PaletteVersion: RawRepresentable {
self = .v5
case PaletteV6.default:
self = .v6
case PaletteV7.default:
self = .v7
default:
return nil
}
Expand All @@ -36,11 +38,15 @@ extension PaletteVersion: RawRepresentable {
return PaletteV5.default
case .v6:
return PaletteV6.default
case .v7:
return PaletteV7.default
}
}

var compatibilityMap: ColorCompatibilityMap? {
switch self {
case .v6:
return ColorCompatibilityMapV6.default
case .v5:
return ColorCompatibilityMapV5.default
case .v4:
Expand Down Expand Up @@ -84,7 +90,14 @@ public enum PaletteVersion: CaseIterable, Comparable {
*/
case v6

/// Palette version which should be adopted by developer, if creating a custom palette from scratch.
/**
Snapshot of palette at SAP Fiori SDK version 8.0.

- Important: Referred to in SAP Fiori Design Guidelines as 'Fiori Next' styling.
*/
case v7

/// FUIPalette version which should be adopted by developer, if creating a custom palette from scratch.
/// - Note: Creating a custom palette from scratch is very uncommon and not generally recommended: it is more typical and convenient to override specific colors of the current system-provided palette, using the `ThemeManager.shared.setColor(...)` or `ThemeManager.shared.setHexColor(...)` APIs.
public static let latest: PaletteVersion = { allCases.last! }()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ class ArrayAnyExtensiontests: XCTestCase {
func testFlatCompactMapForVariadicParameters() throws {
struct Container {
var params: [Any]!

mutating func apply(objects: Any...) -> Container {
Container(params: objects)
}
}

func createContainer(objects: Any...) -> Container {
var container = Container()
return container.apply(objects: objects)
}

let optionalAny: Any? = nil
let container = createContainer(objects: "Hello", optionalAny as Any)

let unpackedParameters = container.params!
XCTAssertEqual(unpackedParameters.debugDescription, "[[\"Hello\", nil]]")

let result = unpackedParameters.flatCompactMapForVariadicParameters()
XCTAssertEqual(result.debugDescription, "[\"Hello\"]")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,29 @@ import UIKit
import XCTest

class ThemeManagerTests: XCTestCase {
func testLatestColorStyle() throws {
XCTAssertEqual(ColorStyle.allCases.count, 181)
}

func testPaletteV7() throws {
let tm = ThemeManager.shared
tm.setPaletteVersion(.v7)
XCTAssertEqual(tm.paletteVersion?.supportedStyles().count, 181)
XCTAssertEqual(tm.paletteVersion?.obsoletedStyles().count, 0)
XCTAssertEqual(tm.paletteVersion?.newStyles().count, 49)
let newStyle_grey1 = tm.hexColor(for: .grey1)
XCTAssertEqual(newStyle_grey1, HexColor(lightColor: "12171CFF", darkColor: "F5F6F7FF", contrastLightColor: "1C242BFF", contrastDarkColor: "EAECEEFF"))
let newStyle_primaryLabel = tm.hexColor(for: .primaryLabel)
XCTAssertEqual(newStyle_primaryLabel, HexColor(lightColor: "F5F6F7FF", darkColor: "223548FF", contrastLightColor: "FFFFFFFF", contrastDarkColor: "000000FF"))
let obsoletedStyle_line = tm.hexColor(for: .line)
XCTAssertEqual(obsoletedStyle_line, HexColor(lightColor: "8696A9", darkColor: "89919A"))
let obsoletedStyle_negative = tm.hexColor(for: .negative)
XCTAssertEqual(obsoletedStyle_negative, HexColor(lightColor: "FF8888", darkColor: "BB0000"))
}

func testPaletteV6() throws {
let tm = ThemeManager.shared
tm.setPaletteVersion(.v6)
XCTAssertEqual(ColorStyle.allCases.count, 132)
XCTAssertEqual(tm.paletteVersion?.supportedStyles().count, 132)
XCTAssertEqual(tm.paletteVersion?.obsoletedStyles().count, 38)
XCTAssertEqual(tm.paletteVersion?.newStyles().count, 78)
Expand Down