Skip to content

Commit

Permalink
Apply unified UI for SC's top banner on ChatView
Browse files Browse the repository at this point in the history
  • Loading branch information
ykyivskyi-gl authored and Egor Egorov committed Dec 3, 2024
1 parent 380017f commit 62a2a13
Show file tree
Hide file tree
Showing 22 changed files with 246 additions and 22 deletions.
42 changes: 37 additions & 5 deletions GliaWidgets.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@
216D31092CF5DC080019CA9E /* OverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 216D31082CF5DC080019CA9E /* OverlayView.swift */; };
216D310B2CF790980019CA9E /* EntryWidget.Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 216D310A2CF790980019CA9E /* EntryWidget.Mock.swift */; };
216D310D2CF795380019CA9E /* EntryWidgetViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 216D310C2CF795380019CA9E /* EntryWidgetViewModelTests.swift */; };
216D31172CFE25510019CA9E /* MediaTypeItemsStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 216D31162CFE25510019CA9E /* MediaTypeItemsStyle.swift */; };
216D311B2CFE25A20019CA9E /* MediaTypeItemsStyle.RemoteConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 216D311A2CFE25A20019CA9E /* MediaTypeItemsStyle.RemoteConfig.swift */; };
216D311D2CFE2ED10019CA9E /* MediaTypeItemsStyle.Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 216D311C2CFE2ED10019CA9E /* MediaTypeItemsStyle.Mock.swift */; };
216D311F2CFE2F050019CA9E /* MediaTypeItemStyle.Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 216D311E2CFE2F050019CA9E /* MediaTypeItemStyle.Mock.swift */; };
2188DED22CECC3D400FA3BEF /* SecureMessagingTopBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2188DED12CECC3D400FA3BEF /* SecureMessagingTopBannerView.swift */; };
2188DED42CECE15800FA3BEF /* SecureMessagingTopBannerViewStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2188DED32CECE15800FA3BEF /* SecureMessagingTopBannerViewStyle.swift */; };
2188DEDD2CEE2C3F00FA3BEF /* SecureMessagingBottomBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2188DED92CEE2C3F00FA3BEF /* SecureMessagingBottomBannerView.swift */; };
Expand Down Expand Up @@ -1268,6 +1272,10 @@
216D31082CF5DC080019CA9E /* OverlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OverlayView.swift; sourceTree = "<group>"; };
216D310A2CF790980019CA9E /* EntryWidget.Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryWidget.Mock.swift; sourceTree = "<group>"; };
216D310C2CF795380019CA9E /* EntryWidgetViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryWidgetViewModelTests.swift; sourceTree = "<group>"; };
216D31162CFE25510019CA9E /* MediaTypeItemsStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaTypeItemsStyle.swift; sourceTree = "<group>"; };
216D311A2CFE25A20019CA9E /* MediaTypeItemsStyle.RemoteConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaTypeItemsStyle.RemoteConfig.swift; sourceTree = "<group>"; };
216D311C2CFE2ED10019CA9E /* MediaTypeItemsStyle.Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaTypeItemsStyle.Mock.swift; sourceTree = "<group>"; };
216D311E2CFE2F050019CA9E /* MediaTypeItemStyle.Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaTypeItemStyle.Mock.swift; sourceTree = "<group>"; };
2188DED12CECC3D400FA3BEF /* SecureMessagingTopBannerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecureMessagingTopBannerView.swift; sourceTree = "<group>"; };
2188DED32CECE15800FA3BEF /* SecureMessagingTopBannerViewStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureMessagingTopBannerViewStyle.swift; sourceTree = "<group>"; };
2188DED92CEE2C3F00FA3BEF /* SecureMessagingBottomBannerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecureMessagingBottomBannerView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3350,6 +3358,29 @@
path = EngagementLauncher;
sourceTree = "<group>";
};
216D31182CFE25570019CA9E /* MediaTypeItem */ = {
isa = PBXGroup;
children = (
C0C5BB762CAD4259001B2025 /* MediaTypeItemStyle.swift */,
AFA7A8A62CD9482E00861322 /* MediaTypeItemStyle.Accessibility.swift */,
216D311E2CFE2F050019CA9E /* MediaTypeItemStyle.Mock.swift */,
C0C5BB782CAD42FD001B2025 /* MediaTypeItemStyle.RemoteConfig.swift */,
AFB6A0782CCBF3B700A1ED9A /* MediaTypeItemStyle.Loading.swift */,
AFB6A07A2CCBF53800A1ED9A /* MediaTypeItemStyle.Loading.Accessibility.swift */,
);
path = MediaTypeItem;
sourceTree = "<group>";
};
216D31192CFE25630019CA9E /* MediaTypeItems */ = {
isa = PBXGroup;
children = (
216D31162CFE25510019CA9E /* MediaTypeItemsStyle.swift */,
216D311C2CFE2ED10019CA9E /* MediaTypeItemsStyle.Mock.swift */,
216D311A2CFE25A20019CA9E /* MediaTypeItemsStyle.RemoteConfig.swift */,
);
path = MediaTypeItems;
sourceTree = "<group>";
};
2188DED52CECE18C00FA3BEF /* SecureMessaging */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -5213,6 +5244,8 @@
C0F3DE352C69F4A700DE6D7B /* EntryWidget */ = {
isa = PBXGroup;
children = (
216D31192CFE25630019CA9E /* MediaTypeItems */,
216D31182CFE25570019CA9E /* MediaTypeItem */,
C0F7EA372CA1D6D40038019C /* CustomPresentationController.swift */,
216D31022CEF83A90019CA9E /* EntryWidget.Builder.swift */,
C0F3DE362C69F51D00DE6D7B /* EntryWidget.swift */,
Expand All @@ -5224,11 +5257,6 @@
C034EEEC2CAAB525002650B8 /* EntryWidgetStyle.RemoteConfig.swift */,
C0F3DE3A2C6E0DD900DE6D7B /* EntryWidgetView.swift */,
C0F3DE3C2C6E170600DE6D7B /* EntryWidgetViewModel.swift */,
C0C5BB762CAD4259001B2025 /* MediaTypeItemStyle.swift */,
AFA7A8A62CD9482E00861322 /* MediaTypeItemStyle.Accessibility.swift */,
C0C5BB782CAD42FD001B2025 /* MediaTypeItemStyle.RemoteConfig.swift */,
AFB6A0782CCBF3B700A1ED9A /* MediaTypeItemStyle.Loading.swift */,
AFB6A07A2CCBF53800A1ED9A /* MediaTypeItemStyle.Loading.Accessibility.swift */,
);
path = EntryWidget;
sourceTree = "<group>";
Expand Down Expand Up @@ -6036,6 +6064,7 @@
C0D6CA092C18451800D4709B /* CallViewController.Environment.swift in Sources */,
84D5B9622A14F33400807F92 /* QuickLookBased.Live.swift in Sources */,
C09047152B7E18E7003C437C /* Theme.Text.Accessibility.swift in Sources */,
216D311F2CFE2F050019CA9E /* MediaTypeItemStyle.Mock.swift in Sources */,
AF6291112B0813B000D3D76B /* SwiftBased.Live.swift in Sources */,
75940953298D3832008B173A /* Command.swift in Sources */,
75C1143429A3F58E0004E5F7 /* RemoteConfiguration+SecureConversationsWelcomeScreen.swift in Sources */,
Expand Down Expand Up @@ -6095,6 +6124,7 @@
AFF4412D2CD572AE0088B1C5 /* ChatMessageEntryView.StateStyle.swift in Sources */,
1A0452F025DBE268000DA0C1 /* MessageButtonStateStyle.swift in Sources */,
216D31052CF4D3590019CA9E /* ChatView.DefineLayout.swift in Sources */,
216D311B2CFE25A20019CA9E /* MediaTypeItemsStyle.RemoteConfig.swift in Sources */,
EB2CBB1227D89F7D004F178E /* OnHoldOverlayStyle.swift in Sources */,
C09047482B7E20B0003C437C /* FileUploadStateStyle.Mock.swift in Sources */,
75940983298D38C2008B173A /* VisitorCodeViewModel+Delegate.swift in Sources */,
Expand Down Expand Up @@ -6189,6 +6219,7 @@
1A60B0192567FC8A00E53F53 /* ButtonKind.swift in Sources */,
AFA5E96229F2CF9400F13DB7 /* SecureConversations.TranscriptModel.DividedChatItemsForUnreadCount.swift in Sources */,
C42463742673ABE10082C135 /* ScreenShareHandler.Interface.swift in Sources */,
216D311D2CFE2ED10019CA9E /* MediaTypeItemsStyle.Mock.swift in Sources */,
3100EEFD293F757E00D57F71 /* SecureConversations.WelcomeStyle.swift in Sources */,
C09046F02B7E0F78003C437C /* Theme.OperatorChatMessageStyle.RemoteConfig.swift in Sources */,
755D187729A6A6D70009F5E8 /* WelcomeStyle.MessageWarningStyle.swift in Sources */,
Expand Down Expand Up @@ -6500,6 +6531,7 @@
AF7753102B19EB9500E523A2 /* Logger.Interface.swift in Sources */,
1A1E309625F8CA4400850E68 /* FileDownload.swift in Sources */,
EB2CBB1527D8DB95004F178E /* OnHoldOverlayVisualEffectView.swift in Sources */,
216D31172CFE25510019CA9E /* MediaTypeItemsStyle.swift in Sources */,
AFEF5C7129929601005C3D8D /* SecureConversations.FilePreviewView.swift in Sources */,
C090475C2B7E2254003C437C /* FileUploadListStyle.Mock.swift in Sources */,
1A4AD3AF256D283700468BFB /* ChatMessageView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extension SecureConversations.TranscriptModel {
var leaveCurrentSecureConversation: Cmd
var createEntryWidget: EntryWidgetBuilder
var switchToEngagement: Command<EngagementKind>
var topBannerItemsStyle: EntryWidgetStyle.MediaTypeItemsStyle
}
}

Expand Down Expand Up @@ -77,7 +78,8 @@ extension SecureConversations.TranscriptModel.Environment {
shouldShowLeaveSecureConversationDialog: environment.shouldShowLeaveSecureConversationDialog,
leaveCurrentSecureConversation: environment.leaveCurrentSecureConversation,
createEntryWidget: environment.createEntryWidget,
switchToEngagement: environment.switchToEngagement
switchToEngagement: environment.switchToEngagement,
topBannerItemsStyle: viewFactory.theme.chat.secureMessagingExpandedTopBannerItemsStyle
)
}
}
Expand Down Expand Up @@ -117,7 +119,9 @@ extension SecureConversations.TranscriptModel.Environment {
shouldShowLeaveSecureConversationDialog: Bool = false,
leaveCurrentSecureConversation: Cmd = .nop,
createEntryWidget: @escaping EntryWidgetBuilder = { _ in .mock() },
switchToEngagement: Command<EngagementKind> = .nop
switchToEngagement: Command<EngagementKind> = .nop,
// swiftlint:disable:next line_length
secureMessagingExpandedTopBannerItemsStyle: EntryWidgetStyle.MediaTypeItemsStyle = Theme().chatStyle.secureMessagingExpandedTopBannerItemsStyle
) -> Self {
Self(
fetchFile: fetchFile,
Expand Down Expand Up @@ -152,7 +156,8 @@ extension SecureConversations.TranscriptModel.Environment {
shouldShowLeaveSecureConversationDialog: shouldShowLeaveSecureConversationDialog,
leaveCurrentSecureConversation: leaveCurrentSecureConversation,
createEntryWidget: createEntryWidget,
switchToEngagement: switchToEngagement
switchToEngagement: switchToEngagement,
topBannerItemsStyle: secureMessagingExpandedTopBannerItemsStyle
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,8 @@ extension SecureConversations.TranscriptModel {
),
showPoweredBy: false,
filterSecureConversation: true,
mediaTypeSelected: .init(closure: entryWidgetMediaTypeSelected)
mediaTypeSelected: .init(closure: entryWidgetMediaTypeSelected),
mediaTypeItemsStyle: environment.topBannerItemsStyle
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extension EntryWidget {
let showPoweredBy: Bool
let filterSecureConversation: Bool
let mediaTypeSelected: Command<EntryWidget.MediaTypeItem>?
let mediaTypeItemsStyle: EntryWidgetStyle.MediaTypeItemsStyle?
}
}

Expand All @@ -37,6 +38,7 @@ extension EntryWidget.Configuration {
),
showPoweredBy: true,
filterSecureConversation: false,
mediaTypeSelected: nil
mediaTypeSelected: nil,
mediaTypeItemsStyle: nil
)
}
10 changes: 9 additions & 1 deletion GliaWidgets/Sources/EntryWidget/EntryWidgetViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ extension EntryWidgetView {
let configuration: EntryWidget.Configuration
let showHeader: Bool
var retryMonitoring: (() -> Void)?

var style: EntryWidgetStyle {
theme.entryWidget
if let mediaTypeItemsStyle = configuration.mediaTypeItemsStyle {
var widgetStyle = theme.entryWidgetStyle
widgetStyle.mediaTypeItem = mediaTypeItemsStyle.mediaItemStyle
widgetStyle.dividerColor = mediaTypeItemsStyle.dividerColor
return widgetStyle
} else {
return theme.entryWidgetStyle
}
}

var showPoweredBy: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

extension EntryWidgetStyle.MediaTypeItemStyle {
/// The style of a media type item when it is loading.
public struct LoadingStyle {
public struct LoadingStyle: Equatable {
/// The color of the placeholders during the loading state.
public var loadingTintColor: ColorType

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#if DEBUG
import UIKit

extension EntryWidgetStyle.MediaTypeItemStyle {
static func mock(
chatTitle: String = "Chat",
audioTitle: String = "Audio",
videoTitle: String = "Video",
secureMessagingTitle: String = "Secure messaging",
titleFont: UIFont = .systemFont(ofSize: 16),
titleColor: UIColor = .black,
titleTextStyle: UIFont.TextStyle = .body,
chatMessage: String = "Chat message",
audioMessage: String = "Audio message",
videoMessage: String = "Video message",
secureMessagingMessage: String = "Secure messaging message",
messageFont: UIFont = .systemFont(ofSize: 16),
messageColor: UIColor = .black,
unreadMessagesCounterFont: UIFont = .systemFont(ofSize: 16),
unreadMessagesCounterColor: UIColor = .white,
unreadMessagesCounterBackgroundColor: ColorType = .fill(color: .blue),
messageTextStyle: UIFont.TextStyle = .footnote,
iconColor: ColorType = .fill(color: .blue),
backgroundColor: ColorType = .fill(color: .white),
loading: LoadingStyle = .init(loadingTintColor: .fill(color: .gray)),
accessibility: Accessibility = .unsupported
) -> Self {
Self(
chatTitle: chatTitle,
audioTitle: audioTitle,
videoTitle: videoTitle,
secureMessagingTitle: secureMessagingTitle,
titleFont: titleFont,
titleColor: titleColor,
titleTextStyle: titleTextStyle,
chatMessage: chatMessage,
audioMessage: audioMessage,
videoMessage: videoMessage,
secureMessagingMessage: secureMessagingMessage,
messageFont: messageFont,
messageColor: messageColor,
unreadMessagesCounterFont: unreadMessagesCounterFont,
unreadMessagesCounterColor: unreadMessagesCounterColor,
unreadMessagesCounterBackgroundColor: unreadMessagesCounterBackgroundColor,
messageTextStyle: messageTextStyle,
iconColor: iconColor,
backgroundColor: backgroundColor,
loading: loading,
accessibility: accessibility
)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit

extension EntryWidgetStyle {
public struct MediaTypeItemStyle {
public struct MediaTypeItemStyle: Equatable {
/// The title for chat media type.
public var chatTitle: String

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#if DEBUG
import UIKit

extension EntryWidgetStyle.MediaTypeItemsStyle {
static func mock(
mediaItemStyle: EntryWidgetStyle.MediaTypeItemStyle = .mock(),
dividerColor: UIColor = .gray
) -> Self {
Self(
mediaItemStyle: mediaItemStyle,
dividerColor: dividerColor
)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import UIKit

extension EntryWidgetStyle.MediaTypeItemsStyle {
mutating func apply(
configuration: RemoteConfiguration.MediaTypeItems?,
assetBuilder: RemoteConfiguration.AssetsBuilder
) {
mediaItemStyle.apply(configuration: configuration?.mediaTypeItem, assetsBuilder: assetBuilder)

configuration?.dividerColor?.value
.map { UIColor(hex: $0) }
.first
.unwrap { dividerColor = $0 }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import UIKit

extension EntryWidgetStyle {
public struct MediaTypeItemsStyle: Equatable {
/// The style of media type item.
public var mediaItemStyle: EntryWidgetStyle.MediaTypeItemStyle

/// The color of the divider.
public var dividerColor: UIColor

/// - Parameters:
/// - mediaItemStyle: Style of media type item..
/// - dividerColor: Color of the banner divider.
public init(
mediaItemStyle: EntryWidgetStyle.MediaTypeItemStyle,
dividerColor: UIColor
) {
self.mediaItemStyle = mediaItemStyle
self.dividerColor = dividerColor
}
}
}
8 changes: 7 additions & 1 deletion GliaWidgets/Sources/Theme/Theme+Chat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ extension Theme {
iconColor: color.baseLight
)

let secureMessagingExpandedTopBannerItemsStyle = EntryWidgetStyle.MediaTypeItemsStyle(
mediaItemStyle: entryWidgetStyle.mediaTypeItem,
dividerColor: entryWidgetStyle.dividerColor
)

return ChatStyle(
header: header,
connect: connect,
Expand Down Expand Up @@ -498,7 +503,8 @@ extension Theme {
gliaVirtualAssistant: gliaVirtualAssistantStyle,
secureMessagingTopBannerStyle: secureMessagingTopBannerStyle,
secureMessagingBottomBannerStyle: secureMessagingBottomBannerStyle,
sendingMessageUnavailableBannerViewStyle: sendingMessageUnavailableBannerViewStyle
sendingMessageUnavailableBannerViewStyle: sendingMessageUnavailableBannerViewStyle,
secureMessagingExpandedTopBannerItemsStyle: secureMessagingExpandedTopBannerItemsStyle
)
}

Expand Down
6 changes: 4 additions & 2 deletions GliaWidgets/Sources/View/Chat/ChatStyle.Deprecated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ extension ChatStyle {
gliaVirtualAssistant: GliaVirtualAssistantStyle,
secureMessagingTopBannerStyle: SecureMessagingTopBannerViewStyle,
secureMessagingBottomBannerStyle: SecureMessagingBottomBannerViewStyle,
sendingMessageUnavailableBannerViewStyle: SendingMessageUnavailableBannerViewStyle
sendingMessageUnavailableBannerViewStyle: SendingMessageUnavailableBannerViewStyle,
secureMessagingExpandedTopBannerItemsStyle: EntryWidgetStyle.MediaTypeItemsStyle
) {
self.init(
header: header,
Expand All @@ -117,7 +118,8 @@ extension ChatStyle {
gliaVirtualAssistant: gliaVirtualAssistant,
secureMessagingTopBannerStyle: secureMessagingTopBannerStyle,
secureMessagingBottomBannerStyle: secureMessagingBottomBannerStyle,
sendingMessageUnavailableBannerViewStyle: sendingMessageUnavailableBannerViewStyle
sendingMessageUnavailableBannerViewStyle: sendingMessageUnavailableBannerViewStyle,
secureMessagingExpandedTopBannerItemsStyle: secureMessagingExpandedTopBannerItemsStyle
)
}
}
8 changes: 8 additions & 0 deletions GliaWidgets/Sources/View/Chat/ChatStyle.RemoteConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ extension ChatStyle {
configuration: configuration?.gva,
assetBuilder: assetsBuilder
)
secureMessagingTopBannerStyle.apply(
configuration: configuration?.secureMessaging,
assetBuilder: assetsBuilder
)
secureMessagingExpandedTopBannerItemsStyle.apply(
configuration: configuration?.secureMessaging?.mediaTypeItems,
assetBuilder: assetsBuilder
)
secureMessagingBottomBannerStyle.apply(
configuration: configuration?.secureMessaging,
assetBuilder: assetsBuilder
Expand Down
Loading

0 comments on commit 62a2a13

Please sign in to comment.