-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworked styles for chat message views
Added supporting for borders and gradiented backgrounds
- Loading branch information
Egor Egorov
authored and
github-review-helper
committed
Aug 16, 2023
1 parent
c298636
commit d6fe2d7
Showing
39 changed files
with
1,399 additions
and
190 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
67 changes: 67 additions & 0 deletions
67
GliaWidgets/Sources/Theme/Chat/Theme.ChatMessageStyle.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,67 @@ | ||
import UIKit | ||
|
||
extension Theme { | ||
/// Internal base style of a chat message. | ||
struct ChatMessageStyle { | ||
/// Style of the message text. | ||
let text: Text | ||
/// Style of the message background. | ||
let background: Layer | ||
/// Style of the image content. | ||
let imageFile: ChatImageFileContentStyle | ||
/// Style of the image content. | ||
let fileDownload: ChatFileDownloadStyle | ||
/// Accessibility related properties. | ||
let accessibility: Accessibility | ||
|
||
/// | ||
/// - Parameters: | ||
/// - text: Style of the message text. | ||
/// - background: Style of the message background. | ||
/// - imageFile: Style of the image content. | ||
/// - fileDownload: Style of the downloadable file content. | ||
/// - accessibility: Accessibility related properties. | ||
/// | ||
init( | ||
text: Text, | ||
background: Layer, | ||
imageFile: ChatImageFileContentStyle, | ||
fileDownload: ChatFileDownloadStyle, | ||
accessibility: Accessibility = .unsupported | ||
) { | ||
self.text = text | ||
self.background = background | ||
self.imageFile = imageFile | ||
self.fileDownload = fileDownload | ||
self.accessibility = accessibility | ||
} | ||
} | ||
} | ||
|
||
extension Theme.ChatMessageStyle { | ||
/// Accessibility properties for ChatMessageStyle. | ||
struct Accessibility: Equatable { | ||
/// Accessibility value. | ||
var value: String | ||
/// Flag that provides font dynamic type by setting `adjustsFontForContentSizeCategory` for component that supports it. | ||
var isFontScalingEnabled: Bool | ||
|
||
/// | ||
/// - Parameters: | ||
/// - value: Accessibility value. | ||
/// - isFontScalingEnabled: Flag that provides font dynamic type by setting `adjustsFontForContentSizeCategory` for component that supports it. | ||
init( | ||
value: String = "", | ||
isFontScalingEnabled: Bool | ||
) { | ||
self.value = value | ||
self.isFontScalingEnabled = isFontScalingEnabled | ||
} | ||
|
||
/// Accessibility is not supported intentionally. | ||
static let unsupported = Self( | ||
value: "", | ||
isFontScalingEnabled: false | ||
) | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
GliaWidgets/Sources/Theme/Chat/Theme.ChatTextContentStyle.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,58 @@ | ||
import UIKit | ||
|
||
public extension Theme { | ||
/// Style of a text message. | ||
struct ChatTextContentStyle { | ||
/// Style of the message text. | ||
public var text: Text | ||
/// Style of the content view. | ||
public var background: Layer | ||
/// Accessibility related properties. | ||
public var accessibility: Accessibility | ||
|
||
/// | ||
/// - Parameters: | ||
/// - text: Style of the message text. | ||
/// - background: Style of the content view. | ||
/// - accessibility: Accessibility related properties. | ||
/// | ||
public init( | ||
text: Text, | ||
background: Layer, | ||
accessibility: Accessibility = .unsupported | ||
) { | ||
self.text = text | ||
self.background = background | ||
self.accessibility = accessibility | ||
} | ||
} | ||
} | ||
|
||
extension Theme.ChatTextContentStyle { | ||
/// Accessibility properties for ChatTextContentStyle. | ||
public struct Accessibility: Equatable { | ||
/// Accessibility value. | ||
public var value: String | ||
|
||
/// Flag that provides font dynamic type by setting `adjustsFontForContentSizeCategory` for component that supports it. | ||
public var isFontScalingEnabled: Bool | ||
|
||
/// | ||
/// - Parameters: | ||
/// - value: Accessibility value. | ||
/// - isFontScalingEnabled: Flag that provides font dynamic type by setting `adjustsFontForContentSizeCategory` for component that supports it. | ||
public init( | ||
value: String = "", | ||
isFontScalingEnabled: Bool | ||
) { | ||
self.value = value | ||
self.isFontScalingEnabled = isFontScalingEnabled | ||
} | ||
|
||
/// Accessibility is not supported intentionally. | ||
public static let unsupported = Self( | ||
value: "", | ||
isFontScalingEnabled: false | ||
) | ||
} | ||
} |
Oops, something went wrong.