From f248bdfd920a0e8d7eb38180f0db7684fa1ee8f7 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Mon, 17 Mar 2025 11:37:50 +0100 Subject: [PATCH] removed images in pills in favour of text decos FIX fix --- ElementX.xcodeproj/project.pbxproj | 52 ++++++-------- .../Sources/Other/MatrixEntityRegex.swift | 2 +- .../Sources/Other/Pills/PillConstants.swift | 21 ------ .../Sources/Other/Pills/PillContext.swift | 18 +---- .../Sources/Other/Pills/PillUtilities.swift | 45 ++++++++++++ ElementX/Sources/Other/Pills/PillView.swift | 72 +++++++++---------- .../CompletionSuggestionService.swift | 2 +- .../CompletionSuggestionServiceProtocol.swift | 6 +- .../ComposerToolbarViewModel.swift | 4 +- .../Screens/Timeline/TimelineViewModel.swift | 50 ++++--------- .../View/Replies/TimelineReplyView.swift | 2 +- NSE/SupportingFiles/target.yml | 2 +- .../pillView.Message-link-iPad-en-GB.png | 4 +- .../pillView.Message-link-iPad-pseudo.png | 4 +- .../pillView.Message-link-iPhone-16-en-GB.png | 4 +- ...pillView.Message-link-iPhone-16-pseudo.png | 4 +- ...sage-link-without-room-name-iPad-en-GB.png | 3 + ...age-link-without-room-name-iPad-pseudo.png | 3 + ...link-without-room-name-iPhone-16-en-GB.png | 3 + ...ink-without-room-name-iPhone-16-pseudo.png | 3 + .../PreviewTests/pillView.Room-iPad-en-GB.png | 4 +- .../pillView.Room-iPad-pseudo.png | 4 +- .../pillView.Room-iPhone-16-en-GB.png | 4 +- .../pillView.Room-iPhone-16-pseudo.png | 4 +- .../pillView.Room-without-name-iPad-en-GB.png | 3 + ...pillView.Room-without-name-iPad-pseudo.png | 3 + ...View.Room-without-name-iPhone-16-en-GB.png | 3 + ...iew.Room-without-name-iPhone-16-pseudo.png | 3 + .../PreviewTests/pillView.User-iPad-en-GB.png | 4 +- .../pillView.User-iPad-pseudo.png | 4 +- .../pillView.User-iPhone-16-en-GB.png | 4 +- .../pillView.User-iPhone-16-pseudo.png | 4 +- ...lView.User-with-a-long-name-iPad-en-GB.png | 4 +- ...View.User-with-a-long-name-iPad-pseudo.png | 4 +- ....User-with-a-long-name-iPhone-16-en-GB.png | 4 +- ...User-with-a-long-name-iPhone-16-pseudo.png | 4 +- ...View.User-with-missing-name-iPad-en-GB.png | 3 + ...iew.User-with-missing-name-iPad-pseudo.png | 3 + ...User-with-missing-name-iPhone-16-en-GB.png | 3 + ...ser-with-missing-name-iPhone-16-pseudo.png | 3 + UnitTests/Sources/PillContextTests.swift | 25 ++----- 41 files changed, 201 insertions(+), 200 deletions(-) delete mode 100644 ElementX/Sources/Other/Pills/PillConstants.swift create mode 100644 ElementX/Sources/Other/Pills/PillUtilities.swift create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPad-en-GB.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPad-pseudo.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPhone-16-en-GB.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPhone-16-pseudo.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPad-en-GB.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPad-pseudo.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPhone-16-en-GB.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPhone-16-pseudo.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPad-en-GB.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPad-pseudo.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPhone-16-en-GB.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPhone-16-pseudo.png diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 0b94ec3bf..a3850cd48 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 54; + objectVersion = 56; objects = { /* Begin PBXAggregateTarget section */ @@ -485,7 +485,7 @@ 6189B4ABD535CE526FA1107B /* StartChatViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DF438EAFC732D2D95D34BF6 /* StartChatViewModelTests.swift */; }; 61941DEE5F3834765770BE01 /* InviteUsersScreenSelectedItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10F32E0B4B83D2A11EE8D011 /* InviteUsersScreenSelectedItem.swift */; }; 61A36B9BB2ADE36CEFF5E98C /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E93A1BE7D8A2EBCAD51EEB4 /* Array.swift */; }; - 62418EA4E3EB597AD184AEB6 /* PillConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB8D34E94AB07128DB73D6C7 /* PillConstants.swift */; }; + 62418EA4E3EB597AD184AEB6 /* PillUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB8D34E94AB07128DB73D6C7 /* PillUtilities.swift */; }; 62684AECDFC5C7DC989CBD9E /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 7B6BC3219ADD8AA0311D2B86 /* SnapshotTesting */; }; 627139A3D79F032BA81E3A53 /* UserSessionFlowCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FA29BAE9B0F2D90E57B261C /* UserSessionFlowCoordinatorTests.swift */; }; 62910B515BCB4B455E24D7C1 /* AdvancedSettingsScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D086854995173E897F993C26 /* AdvancedSettingsScreenViewModelProtocol.swift */; }; @@ -699,7 +699,7 @@ 89198AE2649DD77673D5793B /* ExtensionLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41A8571A8A071FB41778C016 /* ExtensionLogger.swift */; }; 8944548A684F1C837CEC47F4 /* RoomMembersListScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D0946F77B696176E062D037 /* RoomMembersListScreenModels.swift */; }; 89658A44C9FC19B58FD1C226 /* ServerConfirmationScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F08776C48FFB47CACF64ED10 /* ServerConfirmationScreenViewModelTests.swift */; }; - 899359A4D1147601F6C4E364 /* PillConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB8D34E94AB07128DB73D6C7 /* PillConstants.swift */; }; + 899359A4D1147601F6C4E364 /* PillUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB8D34E94AB07128DB73D6C7 /* PillUtilities.swift */; }; 899793EFC63DF93C3E0141E7 /* RoomMemberDetailsScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FA60F848D1C14F873F9621A /* RoomMemberDetailsScreenCoordinator.swift */; }; 89B909AC66B96FA054EF3C14 /* InvitedRoomProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E95B3BDB80531C85CD50AE6 /* InvitedRoomProxy.swift */; }; 89DF67AECBF9D0EE0DDB7737 /* Tracing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83B574805B9812C111D6215D /* Tracing.swift */; }; @@ -1367,7 +1367,7 @@ 044E501B8331B339874D1B96 /* CompoundIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompoundIcon.swift; sourceTree = ""; }; 045253F9967A535EE5B16691 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; 046C0D3F53B0B5EF0A1F5BEA /* RoomSummaryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSummaryTests.swift; sourceTree = ""; }; - 048A21188AB19349D026BECD /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + 048A21188AB19349D026BECD /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 04BB8DDE245ED86C489BA983 /* AccessibilityIdentifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityIdentifiers.swift; sourceTree = ""; }; 04DF593C3F7AF4B2FBAEB05D /* FileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileManager.swift; sourceTree = ""; }; 0516C69708D5CBDE1A8E77EC /* RoomDirectorySearchProxyProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDirectorySearchProxyProtocol.swift; sourceTree = ""; }; @@ -1437,7 +1437,7 @@ 128501375217576AF0FE3E92 /* RoomAttachmentPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomAttachmentPicker.swift; sourceTree = ""; }; 12B09A94C519227264A41208 /* RoomMembershipDetailsProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMembershipDetailsProxy.swift; sourceTree = ""; }; 12FD5280AF55AB7F50F8E47D /* preview_avatar_room.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = preview_avatar_room.jpg; sourceTree = ""; }; - 1304D9191300873EADA52D6E /* IntegrationTests.xctestplan */ = {isa = PBXFileReference; path = IntegrationTests.xctestplan; sourceTree = ""; }; + 1304D9191300873EADA52D6E /* IntegrationTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = IntegrationTests.xctestplan; sourceTree = ""; }; 130ED565A078F7E0B59D9D25 /* UNTextInputNotificationResponse+Creator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UNTextInputNotificationResponse+Creator.swift"; sourceTree = ""; }; 136F80A613B55BDD071DCEA5 /* JoinRoomScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinRoomScreenModels.swift; sourceTree = ""; }; 13802897C7AFA360EA74C0B0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = ""; }; @@ -1541,7 +1541,7 @@ 25F7FE40EF7490A7E09D7BE6 /* NotificationItemProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationItemProxy.swift; sourceTree = ""; }; 25F8664F1FB95AF3C4202478 /* PollFormScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollFormScreenCoordinator.swift; sourceTree = ""; }; 260004737C573A56FA01E86E /* Encodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Encodable.swift; sourceTree = ""; }; - 267BB1D5B08A9511F894CB57 /* PreviewTests.xctestplan */ = {isa = PBXFileReference; path = PreviewTests.xctestplan; sourceTree = ""; }; + 267BB1D5B08A9511F894CB57 /* PreviewTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = PreviewTests.xctestplan; sourceTree = ""; }; 26B0A96B8FE4849227945067 /* VoiceMessageRecorder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceMessageRecorder.swift; sourceTree = ""; }; 26EAAB54C6CE91D64B69A9F8 /* AppLockServiceProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockServiceProtocol.swift; sourceTree = ""; }; 2711E5996016ABD6EAAEB58A /* LogLevel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogLevel.swift; sourceTree = ""; }; @@ -1614,7 +1614,7 @@ 3558A15CFB934F9229301527 /* RestorationToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestorationToken.swift; sourceTree = ""; }; 35AFCF4C05DEED04E3DB1A16 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = ""; }; 35FA991289149D31F4286747 /* UserPreference.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPreference.swift; sourceTree = ""; }; - 36DA824791172B9821EACBED /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + 36DA824791172B9821EACBED /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 36FD673E24FBFCFDF398716A /* RoomMemberProxyMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMemberProxyMock.swift; sourceTree = ""; }; 371B248460BD1A3F20318137 /* TimelineProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineProvider.swift; sourceTree = ""; }; 376D941BF8BB294389C0DE24 /* MapTilerURLBuildersTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapTilerURLBuildersTests.swift; sourceTree = ""; }; @@ -2024,7 +2024,7 @@ 8D55702474F279D910D2D162 /* RoomStateEventStringBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomStateEventStringBuilder.swift; sourceTree = ""; }; 8D8169443E5AC5FF71BFB3DB /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = ""; }; 8DA1E8F287680C8ED25EDBAC /* NetworkMonitorMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkMonitorMock.swift; sourceTree = ""; }; - 8E088F2A1B9EC529D3221931 /* UITests.xctestplan */ = {isa = PBXFileReference; path = UITests.xctestplan; sourceTree = ""; }; + 8E088F2A1B9EC529D3221931 /* UITests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = UITests.xctestplan; sourceTree = ""; }; 8E1584F8BCF407BB94F48F04 /* EncryptionResetPasswordScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionResetPasswordScreen.swift; sourceTree = ""; }; 8EAF4A49F3ACD8BB8B0D2371 /* ClientSDKMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientSDKMock.swift; sourceTree = ""; }; 8F062DD2CCD95DC33528A16F /* KnockRequestProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KnockRequestProxy.swift; sourceTree = ""; }; @@ -2219,7 +2219,7 @@ B53AC78E49A297AC1D72A7CF /* AppMediator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppMediator.swift; sourceTree = ""; }; B590BD4507D4F0A377FDE01A /* LoadableAvatarImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadableAvatarImage.swift; sourceTree = ""; }; B5D829FD8958376614504B18 /* TargetConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TargetConfiguration.swift; sourceTree = ""; }; - B61C339A2FDDBD067FF6635C /* ConfettiScene.scn */ = {isa = PBXFileReference; path = ConfettiScene.scn; sourceTree = ""; }; + B61C339A2FDDBD067FF6635C /* ConfettiScene.scn */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = ConfettiScene.scn; sourceTree = ""; }; B63B69F9A2BC74DD40DC75C8 /* AdvancedSettingsScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedSettingsScreenViewModel.swift; sourceTree = ""; }; B6404166CBF5CC88673FF9E2 /* RoomDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDetails.swift; sourceTree = ""; }; B655A536341D2695158C6664 /* AuthenticationClientBuilderFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationClientBuilderFactory.swift; sourceTree = ""; }; @@ -2246,7 +2246,7 @@ BA40B98B098B6F0371B750B3 /* TemplateScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateScreenModels.swift; sourceTree = ""; }; BA919F521E9F0EE3638AFC85 /* BugReportScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BugReportScreen.swift; sourceTree = ""; }; BB284643AF7AB131E307DCE0 /* AudioSessionProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioSessionProtocol.swift; sourceTree = ""; }; - BB576F4118C35E6B5124FA22 /* test_apple_image.heic */ = {isa = PBXFileReference; path = test_apple_image.heic; sourceTree = ""; }; + BB576F4118C35E6B5124FA22 /* test_apple_image.heic */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_apple_image.heic; sourceTree = ""; }; BB5B00A014307CE37B2812CD /* TimelineViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineViewModelProtocol.swift; sourceTree = ""; }; BB8BC4C791D0E88CFCF4E5DF /* ServerSelectionScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSelectionScreenCoordinator.swift; sourceTree = ""; }; BBEC57C204D77908E355EF42 /* AudioRecorderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRecorderProtocol.swift; sourceTree = ""; }; @@ -2328,7 +2328,7 @@ CA90BD288E5AE6BC643AFDDF /* TemplateScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateScreenCoordinator.swift; sourceTree = ""; }; CACA846B3E3E9A521D98B178 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; CAD9547E47C58930E2CE8306 /* CallScreenViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallScreenViewModelTests.swift; sourceTree = ""; }; - CB8D34E94AB07128DB73D6C7 /* PillConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PillConstants.swift; sourceTree = ""; }; + CB8D34E94AB07128DB73D6C7 /* PillUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PillUtilities.swift; sourceTree = ""; }; CBBCC6E74774E79B599625D0 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; CBF9AEA706926DD0DA2B954C /* JoinedRoomSize+MemberCount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "JoinedRoomSize+MemberCount.swift"; sourceTree = ""; }; CC03209FDE8CE0810617BFFF /* RoomMembersListScreenMemberCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMembersListScreenMemberCell.swift; sourceTree = ""; }; @@ -2342,7 +2342,7 @@ CDB3227C7A74B734924942E9 /* RoomSummaryProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSummaryProvider.swift; sourceTree = ""; }; CDE3F3911FF7CC639BDE5844 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = ""; }; CEE20623EB4A9B88FB29F2BA /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/SAS.strings; sourceTree = ""; }; - CEE41494C837AA403A06A5D9 /* UnitTests.xctestplan */ = {isa = PBXFileReference; path = UnitTests.xctestplan; sourceTree = ""; }; + CEE41494C837AA403A06A5D9 /* UnitTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = UnitTests.xctestplan; sourceTree = ""; }; D01FD1171FF40E34D707FD00 /* BigIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BigIcon.swift; sourceTree = ""; }; D046ABB22E680F7C5054441B /* SecurityAndPrivacyScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityAndPrivacyScreenViewModelProtocol.swift; sourceTree = ""; }; D071F86CD47582B9196C9D16 /* UserDiscoverySection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDiscoverySection.swift; sourceTree = ""; }; @@ -2401,7 +2401,7 @@ DC0AEA686E425F86F6BA0404 /* UNNotification+Creator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UNNotification+Creator.swift"; sourceTree = ""; }; DC10CCC8D68B863E20660DBC /* MessageForwardingScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageForwardingScreenViewModelProtocol.swift; sourceTree = ""; }; DC528B3764E3CF7FCFEF40E7 /* PollInteractionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollInteractionHandler.swift; sourceTree = ""; }; - DCA2D836BD10303F37FAAEED /* test_voice_message.m4a */ = {isa = PBXFileReference; path = test_voice_message.m4a; sourceTree = ""; }; + DCA2D836BD10303F37FAAEED /* test_voice_message.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_voice_message.m4a; sourceTree = ""; }; DCAC01A97A43BE07B9E94E43 /* ShareExtensionModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareExtensionModels.swift; sourceTree = ""; }; DCDAB580109C09A6AA97AF7E /* PollFormScreenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollFormScreenTests.swift; sourceTree = ""; }; DCF239C619971FDE48132550 /* SecureBackupLogoutConfirmationScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureBackupLogoutConfirmationScreenModels.swift; sourceTree = ""; }; @@ -2444,7 +2444,7 @@ E5272BC4A60B6AD7553BACA1 /* BlurHashDecode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurHashDecode.swift; sourceTree = ""; }; E53BFB7E4F329621C844E8C3 /* AnalyticsPromptScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsPromptScreen.swift; sourceTree = ""; }; E55B5EA766E89FF1F87C3ACB /* RoomNotificationSettingsProxyProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomNotificationSettingsProxyProtocol.swift; sourceTree = ""; }; - E5E7D4EE7CA295E5039FDA21 /* portrait_test_video.mp4 */ = {isa = PBXFileReference; path = portrait_test_video.mp4; sourceTree = ""; }; + E5E7D4EE7CA295E5039FDA21 /* portrait_test_video.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = portrait_test_video.mp4; sourceTree = ""; }; E5E94DCFEE803E5ABAE8ACCE /* KeychainControllerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainControllerProtocol.swift; sourceTree = ""; }; E5F2B6443D1ED8602F328539 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = ru; path = ru.lproj/Localizable.stringsdict; sourceTree = ""; }; E5FDFAA04174CC99FB66391C /* EditRoomAddressScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditRoomAddressScreenViewModel.swift; sourceTree = ""; }; @@ -2486,7 +2486,7 @@ ED0CBEAB5F796BEFBAF7BB6A /* VideoRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoRoomTimelineView.swift; sourceTree = ""; }; ED1D792EB82506A19A72C8DE /* RoomTimelineItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomTimelineItemProtocol.swift; sourceTree = ""; }; ED33988DA4FD4FC666800106 /* SessionVerificationScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionVerificationScreenViewModel.swift; sourceTree = ""; }; - ED482057AE39D5C6D9C5F3D8 /* message.caf */ = {isa = PBXFileReference; path = message.caf; sourceTree = ""; }; + ED482057AE39D5C6D9C5F3D8 /* message.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = message.caf; sourceTree = ""; }; ED49073BB1C1FC649DAC2CCD /* LocationRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationRoomTimelineView.swift; sourceTree = ""; }; ED60E4D2CD678E1EBF16F77A /* BlockedUsersScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockedUsersScreen.swift; sourceTree = ""; }; EE378083653EF0C9B5E9D580 /* EmoteRoomTimelineItemContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmoteRoomTimelineItemContent.swift; sourceTree = ""; }; @@ -4917,7 +4917,7 @@ 15748C254911E3654C93B0ED /* MentionBuilder.swift */, E1E0B4A34E69BD2132BEC521 /* MessageText.swift */, 1B53D6C5C0D14B04D3AB3F6E /* PillAttachmentViewProvider.swift */, - CB8D34E94AB07128DB73D6C7 /* PillConstants.swift */, + CB8D34E94AB07128DB73D6C7 /* PillUtilities.swift */, 86376BEE425704AEE197CA54 /* PillContext.swift */, 9CF1EE0AA78470C674554262 /* PillTextAttachment.swift */, 913C8E13B8B602C7B6C0C4AE /* PillTextAttachmentData.swift */, @@ -6628,7 +6628,7 @@ 5D70FAE4D2BF4553AFFFFE41 /* NotificationItemProxy.swift in Sources */, B89990DD875B0B603D4D4332 /* NotificationItemProxyProtocol.swift in Sources */, B14BC354E56616B6B7D9A3D7 /* NotificationServiceExtension.swift in Sources */, - 62418EA4E3EB597AD184AEB6 /* PillConstants.swift in Sources */, + 62418EA4E3EB597AD184AEB6 /* PillUtilities.swift in Sources */, 55CDD3968D95D1A820B5491E /* PlaceholderAvatarImage.swift in Sources */, F12F6BED7B6D7EE4BEE55039 /* PlainMentionBuilder.swift in Sources */, 76C874243A8C440D6CF7B344 /* ProcessInfo.swift in Sources */, @@ -7286,7 +7286,7 @@ 2D38D39B1789B91AE69F477F /* PhotoLibraryManagerMock.swift in Sources */, 962A4F8AD6312804E2C6BB6E /* PhotoLibraryPicker.swift in Sources */, EE4E2C1922BBF5169E213555 /* PillAttachmentViewProvider.swift in Sources */, - 899359A4D1147601F6C4E364 /* PillConstants.swift in Sources */, + 899359A4D1147601F6C4E364 /* PillUtilities.swift in Sources */, 767D366C40F1311CFA333763 /* PillContext.swift in Sources */, 7708976CEE6AFB5CFAEFBA68 /* PillTextAttachment.swift in Sources */, 8C050A8012E6078BEAEF5BC8 /* PillTextAttachmentData.swift in Sources */, @@ -7971,9 +7971,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = ( - "-DIS_NSE", - ); + OTHER_SWIFT_FLAGS = "-DIS_NSE"; PRODUCT_BUNDLE_IDENTIFIER = "${BASE_BUNDLE_IDENTIFIER}.nse"; PRODUCT_DISPLAY_NAME = "$(APP_DISPLAY_NAME)"; PRODUCT_NAME = NSE; @@ -8022,9 +8020,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = ( - "-DIS_MAIN_APP", - ); + OTHER_SWIFT_FLAGS = "-DIS_MAIN_APP"; PILLS_UT_TYPE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER).pills"; PRODUCT_BUNDLE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = "$(APP_NAME)"; @@ -8050,9 +8046,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = ( - "-DIS_MAIN_APP", - ); + OTHER_SWIFT_FLAGS = "-DIS_MAIN_APP"; PILLS_UT_TYPE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER).pills"; PRODUCT_BUNDLE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = "$(APP_NAME)"; @@ -8316,9 +8310,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = ( - "-DIS_NSE", - ); + OTHER_SWIFT_FLAGS = "-DIS_NSE"; PRODUCT_BUNDLE_IDENTIFIER = "${BASE_BUNDLE_IDENTIFIER}.nse"; PRODUCT_DISPLAY_NAME = "$(APP_DISPLAY_NAME)"; PRODUCT_NAME = NSE; diff --git a/ElementX/Sources/Other/MatrixEntityRegex.swift b/ElementX/Sources/Other/MatrixEntityRegex.swift index 5dd772953..4b52d9ad6 100644 --- a/ElementX/Sources/Other/MatrixEntityRegex.swift +++ b/ElementX/Sources/Other/MatrixEntityRegex.swift @@ -27,7 +27,7 @@ enum MatrixEntityRegex: String { case .uri: return "matrix:(r|u|roomid)\\/[A-Z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=%]*(?:\\?[A-Z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=%]*)?" case .allUsers: - return PillConstants.atRoom + return PillUtilities.atRoom } } diff --git a/ElementX/Sources/Other/Pills/PillConstants.swift b/ElementX/Sources/Other/Pills/PillConstants.swift deleted file mode 100644 index ad46eddc2..000000000 --- a/ElementX/Sources/Other/Pills/PillConstants.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright 2023, 2024 New Vector Ltd. -// -// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial -// Please see LICENSE files in the repository root for full details. -// - -import Foundation - -enum PillConstants { - static let atRoom = "@room" - static var everyone: String { - L10n.commonEveryone - } - - /// Used by the WYSIWYG as the urlString value to identify @room mentions - static let composerAtRoomURLString = "#" - - /// Used only to mock the max width in previews since the real max width is calculated by the line fragment width - static let mockMaxWidth: CGFloat = 235 -} diff --git a/ElementX/Sources/Other/Pills/PillContext.swift b/ElementX/Sources/Other/Pills/PillContext.swift index 135657126..795bd1192 100644 --- a/ElementX/Sources/Other/Pills/PillContext.swift +++ b/ElementX/Sources/Other/Pills/PillContext.swift @@ -39,13 +39,8 @@ extension PillContext { } enum PillViewState: Equatable { - enum PillImage: Equatable { - case link - case roomAvatar(RoomAvatar) - } - case mention(isOwnMention: Bool, displayText: String) - case reference(avatar: PillImage, displayText: String) + case reference(displayText: String) case undefined var isOwnMention: Bool { @@ -59,7 +54,7 @@ enum PillViewState: Equatable { var displayText: String { switch self { - case .mention(_, let displayText), .reference(_, let displayText): + case .mention(_, let displayText), .reference(let displayText): return displayText case .undefined: return "" @@ -74,13 +69,4 @@ enum PillViewState: Equatable { return false } } - - var image: PillImage? { - switch self { - case .reference(let avatar, _): - return avatar - default: - return nil - } - } } diff --git a/ElementX/Sources/Other/Pills/PillUtilities.swift b/ElementX/Sources/Other/Pills/PillUtilities.swift new file mode 100644 index 000000000..8d92ee6dc --- /dev/null +++ b/ElementX/Sources/Other/Pills/PillUtilities.swift @@ -0,0 +1,45 @@ +// +// Copyright 2023, 2024 New Vector Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +// Please see LICENSE files in the repository root for full details. +// + +import Foundation + +enum PillUtilities { + static let atRoom = "@room" + static var everyone: String { + L10n.commonEveryone + } + + /// Used by the WYSIWYG as the urlString value to identify @room mentions + static let composerAtRoomURLString = "#" + + /// Used only to mock the max width in previews since the real max width is calculated by the line fragment width + static let mockMaxWidth: CGFloat = 235 + + private static let roomDecoration = "#" + static func roomPillDisplayText(roomName: String?, rawRoomText: String) -> String { + guard let roomName else { + return rawRoomText + } + return "\(roomDecoration)\(roomName)" + } + + private static let eventDecoration = "💬 > " + static func eventPillDisplayText(roomName: String?, rawRoomText: String) -> String { + guard let roomName else { + return "\(eventDecoration)\(rawRoomText)" + } + return "\(eventDecoration)\(roomDecoration)\(roomName)" + } + + private static let userDecoration = "@" + static func userPillDisplayText(username: String?, userID: String) -> String { + guard let username else { + return userID + } + return "\(userDecoration)\(username)" + } +} diff --git a/ElementX/Sources/Other/Pills/PillView.swift b/ElementX/Sources/Other/Pills/PillView.swift index 8e1093b5a..16cdeecce 100644 --- a/ElementX/Sources/Other/Pills/PillView.swift +++ b/ElementX/Sources/Other/Pills/PillView.swift @@ -31,33 +31,14 @@ struct PillView: View { @ViewBuilder private var mainContent: some View { - HStack(spacing: 4) { - image - Text(context.viewState.displayText) - .font(.compound.bodyLGSemibold) - .foregroundColor(textColor) - .lineLimit(1) - } - .padding(.leading, 4) - .padding(.trailing, 6) - .padding(.vertical, 1) - .background { Capsule().foregroundColor(backgroundColor) } - } - - @ViewBuilder - private var image: some View { - if let image = context.viewState.image { - switch image { - case .link: - CompoundIcon(\.link, size: .custom(12), relativeTo: .compound.bodyLGSemibold) - .padding(2) - .foregroundStyle(.compound.bgCanvasDefault) - .background(.compound.textLinkExternal) - .clipShape(Circle()) - case .roomAvatar(let avatar): - RoomAvatarImage(avatar: avatar, avatarSize: .custom(16), mediaProvider: mediaProvider) - } - } + Text(context.viewState.displayText) + .font(.compound.bodyLGSemibold) + .foregroundColor(textColor) + .lineLimit(1) + .padding(.leading, 4) + .padding(.trailing, 6) + .padding(.vertical, 1) + .background { Capsule().foregroundColor(backgroundColor) } } } @@ -67,26 +48,43 @@ struct PillView_Previews: PreviewProvider, TestablePreview { static var previews: some View { PillView(mediaProvider: mockMediaProvider, context: PillContext.mock(viewState: .mention(isOwnMention: false, - displayText: "@Alice"))) { } - .frame(maxWidth: PillConstants.mockMaxWidth) + displayText: PillUtilities.userPillDisplayText(username: "User", + userID: "@alice:matrix.org")))) { } + .frame(maxWidth: PillUtilities.mockMaxWidth) .previewDisplayName("User") PillView(mediaProvider: mockMediaProvider, context: PillContext.mock(viewState: .mention(isOwnMention: false, - displayText: "@Alice but with a very very long name"))) { } - .frame(maxWidth: PillConstants.mockMaxWidth) + displayText: PillUtilities.userPillDisplayText(username: "Alice but with a very long name", + userID: "@alice:matrix.org")))) { } + .frame(maxWidth: PillUtilities.mockMaxWidth) .previewDisplayName("User with a long name") + PillView(mediaProvider: mockMediaProvider, + context: PillContext.mock(viewState: .mention(isOwnMention: false, + displayText: PillUtilities.userPillDisplayText(username: nil, userID: "@alice:matrix.org")))) { } + .frame(maxWidth: PillUtilities.mockMaxWidth) + .previewDisplayName("User with missing name") PillView(mediaProvider: mockMediaProvider, context: PillContext.mock(viewState: .mention(isOwnMention: true, - displayText: "@Alice"))) { } - .frame(maxWidth: PillConstants.mockMaxWidth) + displayText: PillUtilities.userPillDisplayText(username: "Alice", userID: "@alice:matrix.org")))) { } + .frame(maxWidth: PillUtilities.mockMaxWidth) .previewDisplayName("Own user") PillView(mediaProvider: mockMediaProvider, - context: PillContext.mock(viewState: .reference(avatar: .roomAvatar(.room(id: "roomID", name: "Room", avatarURL: nil)), displayText: "Room"))) { } - .frame(maxWidth: PillConstants.mockMaxWidth) + context: PillContext.mock(viewState: .reference(displayText: PillUtilities.roomPillDisplayText(roomName: "Room", + rawRoomText: "#room:matrix.org")))) { } + .frame(maxWidth: PillUtilities.mockMaxWidth) .previewDisplayName("Room") PillView(mediaProvider: mockMediaProvider, - context: PillContext.mock(viewState: .reference(avatar: .link, displayText: L10n.screenRoomEventPill("Room")))) { } - .frame(maxWidth: PillConstants.mockMaxWidth) + context: PillContext.mock(viewState: .reference(displayText: PillUtilities.roomPillDisplayText(roomName: nil, + rawRoomText: "#room:matrix.org")))) { } + .frame(maxWidth: PillUtilities.mockMaxWidth) + .previewDisplayName("Room without name") + PillView(mediaProvider: mockMediaProvider, + context: PillContext.mock(viewState: .reference(displayText: PillUtilities.eventPillDisplayText(roomName: "Room", rawRoomText: "#room:matrix.org")))) { } + .frame(maxWidth: PillUtilities.mockMaxWidth) .previewDisplayName("Message link") + PillView(mediaProvider: mockMediaProvider, + context: PillContext.mock(viewState: .reference(displayText: PillUtilities.eventPillDisplayText(roomName: nil, rawRoomText: "#room:matrix.org")))) { } + .frame(maxWidth: PillUtilities.mockMaxWidth) + .previewDisplayName("Message link without room name") } } diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionService.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionService.swift index 0026819d5..ee29ea029 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionService.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionService.swift @@ -81,7 +81,7 @@ final class CompletionSuggestionService: CompletionSuggestionServiceProtocol { if canMentionAllUsers, !roomProxy.isDirectOneToOneRoom, - Self.shouldIncludeMember(userID: PillConstants.atRoom, displayName: PillConstants.everyone, searchText: suggestionTrigger.text) { + Self.shouldIncludeMember(userID: PillUtilities.atRoom, displayName: PillUtilities.everyone, searchText: suggestionTrigger.text) { membersSuggestion .insert(SuggestionItem(suggestionType: .allUsers(roomProxy.details.avatar), range: suggestionTrigger.range, rawSuggestionText: suggestionTrigger.text), at: 0) } diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionServiceProtocol.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionServiceProtocol.swift index 76d066bf0..dc902483f 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionServiceProtocol.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionServiceProtocol.swift @@ -49,7 +49,7 @@ struct SuggestionItem: Identifiable, Equatable { case .user(let user): user.id case .allUsers: - PillConstants.atRoom + PillUtilities.atRoom case .room(let room): room.id } @@ -58,7 +58,7 @@ struct SuggestionItem: Identifiable, Equatable { var displayName: String { switch suggestionType { case .allUsers: - return PillConstants.everyone + return PillUtilities.everyone case .user(let user): return user.displayName ?? user.id case .room(let room): @@ -69,7 +69,7 @@ struct SuggestionItem: Identifiable, Equatable { var subtitle: String? { switch suggestionType { case .allUsers: - return PillConstants.atRoom + return PillUtilities.atRoom case .user(let user): return user.displayName == nil ? nil : user.id case .room(let room): diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift index 0dff14972..baf6aee3f 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift @@ -413,7 +413,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool // Remove the attribute so it doesn't get inherited by the new string attributedString.removeAttribute(.MatrixAllUsersMention, range: range) - attributedString.replaceCharacters(in: range, with: PillConstants.atRoom) + attributedString.replaceCharacters(in: range, with: PillUtilities.atRoom) containsAtRoom = true stop.pointee = true @@ -464,7 +464,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool let attributedString: NSMutableAttributedString // This is the all room mention special case - if urlString == PillConstants.composerAtRoomURLString { + if urlString == PillUtilities.composerAtRoomURLString { attributedString = NSMutableAttributedString(string: string, attributes: [.MatrixAllUsersMention: true]) } else { attributedString = NSMutableAttributedString(string: string, attributes: [.link: URL(string: urlString) as Any]) diff --git a/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift b/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift index fb833e11d..b8f58a3f1 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift @@ -841,11 +841,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { case let .user(id): let isOwnMention = id == state.ownUserID if let profile = state.members[id] { - var name = id - if let displayName = profile.displayName { - name = "@\(displayName)" - } - pillContext.viewState = .mention(isOwnMention: isOwnMention, displayText: name) + pillContext.viewState = .mention(isOwnMention: isOwnMention, displayText: PillUtilities.userPillDisplayText(username: profile.displayName, userID: id)) } else { pillContext.viewState = .mention(isOwnMention: isOwnMention, displayText: id) pillContext.cancellable = context.$viewState @@ -854,49 +850,29 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { guard let pillContext else { return } - - var name = id - if let displayName = profile.displayName { - name = "@\(displayName)" - } - pillContext.viewState = .mention(isOwnMention: isOwnMention, displayText: name) + pillContext.viewState = .mention(isOwnMention: isOwnMention, displayText: PillUtilities.userPillDisplayText(username: profile.displayName, userID: id)) pillContext.cancellable = nil } } case .allUsers: - pillContext.viewState = .mention(isOwnMention: true, displayText: PillConstants.atRoom) + pillContext.viewState = .mention(isOwnMention: true, displayText: PillUtilities.atRoom) case .event(let room): - var pillViewState: PillViewState = .reference(avatar: .link, displayText: L10n.screenRoomEventPill(L10n.commonRoom)) - defer { - pillContext.viewState = pillViewState - } - + let pillViewState: PillViewState switch room { case .roomAlias(let alias): - guard let roomSummary = clientProxy.roomSummaryForAlias(alias) else { - return - } - // We always show the link image for event permalinks - pillViewState = .reference(avatar: .link, displayText: L10n.screenRoomEventPill(roomSummary.name)) + let roomSummary = clientProxy.roomSummaryForAlias(alias) + pillViewState = .reference(displayText: PillUtilities.eventPillDisplayText(roomName: roomSummary?.name, rawRoomText: alias)) case .roomID(let id): - guard let roomSummary = clientProxy.roomSummaryForIdentifier(id) else { - return - } - // We always show the link image for event permalinks - pillViewState = .reference(avatar: .link, displayText: L10n.screenRoomEventPill(roomSummary.name)) + let roomSummary = clientProxy.roomSummaryForIdentifier(id) + pillViewState = .reference(displayText: PillUtilities.eventPillDisplayText(roomName: roomSummary?.name, rawRoomText: id)) } + pillContext.viewState = pillViewState case .roomAlias(let alias): - guard let roomSummary = clientProxy.roomSummaryForAlias(alias) else { - pillContext.viewState = .reference(avatar: .link, displayText: alias) - return - } - pillContext.viewState = .reference(avatar: .roomAvatar(roomSummary.avatar), displayText: roomSummary.name) + let roomSummary = clientProxy.roomSummaryForAlias(alias) + pillContext.viewState = .reference(displayText: PillUtilities.roomPillDisplayText(roomName: roomSummary?.name, rawRoomText: alias)) case .roomID(let id): - guard let roomSummary = clientProxy.roomSummaryForIdentifier(id) else { - pillContext.viewState = .reference(avatar: .link, displayText: id) - return - } - pillContext.viewState = .reference(avatar: .roomAvatar(roomSummary.avatar), displayText: roomSummary.name) + let roomSummary = clientProxy.roomSummaryForIdentifier(id) + pillContext.viewState = .reference(displayText: PillUtilities.roomPillDisplayText(roomName: roomSummary?.name, rawRoomText: id)) } } diff --git a/ElementX/Sources/Screens/Timeline/View/Replies/TimelineReplyView.swift b/ElementX/Sources/Screens/Timeline/View/Replies/TimelineReplyView.swift index 9af9b1c1d..72604cf30 100644 --- a/ElementX/Sources/Screens/Timeline/View/Replies/TimelineReplyView.swift +++ b/ElementX/Sources/Screens/Timeline/View/Replies/TimelineReplyView.swift @@ -198,7 +198,7 @@ struct TimelineReplyView: View { } if attributes[.MatrixAllUsersMention] as? Bool == true { - attributedString.replaceCharacters(in: range, with: PillConstants.atRoom) + attributedString.replaceCharacters(in: range, with: PillUtilities.atRoom) } } return attributedString.string diff --git a/NSE/SupportingFiles/target.yml b/NSE/SupportingFiles/target.yml index e9120e804..684c33e33 100644 --- a/NSE/SupportingFiles/target.yml +++ b/NSE/SupportingFiles/target.yml @@ -107,7 +107,7 @@ targets: - path: ../../ElementX/Sources/Other/Logging - path: ../../ElementX/Sources/Other/MatrixEntityRegex.swift - path: ../../ElementX/Sources/Other/NetworkMonitor - - path: ../../ElementX/Sources/Other/Pills/PillConstants.swift + - path: ../../ElementX/Sources/Other/Pills/PillUtilities.swift - path: ../../ElementX/Sources/Other/Pills/PlainMentionBuilder.swift - path: ../../ElementX/Sources/Other/SwiftUI/Views/PlaceholderAvatarImage.swift - path: ../../ElementX/Sources/Other/TestablePreview.swift diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPad-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPad-en-GB.png index 5005627b5..662bc38d4 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPad-en-GB.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPad-en-GB.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:445cdca5bd4aac1963fbfc13b34b0b1bcf9490c4cc2458d10a23708a45131275 -size 73585 +oid sha256:9a69dc4da7c7cfa9a9e02276b9d3ae3086b80dae50bd734aa15286c24031acf4 +size 73475 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPad-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPad-pseudo.png index a40394fe0..662bc38d4 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPad-pseudo.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPad-pseudo.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:47f766c176bdc15ee93e8ff147e38493c21596ea74797072997f0e01812029ea -size 74756 +oid sha256:9a69dc4da7c7cfa9a9e02276b9d3ae3086b80dae50bd734aa15286c24031acf4 +size 73475 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPhone-16-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPhone-16-en-GB.png index d6caf5b66..d4b78d7e7 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPhone-16-en-GB.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPhone-16-en-GB.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:99c7ec98f20b165e79f62ccb7610b4028f14bc33eceb0b88a85330bd060db4cc -size 33380 +oid sha256:1917fe439a153d7de4e8a24d9367b9dc68be902c87ee157bd6ec0ec9aee7d8cf +size 32599 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPhone-16-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPhone-16-pseudo.png index 66cfa9966..d4b78d7e7 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPhone-16-pseudo.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-iPhone-16-pseudo.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3bbc20d9bd83e4ecc033fd11cced6bcc5b457ec9a63683b3f72ba85a877fc020 -size 34866 +oid sha256:1917fe439a153d7de4e8a24d9367b9dc68be902c87ee157bd6ec0ec9aee7d8cf +size 32599 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPad-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPad-en-GB.png new file mode 100644 index 000000000..f8610babe --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPad-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42458395202c8c27d51f04d04fea568b3bd4810cfb591f960fe2cef0faa3b3d2 +size 75236 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPad-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPad-pseudo.png new file mode 100644 index 000000000..f8610babe --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPad-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42458395202c8c27d51f04d04fea568b3bd4810cfb591f960fe2cef0faa3b3d2 +size 75236 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPhone-16-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPhone-16-en-GB.png new file mode 100644 index 000000000..e559af09c --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPhone-16-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de9203b51ed448c790df06d658a09ca7e582bd87b8beb6138b9ab427ee4b4bc4 +size 34921 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPhone-16-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPhone-16-pseudo.png new file mode 100644 index 000000000..e559af09c --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Message-link-without-room-name-iPhone-16-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de9203b51ed448c790df06d658a09ca7e582bd87b8beb6138b9ab427ee4b4bc4 +size 34921 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPad-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPad-en-GB.png index 0e072fb2f..9297fa585 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPad-en-GB.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPad-en-GB.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3866839ecf0aab97249e8bb9af2a65e621afab2b249e71794e4146c2f5d920c8 -size 69868 +oid sha256:5e8cfd15d81ecfd4966947582f869c4357cef4e54bd8646fc078e2a79b5fe0d3 +size 69712 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPad-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPad-pseudo.png index 0e072fb2f..9297fa585 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPad-pseudo.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPad-pseudo.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3866839ecf0aab97249e8bb9af2a65e621afab2b249e71794e4146c2f5d920c8 -size 69868 +oid sha256:5e8cfd15d81ecfd4966947582f869c4357cef4e54bd8646fc078e2a79b5fe0d3 +size 69712 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPhone-16-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPhone-16-en-GB.png index fb7435f13..8118225ce 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPhone-16-en-GB.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPhone-16-en-GB.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e5917c9d41ef154277d1b79ddb3d8a875bdf36c020fd53166a286908e0fdf3fa -size 29609 +oid sha256:d2199497caedf0c974a93d04445feb6fc11ca35d9f895d6257fd9c3cebc79a5d +size 29379 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPhone-16-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPhone-16-pseudo.png index fb7435f13..8118225ce 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPhone-16-pseudo.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-iPhone-16-pseudo.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e5917c9d41ef154277d1b79ddb3d8a875bdf36c020fd53166a286908e0fdf3fa -size 29609 +oid sha256:d2199497caedf0c974a93d04445feb6fc11ca35d9f895d6257fd9c3cebc79a5d +size 29379 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPad-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPad-en-GB.png new file mode 100644 index 000000000..3f68ace9f --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPad-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eadb984285c3bb9a815f0fd7839d69b7af7968702f747b3a2ccc32f3a7091a52 +size 72100 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPad-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPad-pseudo.png new file mode 100644 index 000000000..3f68ace9f --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPad-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eadb984285c3bb9a815f0fd7839d69b7af7968702f747b3a2ccc32f3a7091a52 +size 72100 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPhone-16-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPhone-16-en-GB.png new file mode 100644 index 000000000..440975523 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPhone-16-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:beec1ef8f73c62c3a120a30496ef625a42cb75382f21246df9eedb56c1c1ba35 +size 31637 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPhone-16-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPhone-16-pseudo.png new file mode 100644 index 000000000..440975523 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.Room-without-name-iPhone-16-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:beec1ef8f73c62c3a120a30496ef625a42cb75382f21246df9eedb56c1c1ba35 +size 31637 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPad-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPad-en-GB.png index 07cc0c4df..c08191c7c 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPad-en-GB.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPad-en-GB.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1b95c2fb2064fcf29b6e618b8b314c574b8868078b600d1b2ca4d8b81a1771c6 -size 69625 +oid sha256:1bb9ebd37827a5e9e3a18031e5d0a99215fecc2ba8bf7c91be8534aaf89224b5 +size 70033 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPad-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPad-pseudo.png index 07cc0c4df..c08191c7c 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPad-pseudo.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPad-pseudo.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1b95c2fb2064fcf29b6e618b8b314c574b8868078b600d1b2ca4d8b81a1771c6 -size 69625 +oid sha256:1bb9ebd37827a5e9e3a18031e5d0a99215fecc2ba8bf7c91be8534aaf89224b5 +size 70033 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPhone-16-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPhone-16-en-GB.png index 95d99d1db..aa593da96 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPhone-16-en-GB.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPhone-16-en-GB.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5a0d7e0566bfc51fdbeae5f6f6e19120a5d57b333f23c0a96a3d66958ed13330 -size 30143 +oid sha256:09ee682cd01ba1e3cafaf4f36048e03d4904ae8891d7497d5588244a745b2bee +size 29996 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPhone-16-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPhone-16-pseudo.png index 95d99d1db..aa593da96 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPhone-16-pseudo.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-iPhone-16-pseudo.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5a0d7e0566bfc51fdbeae5f6f6e19120a5d57b333f23c0a96a3d66958ed13330 -size 30143 +oid sha256:09ee682cd01ba1e3cafaf4f36048e03d4904ae8891d7497d5588244a745b2bee +size 29996 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPad-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPad-en-GB.png index 9a6d427bb..ede9ff915 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPad-en-GB.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPad-en-GB.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fcc37d47cfc3f0b4b9fb715c6d7f01ef9971f822b9c476f131a5dd1a3214b635 -size 74787 +oid sha256:78398670d2fe623f5615f8f47b1ca03a9448cbc7bf0db7d20e760ba03e5d3b32 +size 75290 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPad-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPad-pseudo.png index 9a6d427bb..ede9ff915 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPad-pseudo.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPad-pseudo.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fcc37d47cfc3f0b4b9fb715c6d7f01ef9971f822b9c476f131a5dd1a3214b635 -size 74787 +oid sha256:78398670d2fe623f5615f8f47b1ca03a9448cbc7bf0db7d20e760ba03e5d3b32 +size 75290 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPhone-16-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPhone-16-en-GB.png index 2920991ea..4bd046758 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPhone-16-en-GB.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPhone-16-en-GB.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2f38c8984a2f15bb1785edd0b3d508796a91b668f48503bb31b1f71863b6b9ad -size 34390 +oid sha256:7d1b3f189a14f7f57a5a75abcdf8fe4302775704ce3078cfb33e48c1167075e6 +size 34893 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPhone-16-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPhone-16-pseudo.png index 2920991ea..4bd046758 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPhone-16-pseudo.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-a-long-name-iPhone-16-pseudo.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2f38c8984a2f15bb1785edd0b3d508796a91b668f48503bb31b1f71863b6b9ad -size 34390 +oid sha256:7d1b3f189a14f7f57a5a75abcdf8fe4302775704ce3078cfb33e48c1167075e6 +size 34893 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPad-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPad-en-GB.png new file mode 100644 index 000000000..eb29fbb09 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPad-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57bef12f0098ed91ef2438de9d7cc878a31b30f0de9aadd0ca9037a27e0155be +size 73454 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPad-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPad-pseudo.png new file mode 100644 index 000000000..eb29fbb09 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPad-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57bef12f0098ed91ef2438de9d7cc878a31b30f0de9aadd0ca9037a27e0155be +size 73454 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPhone-16-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPhone-16-en-GB.png new file mode 100644 index 000000000..4fd3f638a --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPhone-16-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:803a52b525255c2f011e64b71cadea4f1cca0348449743b0a4617a5314b7ea83 +size 32080 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPhone-16-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPhone-16-pseudo.png new file mode 100644 index 000000000..4fd3f638a --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/pillView.User-with-missing-name-iPhone-16-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:803a52b525255c2f011e64b71cadea4f1cca0348449743b0a4617a5314b7ea83 +size 32080 diff --git a/UnitTests/Sources/PillContextTests.swift b/UnitTests/Sources/PillContextTests.swift index 4fb576868..3311a90a9 100644 --- a/UnitTests/Sources/PillContextTests.swift +++ b/UnitTests/Sources/PillContextTests.swift @@ -40,7 +40,6 @@ class PillContextTests: XCTestCase { await Task.yield() XCTAssertFalse(context.viewState.isOwnMention) - XCTAssertNil(context.viewState.image) XCTAssertEqual(context.viewState.displayText, "@\(name)") } @@ -63,7 +62,6 @@ class PillContextTests: XCTestCase { clientProxy: ClientProxyMock(.init())) let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .user(userID: id), font: .preferredFont(forTextStyle: .body))) - XCTAssertNil(context.viewState.image) XCTAssertTrue(context.viewState.isOwnMention) } @@ -89,8 +87,7 @@ class PillContextTests: XCTestCase { let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .allUsers, font: .preferredFont(forTextStyle: .body))) XCTAssertTrue(context.viewState.isOwnMention) - XCTAssertNil(context.viewState.image) - XCTAssertEqual(context.viewState.displayText, PillConstants.atRoom) + XCTAssertEqual(context.viewState.displayText, PillUtilities.atRoom) } func testRoomIDMention() { @@ -115,8 +112,7 @@ class PillContextTests: XCTestCase { XCTAssertFalse(context.viewState.isOwnMention) XCTAssertFalse(context.viewState.isUndefined) - XCTAssertEqual(context.viewState.image, .roomAvatar(.room(id: "1", name: "Foundation 🔭🪐🌌", avatarURL: nil))) - XCTAssertEqual(context.viewState.displayText, "Foundation 🔭🪐🌌") + XCTAssertEqual(context.viewState.displayText, "#Foundation 🔭🪐🌌") } func testRoomIDMentionMissingRoom() { @@ -139,7 +135,6 @@ class PillContextTests: XCTestCase { XCTAssertFalse(context.viewState.isOwnMention) XCTAssertFalse(context.viewState.isUndefined) - XCTAssertEqual(context.viewState.image, .link) XCTAssertEqual(context.viewState.displayText, "1") } @@ -167,8 +162,7 @@ class PillContextTests: XCTestCase { XCTAssertFalse(context.viewState.isOwnMention) XCTAssertFalse(context.viewState.isUndefined) - XCTAssertEqual(context.viewState.image, .roomAvatar(.room(id: "2", name: "Foundation and Empire", avatarURL: nil))) - XCTAssertEqual(context.viewState.displayText, "Foundation and Empire") + XCTAssertEqual(context.viewState.displayText, "#Foundation and Empire") } func testRoomAliasMentionMissingRoom() { @@ -191,7 +185,6 @@ class PillContextTests: XCTestCase { XCTAssertFalse(context.viewState.isOwnMention) XCTAssertFalse(context.viewState.isUndefined) - XCTAssertEqual(context.viewState.image, .link) XCTAssertEqual(context.viewState.displayText, "#foundation-and-empire:matrix.org") } @@ -217,8 +210,7 @@ class PillContextTests: XCTestCase { XCTAssertFalse(context.viewState.isOwnMention) XCTAssertFalse(context.viewState.isUndefined) - XCTAssertEqual(context.viewState.image, .link) - XCTAssertEqual(context.viewState.displayText, L10n.screenRoomEventPill("Foundation 🔭🪐🌌")) + XCTAssertEqual(context.viewState.displayText, "💬 > #Foundation 🔭🪐🌌") } func testEventOnRoomIDMentionMissingRoom() { @@ -241,8 +233,7 @@ class PillContextTests: XCTestCase { XCTAssertFalse(context.viewState.isOwnMention) XCTAssertFalse(context.viewState.isUndefined) - XCTAssertEqual(context.viewState.image, .link) - XCTAssertEqual(context.viewState.displayText, L10n.screenRoomEventPill(L10n.commonRoom)) + XCTAssertEqual(context.viewState.displayText, "💬 > 1") } func testEventOnRoomAliasMention() async throws { @@ -269,8 +260,7 @@ class PillContextTests: XCTestCase { XCTAssertFalse(context.viewState.isOwnMention) XCTAssertFalse(context.viewState.isUndefined) - XCTAssertEqual(context.viewState.image, .link) - XCTAssertEqual(context.viewState.displayText, L10n.screenRoomEventPill("Foundation and Empire")) + XCTAssertEqual(context.viewState.displayText, "💬 > #Foundation and Empire") } func testEventOnRoomAliasMentionMissingRoom() async throws { @@ -293,7 +283,6 @@ class PillContextTests: XCTestCase { XCTAssertFalse(context.viewState.isOwnMention) XCTAssertFalse(context.viewState.isUndefined) - XCTAssertEqual(context.viewState.image, .link) - XCTAssertEqual(context.viewState.displayText, L10n.screenRoomEventPill(L10n.commonRoom)) + XCTAssertEqual(context.viewState.displayText, "💬 > #foundation-and-empire:matrix.org") } }