Skip to content

Commit

Permalink
Localization and error style for visitor message
Browse files Browse the repository at this point in the history
This commit adds localization, extends VisitorChatMessageStyle and RemoteConfiguration to customize visitor message error state.

MOB-3597
  • Loading branch information
Egor Egorov committed Sep 30, 2024
1 parent fa640ff commit 77dacad
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
8 changes: 6 additions & 2 deletions GliaWidgets/Localization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ internal enum Localization {
internal static var delivered: String { Localization.tr("Localizable", "chat.message.delivered", fallback: "Delivered") }
/// Send a message to start chatting
internal static var startEngagementPlaceholder: String { Localization.tr("Localizable", "chat.message.start_engagement_placeholder", fallback: "Send a message to start chatting") }
internal enum FailedToDeliver {
/// Failed to deliver. Tap to retry.
internal static var retry: String { Localization.tr("Localizable", "chat.message.failed_to_deliver.retry", fallback: "Failed to deliver. Tap to retry.") }
}
internal enum Unread {
internal enum Accessibility {
/// Unread messages
Expand Down Expand Up @@ -459,9 +463,9 @@ internal enum Localization {
internal static var close: String { Localization.tr("Localizable", "general.close", fallback: "Close") }
/// Comment
internal static var comment: String { Localization.tr("Localizable", "general.comment", fallback: "Comment") }
/// Company Name
///
internal static var companyName: String { Localization.tr("Localizable", "general.company_name", fallback: "") }
/// Company Name without asking string provider
/// without asking string provider
internal static var companyNameLocalFallbackOnly: String { Localization.tr("Localizable", "general.company_name", fallback: "", stringProviding: nil) }
/// Decline
internal static var decline: String { Localization.tr("Localizable", "general.decline", fallback: "Decline") }
Expand Down
1 change: 1 addition & 0 deletions GliaWidgets/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"chat.operator_name.accessibility.label" = "Operator Name";
"chat.operator_joined.system_message" = "{operatorName} has joined the conversation.";
"chat.message.delivered" = "Delivered";
"chat.message.failed_to_deliver.retry" = "Failed to deliver. Tap to retry.";
"chat.status.typing" = "Operator is typing";
"chat.status.typing.accessibility.label" = "{operatorName} is typing";
"chat.unread_message_divider" = "New Messages";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ extension RemoteConfiguration {
let text: Text?
let file: FileMessage?
let status: Text?
let error: Text?
let userImage: UserImageStyle?
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ extension Theme.VisitorMessageStyle {
assetsBuilder: assetsBuilder
)

error.apply(
configuration: configuration?.error,
assetsBuilder: assetsBuilder
)

fileDownload.apply(
configuration: configuration?.file,
assetsBuilder: assetsBuilder
Expand Down
17 changes: 17 additions & 0 deletions GliaWidgets/Sources/Theme/Chat/Theme.VisitorChatMessageStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public extension Theme {
/// Text of the message delivered status.
public var delivered: String

/// Style of the message error text.
public var error: Text

/// Text of the failed to deliver message status.
public var failedToDeliver: String

/// Accessibility related properties.
public var accessibility: Accessibility

Expand All @@ -31,6 +37,8 @@ public extension Theme {
/// - fileDownload: Style of the downloadable file content.
/// - status: Style of the message status text.
/// - delivered: Text of the message delivered status.
/// - error: Style of the message error text.
/// - failedToDeliver: Text of the failed to deliver message status.
/// - accessibility: Accessibility related properties.
///
public init(
Expand All @@ -40,6 +48,13 @@ public extension Theme {
fileDownload: ChatFileDownloadStyle,
status: Text,
delivered: String,
error: Text = .init(
color: "D11149",
font: UIFont.systemFont(ofSize: 12, weight: .regular),
textStyle: .caption1,
accessibility: .init(isFontScalingEnabled: true)
),
failedToDeliver: String = "",
accessibility: Accessibility = .unsupported
) {
self.text = text
Expand All @@ -48,6 +63,8 @@ public extension Theme {
self.fileDownload = fileDownload
self.status = status
self.delivered = delivered
self.error = error
self.failedToDeliver = failedToDeliver
self.accessibility = accessibility
}
}
Expand Down
7 changes: 7 additions & 0 deletions GliaWidgets/Sources/Theme/Theme+Chat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ extension Theme {
accessibility: .init(isFontScalingEnabled: true)
),
delivered: Localization.Chat.Message.delivered,
error: .init(
color: color.systemNegative.hex,
font: font.caption,
textStyle: .caption1,
accessibility: .init(isFontScalingEnabled: true)
),
failedToDeliver: Localization.Chat.Message.FailedToDeliver.retry,
accessibility: .init(isFontScalingEnabled: true)
)
let operatorImageFile = ChatImageFileContentStyle(
Expand Down

0 comments on commit 77dacad

Please sign in to comment.