From 1ea3ecf8bc0f4b07ba8b482fd33a84d1ac3a942e Mon Sep 17 00:00:00 2001 From: Igor Kravchenko Date: Thu, 7 Nov 2024 18:12:26 +0200 Subject: [PATCH] Introduce disabled state for file upload list Since message entry can have disabled state, file upload list, which is a part of message entry, also needs to have disabled state. These changes introduce such state. Styles use same colors for disabled state as for enabled for now, because we do not have a flow for disabled file upload. MOB-3763 --- GliaWidgets.xcodeproj/project.pbxproj | 16 +- .../SecureConversations.TranscriptModel.swift | 7 +- .../SecureConversations.FilePreviewView.swift | 2 +- ...onversations.FileUploadListViewModel.swift | 8 +- .../SecureConversations.FileUploadView.swift | 26 +++- .../Theme+SecureConversationsWelcome.swift | 82 ++++++++-- GliaWidgets/Sources/StatefulStyle.swift | 2 + GliaWidgets/Sources/Theme/Theme+Chat.swift | 80 ++++++++-- ...tyle.EnabledDisabledState.Equatable.swift} | 4 +- .../Entry/Upload/FileUploadStyle.Mock.swift | 31 ++-- .../Upload/FileUploadStyle.RemoteConfig.swift | 19 +-- .../Chat/Entry/Upload/FileUploadStyle.swift | 131 +++++++++------- ...tyle.EnabledDisabledState.Equatable.swift} | 4 +- ...geCenterFileUploadStyle.RemoteConfig.swift | 19 +-- .../Upload/MessageCenterFileUploadStyle.swift | 142 ++++++++++-------- .../ChatTranscript/TranscriptModelTests.swift | 7 +- ...onsWelcomeScreenDynamicTypeFontTests.swift | 46 ++++-- ...onversationsWelcomeScreenLayoutTests.swift | 46 ++++-- ...ersationsWelcomeScreenVoiceOverTests.swift | 46 ++++-- 19 files changed, 484 insertions(+), 234 deletions(-) rename GliaWidgets/Sources/View/Chat/Entry/Upload/{FileUploadStyle.Equatable.swift => FileUploadStyle.EnabledDisabledState.Equatable.swift} (82%) rename GliaWidgets/Sources/View/Chat/Entry/Upload/{MessageCenterFileUploadStyle.Equatable.swift => MessageCenterFileUploadStyle.EnabledDisabledState.Equatable.swift} (79%) diff --git a/GliaWidgets.xcodeproj/project.pbxproj b/GliaWidgets.xcodeproj/project.pbxproj index ef3628933..ee0675ee9 100644 --- a/GliaWidgets.xcodeproj/project.pbxproj +++ b/GliaWidgets.xcodeproj/project.pbxproj @@ -844,8 +844,8 @@ C09047442B7E2016003C437C /* FileUploadStyle.Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09047432B7E2016003C437C /* FileUploadStyle.Mock.swift */; }; C09047462B7E2064003C437C /* FileUploadErrorStateStyle.Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09047452B7E2064003C437C /* FileUploadErrorStateStyle.Mock.swift */; }; C09047482B7E20B0003C437C /* FileUploadStateStyle.Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09047472B7E20B0003C437C /* FileUploadStateStyle.Mock.swift */; }; - C090474A2B7E20E0003C437C /* MessageCenterFileUploadStyle.Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09047492B7E20E0003C437C /* MessageCenterFileUploadStyle.Equatable.swift */; }; - C090474C2B7E210C003C437C /* FileUploadStyle.Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C090474B2B7E210C003C437C /* FileUploadStyle.Equatable.swift */; }; + C090474A2B7E20E0003C437C /* MessageCenterFileUploadStyle.EnabledDisabledState.Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09047492B7E20E0003C437C /* MessageCenterFileUploadStyle.EnabledDisabledState.Equatable.swift */; }; + C090474C2B7E210C003C437C /* FileUploadStyle.EnabledDisabledState.Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C090474B2B7E210C003C437C /* FileUploadStyle.EnabledDisabledState.Equatable.swift */; }; C090474E2B7E2138003C437C /* FileUploadErrorStateStyle.Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C090474D2B7E2138003C437C /* FileUploadErrorStateStyle.Equatable.swift */; }; C09047502B7E215E003C437C /* FileUploadStateStyle.Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C090474F2B7E215E003C437C /* FileUploadStateStyle.Equatable.swift */; }; C09047522B7E21A2003C437C /* MessageCenterFileUploadListStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09047512B7E21A2003C437C /* MessageCenterFileUploadListStyle.swift */; }; @@ -1911,8 +1911,8 @@ C09047432B7E2016003C437C /* FileUploadStyle.Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileUploadStyle.Mock.swift; sourceTree = ""; }; C09047452B7E2064003C437C /* FileUploadErrorStateStyle.Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileUploadErrorStateStyle.Mock.swift; sourceTree = ""; }; C09047472B7E20B0003C437C /* FileUploadStateStyle.Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileUploadStateStyle.Mock.swift; sourceTree = ""; }; - C09047492B7E20E0003C437C /* MessageCenterFileUploadStyle.Equatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageCenterFileUploadStyle.Equatable.swift; sourceTree = ""; }; - C090474B2B7E210C003C437C /* FileUploadStyle.Equatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileUploadStyle.Equatable.swift; sourceTree = ""; }; + C09047492B7E20E0003C437C /* MessageCenterFileUploadStyle.EnabledDisabledState.Equatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageCenterFileUploadStyle.EnabledDisabledState.Equatable.swift; sourceTree = ""; }; + C090474B2B7E210C003C437C /* FileUploadStyle.EnabledDisabledState.Equatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileUploadStyle.EnabledDisabledState.Equatable.swift; sourceTree = ""; }; C090474D2B7E2138003C437C /* FileUploadErrorStateStyle.Equatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileUploadErrorStateStyle.Equatable.swift; sourceTree = ""; }; C090474F2B7E215E003C437C /* FileUploadStateStyle.Equatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileUploadStateStyle.Equatable.swift; sourceTree = ""; }; C09047512B7E21A2003C437C /* MessageCenterFileUploadListStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageCenterFileUploadListStyle.swift; sourceTree = ""; }; @@ -2263,14 +2263,14 @@ C09047392B7E1ECD003C437C /* FileUploadStateStyle.RemoteConfig.swift */, C09047372B7E1EA6003C437C /* FileUploadStateStyle.swift */, 9A186A3427F5CF3C0055886D /* FileUploadStyle.Accessibility.swift */, - C090474B2B7E210C003C437C /* FileUploadStyle.Equatable.swift */, + C090474B2B7E210C003C437C /* FileUploadStyle.EnabledDisabledState.Equatable.swift */, C09047432B7E2016003C437C /* FileUploadStyle.Mock.swift */, C09047352B7E1DEF003C437C /* FileUploadStyle.RemoteConfig.swift */, 1A0EDF5925E786DB0076D1AD /* FileUploadStyle.swift */, C09047552B7E21F0003C437C /* MessageCenterFileUploadListStyle.Equatable.swift */, C09047532B7E21C5003C437C /* MessageCenterFileUploadListStyle.RemoteConfig.swift */, C09047512B7E21A2003C437C /* MessageCenterFileUploadListStyle.swift */, - C09047492B7E20E0003C437C /* MessageCenterFileUploadStyle.Equatable.swift */, + C09047492B7E20E0003C437C /* MessageCenterFileUploadStyle.EnabledDisabledState.Equatable.swift */, C09047412B7E1FDF003C437C /* MessageCenterFileUploadStyle.RemoteConfig.swift */, C090473F2B7E1FBC003C437C /* MessageCenterFileUploadStyle.swift */, ); @@ -5864,7 +5864,7 @@ 3197F7B129E958F4008EE9F7 /* SystemMessageStyle.swift in Sources */, 3100D92C296E946600DEC9CE /* SecureConversations.ConfirmationViewController.swift in Sources */, C0F3DE3B2C6E0DD900DE6D7B /* EntryWidgetView.swift in Sources */, - C090474C2B7E210C003C437C /* FileUploadStyle.Equatable.swift in Sources */, + C090474C2B7E210C003C437C /* FileUploadStyle.EnabledDisabledState.Equatable.swift in Sources */, C09047402B7E1FBC003C437C /* MessageCenterFileUploadStyle.swift in Sources */, 9A8130BB27D7A41000220BBD /* FileUpload.Environment.Interface.swift in Sources */, C09046AB2B7D0967003C437C /* WelcomeStyle.SendButton.DisabledStyle.Accessibility.swift in Sources */, @@ -6395,7 +6395,7 @@ 846A5C3429CB3A130049B29F /* ScreenShareHandler.Implementation.swift in Sources */, AFA2FDEC28907D7C00428E6D /* EngagementCoordinator.Environment.swift in Sources */, C09046B52B7D0A84003C437C /* WelcomeStyle.MessageWarningStyle.Accessibility.swift in Sources */, - C090474A2B7E20E0003C437C /* MessageCenterFileUploadStyle.Equatable.swift in Sources */, + C090474A2B7E20E0003C437C /* MessageCenterFileUploadStyle.EnabledDisabledState.Equatable.swift in Sources */, C0D6C9F72C0D2F6D00D4709B /* AlertPlacement.swift in Sources */, C09046992B7D06D7003C437C /* WelcomeStyle.MessageTextViewNormalStyle.Accessibility.swift in Sources */, C09047642B7E2375003C437C /* ChatFileDownloadStateStyle.RemoteConfig.swift in Sources */, diff --git a/GliaWidgets/SecureConversations/ChatTranscript/SecureConversations.TranscriptModel.swift b/GliaWidgets/SecureConversations/ChatTranscript/SecureConversations.TranscriptModel.swift index 079d23261..34a3b3d3f 100644 --- a/GliaWidgets/SecureConversations/ChatTranscript/SecureConversations.TranscriptModel.swift +++ b/GliaWidgets/SecureConversations/ChatTranscript/SecureConversations.TranscriptModel.swift @@ -141,12 +141,11 @@ extension SecureConversations { case let .success(.available(queueIds)): self.environment.queueIds = queueIds self.isSecureConversationsAvailable = true - case .failure, .success(.unavailable(.emptyQueue)): - self.isSecureConversationsAvailable = false - self.engagementAction?(.showAlert(.unavailableMessageCenter())) - case .success(.unavailable(.unauthenticated)): + self.fileUploadListModel.isEnabled = true + case .failure, .success(.unavailable(.emptyQueue)), .success(.unavailable(.unauthenticated)): // For chat screen we no longer show unavailability dialog, but unavailability banner instead. self.isSecureConversationsAvailable = false + self.fileUploadListModel.isEnabled = false } } } diff --git a/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FilePreviewView.swift b/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FilePreviewView.swift index 45f2b5327..f816f11a2 100644 --- a/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FilePreviewView.swift +++ b/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FilePreviewView.swift @@ -230,5 +230,5 @@ extension SecureConversations.FilePreviewView.Kind { } private extension FilePreviewStyle { - static let initial = FileUploadStyle.initial.filePreview + static let initial = FileUploadStyle.initial.enabled.filePreview } diff --git a/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FileUploadListViewModel.swift b/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FileUploadListViewModel.swift index 55db2bd84..d36b223dc 100644 --- a/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FileUploadListViewModel.swift +++ b/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FileUploadListViewModel.swift @@ -6,6 +6,11 @@ extension SecureConversations { var action: ((Action) -> Void)? var delegate: ((DelegateEvent) -> Void)? + var isEnabled = true { + didSet { + reportChange() + } + } enum Event {} enum Action {} @@ -91,7 +96,8 @@ extension SecureConversations { style: style.item, removeTapped: Cmd { [weak self] in self?.removeUpload(fileUpload) - } + }, + isEnabled: isEnabled ) } ) diff --git a/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FileUploadView.swift b/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FileUploadView.swift index 92f0d55c3..cc9aa6ef2 100644 --- a/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FileUploadView.swift +++ b/GliaWidgets/SecureConversations/FileUploadListView/SecureConversations.FileUploadView.swift @@ -11,6 +11,7 @@ extension SecureConversations { let style: Style let state: State let removeTapped: Cmd + let isEnabled: Bool } static func height(for style: Style) -> CGFloat { @@ -68,7 +69,7 @@ extension SecureConversations { constraints += contentView.heightAnchor.constraint(greaterThanOrEqualToConstant: Self.height(for: props.style)) addSubview(contentView) contentView.translatesAutoresizingMaskIntoConstraints = false - let style = Style.Properties(style: props.style) + let style = Style.Properties(style: props.style, isEnabled: props.isEnabled) constraints += contentView.layoutInSuperview(insets: style.contentInsets) contentView.addSubview(filePreviewView) @@ -124,7 +125,8 @@ extension SecureConversations { func renderProps() { let style = SecureConversations.FileUploadView.Style.Properties( - style: props.style + style: props.style, + isEnabled: props.isEnabled ) progressView.backgroundColor = style.progressBackgroundColor removeButton.tintColor = style.removeButtonColor @@ -148,7 +150,7 @@ extension SecureConversations { private func update(for state: FileUpload.State) { let style = SecureConversations.FileUploadView.Style.Properties( - style: props.style + style: props.style, isEnabled: props.isEnabled ) switch state { case .none: @@ -289,7 +291,8 @@ extension SecureConversations.FileUploadView.Props { init( fileUpload: GliaWidgets.FileUpload, style: SecureConversations.FileUploadView.Style, - removeTapped: Cmd + removeTapped: Cmd, + isEnabled: Bool ) { self.init( id: fileUpload.uuid.uuidString, @@ -298,7 +301,8 @@ extension SecureConversations.FileUploadView.Props { state: fileUpload.state.value, localFile: fileUpload.localFile ), - removeTapped: removeTapped + removeTapped: removeTapped, + isEnabled: isEnabled ) } } @@ -308,6 +312,8 @@ extension FileUploadStyle { } extension SecureConversations.FileUploadView { + typealias EnabledDisabledState = StatefulStyle