-
Notifications
You must be signed in to change notification settings - Fork 0
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 #33 from surfstudio/SPT-1509-color-customization
SPT-1509 DebugScreen, цветовая кастомизация
- Loading branch information
Showing
24 changed files
with
396 additions
and
27 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
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 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 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
79 changes: 79 additions & 0 deletions
79
DebugScreen/Common/Models/Appearance/ButtonAppearance.swift
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,79 @@ | ||
// | ||
// ButtonAppearance.swift | ||
// | ||
// | ||
// Created by Ilya Klimenyuk on 29.06.2023. | ||
// | ||
|
||
import UIKit | ||
|
||
/// Debug screen button appearance. | ||
/// | ||
/// Every debug screen button can be configured with custom background and text colors. | ||
/// If custom colors haven't been initialized, the default colors will be used. | ||
public struct ButtonAppearance { | ||
|
||
// MARK: - Properties | ||
|
||
/// Button's background color for highlighted and selected states. | ||
private(set) var highlightedBackground: UIColor | ||
/// Button's background color for normal state. | ||
private(set) var normalBackground: UIColor | ||
/// Button's text color for all states. | ||
private(set) var textColor: UIColor | ||
|
||
// MARK: - Initialization | ||
|
||
/// Allows you to create appearance object with default values, | ||
/// that depends on passed `style` parameter. | ||
public init(style: ActionStyle, | ||
highlightedBackground: UIColor? = nil, | ||
normalBackground: UIColor? = nil, | ||
textColor: UIColor? = nil) { | ||
// Set default colors according to button style | ||
self.init(highlightedBackground: style.highlightedBackgroundColor, | ||
normalBackground: style.backgroundColor, | ||
textColor: style.titleColor) | ||
|
||
// Set custom colors (if needed) | ||
if let highlightedBackground = highlightedBackground { | ||
self.highlightedBackground = highlightedBackground | ||
} | ||
|
||
if let normalBackground = normalBackground { | ||
self.normalBackground = normalBackground | ||
} | ||
|
||
if let textColor = textColor { | ||
self.textColor = textColor | ||
} | ||
} | ||
|
||
/// Allows you to create appearance object with your own custom values | ||
private init(highlightedBackground: UIColor, | ||
normalBackground: UIColor, | ||
textColor: UIColor) { | ||
self.highlightedBackground = highlightedBackground | ||
self.normalBackground = normalBackground | ||
self.textColor = textColor | ||
} | ||
|
||
// MARK: - Static Methods | ||
|
||
/** | ||
Get button appearance settings with selected style. | ||
- Parameter style: Button action style. | ||
- Returns: Button appearance. | ||
For example, if we want to get primary button default appearance settings: | ||
```swift | ||
let primary: ButtonAppearance = .appearance(for: .primary) | ||
``` | ||
*/ | ||
static func appearance(for style: ActionStyle) -> ButtonAppearance { | ||
return .init(highlightedBackground: style.highlightedBackgroundColor, | ||
normalBackground: style.backgroundColor, | ||
textColor: style.titleColor) | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
DebugScreen/Common/Models/Appearance/ButtonConfigurations.swift
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 @@ | ||
// | ||
// ButtonConfigurations.swift | ||
// | ||
// | ||
// Created by Ilya Klimenyuk on 29.06.2023. | ||
// | ||
|
||
/// Representation of all available action buttons apperance configurations. | ||
public struct ButtonConfigurations { | ||
|
||
// MARK: - Properties | ||
|
||
/// Primary button apperance configuration. | ||
private(set) var primary: ButtonAppearance = .appearance(for: .primary) | ||
/// Secondary button appearance configuration. | ||
private(set) var secondary: ButtonAppearance = .appearance(for: .secondary) | ||
/// Destructive button apperance configuration. | ||
private(set) var destructive: ButtonAppearance = .appearance(for: .destructive) | ||
|
||
// MARK: - Initialization | ||
|
||
public init(primary: ButtonAppearance? = nil, | ||
secondary: ButtonAppearance? = nil, | ||
destructive: ButtonAppearance? = nil) { | ||
|
||
if let primary = primary { | ||
self.primary = primary | ||
} | ||
|
||
if let secondary = secondary { | ||
self.secondary = secondary | ||
} | ||
|
||
if let destructive = destructive { | ||
self.destructive = destructive | ||
} | ||
} | ||
|
||
} |
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,59 @@ | ||
// | ||
// ColorScheme.swift | ||
// | ||
// | ||
// Created by Ilya Klimenyuk on 29.06.2023. | ||
// | ||
|
||
import UIKit | ||
|
||
/// Representation of DebugScreen color scheme. | ||
/// | ||
/// You can override all available color components. | ||
/// If custom colors haven't been initialized, the default colors will be used. | ||
public struct ColorScheme { | ||
|
||
// MARK: - Properties | ||
|
||
/// DebugScreen views background color. | ||
private(set) var backgroundColor = Colors.Main.background | ||
/// DebugScreen text color. Used for section headers and close icon. | ||
private(set) var textColor = Colors.Text.primary | ||
/// DebugScreen secondary text color. Used for section headers and labels at an info screens. | ||
private(set) var textSecondaryColor = Colors.Text.secondary | ||
/// DebugScreen action buttons appearance configurations. | ||
private(set) var buttonConfigurations = ButtonConfigurations() | ||
|
||
// MARK: - Initialization | ||
|
||
public init(backgroundColor: UIColor? = nil, | ||
textColor: UIColor? = nil, | ||
textSecondaryColor: UIColor? = nil, | ||
buttonConfigurations: ButtonConfigurations? = nil) { | ||
|
||
if let backgroundColor = backgroundColor { | ||
self.backgroundColor = backgroundColor | ||
} | ||
|
||
if let textColor = textColor { | ||
self.textColor = textColor | ||
} | ||
|
||
if let textSecondaryColor = textSecondaryColor { | ||
self.textSecondaryColor = textSecondaryColor | ||
} | ||
|
||
if let buttonConfigurations = buttonConfigurations { | ||
self.buttonConfigurations = buttonConfigurations | ||
} | ||
} | ||
|
||
// MARK: - Static Methods | ||
|
||
/// Get DebugScreen default color scheme. | ||
/// - Returns: Default color scheme. | ||
static func `default`() -> ColorScheme { | ||
return .init() | ||
} | ||
|
||
} |
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 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 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 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 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 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
Oops, something went wrong.