-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from adevinta/theme
Added theme protocols, default structures and spark implementation (Colors, Typography, Border and Layout)
- Loading branch information
Showing
60 changed files
with
1,864 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,3 +103,6 @@ out | |
|
||
#snapshots | ||
spark-ios-snapshots | ||
|
||
#plists | ||
*.plist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// Bundle+Extension.swift | ||
// Spark | ||
// | ||
// Created by robin.lemaire on 02/03/2023. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
public extension Bundle { | ||
|
||
// MARK: - Constants | ||
|
||
private enum Constants { | ||
static let fontExtensions = ["ttf", "otf"] | ||
} | ||
|
||
// MARK: - Fonts | ||
|
||
func registerAllFonts() { | ||
// Get all custom fonts on bundle | ||
let fontURLs = Constants.fontExtensions.compactMap { fontExtension in | ||
self.urls(forResourcesWithExtension: fontExtension, subdirectory: nil) | ||
} | ||
.flatMap { | ||
$0 | ||
} | ||
.map { | ||
$0 as CFURL | ||
} | ||
|
||
// Try to register all customs fonts | ||
fontURLs.forEach { | ||
guard let fontDataProvider = CGDataProvider(url: $0), | ||
let font = CGFont(fontDataProvider) else { | ||
return | ||
} | ||
|
||
var error: Unmanaged<CFError>? | ||
CTFontManagerRegisterGraphicsFont(font, &error) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// | ||
// Configuration.swift | ||
// Spark | ||
// | ||
// Created by robin.lemaire on 02/03/2023. | ||
// | ||
|
||
public protocol Configuration { | ||
|
||
static func load() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// Border.swift | ||
// SparkCore | ||
// | ||
// Created by robin.lemaire on 28/02/2023. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol Border { | ||
var width: BorderWidth { get } | ||
var radius: BorderRadius { get } | ||
} | ||
|
||
// MARK: - Width | ||
|
||
public protocol BorderWidth { | ||
var none: CGFloat { get } | ||
var small: CGFloat { get } | ||
var medium: CGFloat { get } | ||
} | ||
|
||
public extension BorderWidth { | ||
var none: CGFloat { 0 } | ||
} | ||
|
||
// MARK: - Radius | ||
|
||
public protocol BorderRadius { | ||
var none: CGFloat { get } | ||
var small: CGFloat { get } | ||
var medium: CGFloat { get } | ||
var large: CGFloat { get } | ||
var xLarge: CGFloat { get } | ||
} | ||
|
||
public extension BorderRadius { | ||
var none: CGFloat { 0 } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// BorderDefault.swift | ||
// SparkCore | ||
// | ||
// Created by robin.lemaire on 28/02/2023. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct BorderDefault: Border { | ||
|
||
// MARK: - Properties | ||
|
||
public let width: BorderWidth | ||
public let radius: BorderRadius | ||
|
||
// MARK: - Initialization | ||
|
||
public init(width: BorderWidth, radius: BorderRadius) { | ||
self.width = width | ||
self.radius = radius | ||
} | ||
} | ||
|
||
// MARK: - Width | ||
|
||
public struct BorderWidthDefault: BorderWidth { | ||
|
||
// MARK: - Properties | ||
|
||
public let small: CGFloat | ||
public let medium: CGFloat | ||
|
||
// MARK: - Initialization | ||
|
||
public init(small: CGFloat, | ||
medium: CGFloat) { | ||
self.small = small | ||
self.medium = medium | ||
} | ||
} | ||
|
||
// MARK: - Radius | ||
|
||
public struct BorderRadiusDefault: BorderRadius { | ||
|
||
// MARK: - Properties | ||
|
||
public let small: CGFloat | ||
public let medium: CGFloat | ||
public let large: CGFloat | ||
public let xLarge: CGFloat | ||
|
||
// MARK: - Initialization | ||
|
||
public init(small: CGFloat, | ||
medium: CGFloat, | ||
large: CGFloat, | ||
xLarge: CGFloat) { | ||
self.small = small | ||
self.medium = medium | ||
self.large = large | ||
self.xLarge = xLarge | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// Colors.swift | ||
// SparkCore | ||
// | ||
// Created by louis.borlee on 23/02/2023. | ||
// | ||
|
||
import UIKit | ||
import SwiftUI | ||
|
||
public protocol Colors { | ||
var primary: ColorToken { get } | ||
var primaryVariant: ColorToken { get } | ||
|
||
var secondary: ColorToken { get } | ||
var secondaryVariant: ColorToken { get } | ||
|
||
var background: ColorToken { get } | ||
|
||
var surface: ColorToken { get } | ||
var surfaceInverse: ColorToken { get } | ||
|
||
var success: ColorToken { get } | ||
var alert: ColorToken { get } | ||
var error: ColorToken { get } | ||
var info: ColorToken { get } | ||
var neutral: ColorToken { get } | ||
|
||
var primaryContainer: ColorToken { get } | ||
var secondaryContainer: ColorToken { get } | ||
var successContainer: ColorToken { get } | ||
var alertContainer: ColorToken { get } | ||
var errorContainer: ColorToken { get } | ||
var infoContainer: ColorToken { get } | ||
var neutralContainer: ColorToken { get } | ||
} | ||
|
||
// MARK: - Token | ||
|
||
public protocol ColorToken { | ||
var enabled: ColorTokenValue { get } | ||
var pressed: ColorTokenValue { get } | ||
var disabled: ColorTokenValue { get } | ||
var on: ColorTokenValue { get } | ||
} | ||
|
||
// MARK: - Value | ||
|
||
public protocol ColorTokenValue { | ||
var uiColor: UIColor { get } | ||
var swiftUIcolor: Color { get } | ||
} |
Oops, something went wrong.