From 60c11c8172526145211ea4fbb630b3fc50f8ba2d Mon Sep 17 00:00:00 2001 From: Mauro <34335419+Velin92@users.noreply.github.com> Date: Mon, 5 Oct 2026 18:03:19 +0200 Subject: [PATCH] Add the multi-account announcement screen (#6263) * Add the multi-account announcement screen A self-sizing bottom sheet telling users they can now add multiple accounts, matching the designs. Close and Add account both report back to the coordinator; nothing presents it yet. * Use the Localazy strings for the multi-account announcement The copy now lives in Localazy as screen.multi_account_announcement.*, named after the screen rather than the room list. * Apply review suggestions to the multi-account announcement - Use an ElementNavigationStack with a toolbar close button, like RedactConfirmationView, instead of an overlaid glass button. * Remove the large text preview from the multi-account announcement Other sheets built the same way don't snapshot Dynamic Type sizes, and the iOS 26 bar material it would show isn't rendered in snapshots. * Use TitleAndIcon for the multi-account announcement TitleAndIcon now takes an attributed subtitle (#6274), so the sheet no longer needs to rebuild its layout by hand. The snapshots are unchanged. --- .../Sources/GeneratedAccessibilityTests.swift | 4 ++ ElementX.xcodeproj/project.pbxproj | 36 ++++++++++ .../en-US.lproj/Localizable.strings | 3 + .../en.lproj/Localizable.strings | 3 + ElementX/Sources/Generated/Strings.swift | 8 +++ .../TestablePreviewsDictionary.swift | 1 + ...AccountAnnouncementScreenCoordinator.swift | 47 ++++++++++++ ...MultiAccountAnnouncementScreenModels.swift | 31 ++++++++ ...tiAccountAnnouncementScreenViewModel.swift | 33 +++++++++ ...tAnnouncementScreenViewModelProtocol.swift | 13 ++++ .../View/MultiAccountAnnouncementScreen.swift | 71 +++++++++++++++++++ .../Sources/GeneratedPreviewTests.swift | 7 ++ ...tAnnouncementScreen.Default-iPad-en-GB.png | 3 + ...AnnouncementScreen.Default-iPad-pseudo.png | 3 + ...nnouncementScreen.Default-iPhone-en-GB.png | 3 + ...nouncementScreen.Default-iPhone-pseudo.png | 3 + 16 files changed, 269 insertions(+) create mode 100644 ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenCoordinator.swift create mode 100644 ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenModels.swift create mode 100644 ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenViewModel.swift create mode 100644 ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenViewModelProtocol.swift create mode 100644 ElementX/Sources/Screens/MultiAccountAnnouncementScreen/View/MultiAccountAnnouncementScreen.swift create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPad-en-GB.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPad-pseudo.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPhone-en-GB.png create mode 100644 PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPhone-pseudo.png diff --git a/AccessibilityTests/Sources/GeneratedAccessibilityTests.swift b/AccessibilityTests/Sources/GeneratedAccessibilityTests.swift index 80b3b1eb4..9ad3bb8a6 100644 --- a/AccessibilityTests/Sources/GeneratedAccessibilityTests.swift +++ b/AccessibilityTests/Sources/GeneratedAccessibilityTests.swift @@ -391,6 +391,10 @@ extension AccessibilityTests { try await performAccessibilityAudit(named: "MessageText_Previews") } + func testMultiAccountAnnouncementScreen() async throws { + try await performAccessibilityAudit(named: "MultiAccountAnnouncementScreen_Previews") + } + func testNoticeRoomTimelineView() async throws { try await performAccessibilityAudit(named: "NoticeRoomTimelineView_Previews") } diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 68b2b31e4..47b91696b 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -528,6 +528,7 @@ 52BE121FC21CE88803D2D8B5 /* GalleryItemTileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7927284C6F70D60BE5949F8C /* GalleryItemTileView.swift */; }; 5341D48F833E3E30F16FA2A3 /* SeparatorRoomTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2910422CB628D3B2BBE47449 /* SeparatorRoomTimelineView.swift */; }; 5375902175B2FEA2949D7D74 /* LoginScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CDDDDD9FE1A699D23A5E096 /* LoginScreen.swift */; }; + 53A182049BEEC6195B91DD79 /* MultiAccountAnnouncementScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69630272FD26D4E5974CC88E /* MultiAccountAnnouncementScreenViewModelProtocol.swift */; }; 53A59720F4729D9BBFFB7CAB /* NotificationSettingsEditScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD9CB3B9DFA353AB2B7CD9F8 /* NotificationSettingsEditScreenCoordinator.swift */; }; 53C1E7F6A7D6409D89F36ED7 /* AggregatedReactionMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69CB8242D69B7E4D0B32E18D /* AggregatedReactionMock.swift */; }; 53DEF39F0C4DE02E3FC56D91 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = 800631D7250B7F93195035F1 /* KeychainAccess */; }; @@ -1033,6 +1034,7 @@ A0646F23876D6326AD27FF52 /* LiveLocationSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2FEFA393FC7D2870263012 /* LiveLocationSession.swift */; }; A07178337F3C0B208B5A77A8 /* NotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6ED50FE104992419310EEB /* NotificationHandler.swift */; }; A076E0A9338FD2D950C3C4A1 /* ChatsSpaceFiltersScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = E63072981793CCA84EE12798 /* ChatsSpaceFiltersScreenViewModelProtocol.swift */; }; + A0790A97DAD44E8895035704 /* MultiAccountAnnouncementScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD46D21FF370EDF6BE87F8A7 /* MultiAccountAnnouncementScreenCoordinator.swift */; }; A0861B727B273B5B3DD7FBF6 /* KnockRequestsListScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09227E671DB30795C43FFFD /* KnockRequestsListScreenViewModel.swift */; }; A0868BDE84D2140A885BE3C9 /* EncryptionResetScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E8562F4D7DE073BC32902AB /* EncryptionResetScreenViewModelProtocol.swift */; }; A0D7E5BD0298A97DCBDCE40B /* Sentry in Frameworks */ = {isa = PBXBuildFile; productRef = 7731767AE437BA3BD2CC14A8 /* Sentry */; }; @@ -1270,6 +1272,7 @@ C8E11A335456FCF94A744E6E /* SpaceFlowCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDE826EAB1BAB80C1104980 /* SpaceFlowCoordinator.swift */; }; C8E1E4E06B7C7A3A8246FC9B /* MediaEventsTimelineScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8512B82404B1751D0BCC82D2 /* MediaEventsTimelineScreenCoordinator.swift */; }; C900127318820AD04D6C90B8 /* LabsScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E43D8784B0054C048060FEB /* LabsScreenModels.swift */; }; + C90A5ABB868F7DDEE2DFD653 /* MultiAccountAnnouncementScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DB71240A4E855DE7B9201FD /* MultiAccountAnnouncementScreenModels.swift */; }; C915347779B3C7FDD073A87A /* AVMetadataMachineReadableCodeObjectExtensionsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E1FF0DFBB3768F79FDBF6D /* AVMetadataMachineReadableCodeObjectExtensionsTest.swift */; }; C95ABC529E0009926BDE5664 /* preview_image.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 44688A16934827A0D1668253 /* preview_image.jpg */; }; C960BACE42A9D8C535E8CB34 /* Pagination.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1912062B53CE95E6F700DA60 /* Pagination.swift */; }; @@ -1399,6 +1402,7 @@ DCFE7CB3B9A104330BBB96AD /* AnalyticsPromptScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B67DF223EEB8DCAF178A1D4 /* AnalyticsPromptScreenCoordinator.swift */; }; DD21CE51DF9BD04FC8155972 /* LeaveSpaceHandleSDKMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 580BDCD23DD02481AB5FFB47 /* LeaveSpaceHandleSDKMock.swift */; }; DD4D8B5D668197D345A3ED42 /* TimelineControllerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933BB25FC426D5C67E1D812 /* TimelineControllerMock.swift */; }; + DD66C863B4232BCDEBE883C8 /* MultiAccountAnnouncementScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B5FD54003D9527FE347516 /* MultiAccountAnnouncementScreen.swift */; }; DDE7B4771452300C103B1EB8 /* RoomDirectoryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F6210134203BE1F2DD5C679 /* RoomDirectoryCell.swift */; }; DDFBDEE1DC32BDD5488F898C /* ClientProxyMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F96CCBEAAA7F2185BFA354 /* ClientProxyMock.swift */; }; DE3BF0ED68E56BF625591D49 /* LinkNewDeviceScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72C4A2D279386A811BDC6DAE /* LinkNewDeviceScreen.swift */; }; @@ -1559,6 +1563,7 @@ F519DE17A3A0F760307B2E6D /* InviteUsersScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02D155E09BF961BBA8F85263 /* InviteUsersScreenViewModel.swift */; }; F54E2D6CAD96E1AC15BC526F /* MessageForwardingScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8E60332509665C00179ACF6 /* MessageForwardingScreenViewModel.swift */; }; F58BF3BD3233A03F013816E4 /* ClassicAppAccountManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F4DFFFC62187D9A4D2030D /* ClassicAppAccountManager.swift */; }; + F5A74869B9899FB178EDCDF9 /* MultiAccountAnnouncementScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F6FA4E8F2A0D6947AA44C2 /* MultiAccountAnnouncementScreenViewModel.swift */; }; F5D2270B5021D521C0D22E11 /* FlowCoordinatorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B9FCA1CFD07B8CF9BD21266 /* FlowCoordinatorProtocol.swift */; }; F656F92A63D3DC1978D79427 /* Macros in Frameworks */ = {isa = PBXBuildFile; productRef = 401E93551F7792B0179907CF /* Macros */; }; F65F3909769E7C48B3309D9D /* RemoteSettingsHook.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5D186A6DB8FAC5C9D0E4D61 /* RemoteSettingsHook.swift */; }; @@ -2053,6 +2058,7 @@ 2DA3DBE1A42EAFF93889FA04 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/SAS.strings; sourceTree = ""; }; 2DA4F09CB613C54FDC73AE6A /* ThreadDecorator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadDecorator.swift; sourceTree = ""; }; 2DB0E533508094156D8024C3 /* TimelineStyler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineStyler.swift; sourceTree = ""; }; + 2DB71240A4E855DE7B9201FD /* MultiAccountAnnouncementScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiAccountAnnouncementScreenModels.swift; sourceTree = ""; }; 2E11E7C396ED06A154CF6DF3 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/SAS.strings; sourceTree = ""; }; 2F06F70B9C433BAD4BC6B9F5 /* EncryptedRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptedRoomTimelineView.swift; sourceTree = ""; }; 2F36C5D9B37E50915ECBD3EE /* RoomMemberProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMemberProxy.swift; sourceTree = ""; }; @@ -2168,6 +2174,7 @@ 42C58159916ABD7F454CE689 /* AdvancedSettingsScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedSettingsScreenCoordinator.swift; sourceTree = ""; }; 42C64A14EE89928207E3B42B /* AnalyticsSettingsScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsSettingsScreenModels.swift; sourceTree = ""; }; 42C8C368A611B9CB79C7F5FA /* RoomPollsHistoryScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomPollsHistoryScreen.swift; sourceTree = ""; }; + 42F6FA4E8F2A0D6947AA44C2 /* MultiAccountAnnouncementScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiAccountAnnouncementScreenViewModel.swift; sourceTree = ""; }; 430C73079A84654BF46A7FF5 /* FileMediaEventsTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileMediaEventsTimelineView.swift; sourceTree = ""; }; 4338BB055A26094673CDC220 /* SpaceAddRoomsScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceAddRoomsScreenViewModel.swift; sourceTree = ""; }; 434522ED2BDED08759048077 /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = fi.lproj/Localizable.strings; sourceTree = ""; }; @@ -2391,6 +2398,7 @@ 68F8744C32ACA0821A771EBB /* test_audio.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = test_audio.mp3; sourceTree = ""; }; 690915157A874D1F21ADE70C /* preview_avatar_room.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = preview_avatar_room.jpg; sourceTree = ""; }; 693E16574C6F7F9FA1015A8C /* Search.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Search.swift; sourceTree = ""; }; + 69630272FD26D4E5974CC88E /* MultiAccountAnnouncementScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiAccountAnnouncementScreenViewModelProtocol.swift; sourceTree = ""; }; 69A05E85E4872C3221C5C287 /* RemotePreference.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemotePreference.swift; sourceTree = ""; }; 69CB8242D69B7E4D0B32E18D /* AggregatedReactionMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AggregatedReactionMock.swift; sourceTree = ""; }; 69D42EE0102D2857933625DD /* CreateRoomViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateRoomViewModelTests.swift; sourceTree = ""; }; @@ -2646,6 +2654,7 @@ 94028A227645FA880B966211 /* WaveformSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaveformSource.swift; sourceTree = ""; }; 9475FD81B13D50103E5290EB /* SpaceSettingsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceSettingsScreen.swift; sourceTree = ""; }; 94A561C542596126DAE211AD /* preview_avatar_user.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = preview_avatar_user.jpg; sourceTree = ""; }; + 94B5FD54003D9527FE347516 /* MultiAccountAnnouncementScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiAccountAnnouncementScreen.swift; sourceTree = ""; }; 94D670124FC3E84F23A62CCF /* APNSPayload.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APNSPayload.swift; sourceTree = ""; }; 94EE2C5F0A06F146BBE3A1B1 /* LinkNewDeviceFlowCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkNewDeviceFlowCoordinator.swift; sourceTree = ""; }; 9501D11B4258DFA33BA3B40F /* ServerSelectionScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSelectionScreenModels.swift; sourceTree = ""; }; @@ -2995,6 +3004,7 @@ CCE06F4A71FD46C9D8CD432E /* RoomThreadListServiceProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomThreadListServiceProxy.swift; sourceTree = ""; }; CCF71646898A2F720C5BFDF5 /* RoomDirectorySearchScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDirectorySearchScreenViewModel.swift; sourceTree = ""; }; CD469F7513574341181F7EAA /* ServerSelectionScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSelectionScreen.swift; sourceTree = ""; }; + CD46D21FF370EDF6BE87F8A7 /* MultiAccountAnnouncementScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiAccountAnnouncementScreenCoordinator.swift; sourceTree = ""; }; CD6613DE16AD26B3A74DA1F5 /* LocationRoomTimelineItemContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationRoomTimelineItemContent.swift; sourceTree = ""; }; CDA38C9B58693A49A3032552 /* DeclineAndBlockScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeclineAndBlockScreenCoordinator.swift; sourceTree = ""; }; CDB3227C7A74B734924942E9 /* RoomSummaryProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSummaryProvider.swift; sourceTree = ""; }; @@ -3944,6 +3954,14 @@ path = RoomMember; sourceTree = ""; }; + 2C5E4DC51BC09EA05CA1D590 /* View */ = { + isa = PBXGroup; + children = ( + 94B5FD54003D9527FE347516 /* MultiAccountAnnouncementScreen.swift */, + ); + path = View; + sourceTree = ""; + }; 2D0D49B0533C4C2EB889BF3A /* ServerSelectionScreen */ = { isa = PBXGroup; children = ( @@ -5004,6 +5022,18 @@ path = View; sourceTree = ""; }; + 601F598160369994A6C0C85D /* MultiAccountAnnouncementScreen */ = { + isa = PBXGroup; + children = ( + CD46D21FF370EDF6BE87F8A7 /* MultiAccountAnnouncementScreenCoordinator.swift */, + 2DB71240A4E855DE7B9201FD /* MultiAccountAnnouncementScreenModels.swift */, + 42F6FA4E8F2A0D6947AA44C2 /* MultiAccountAnnouncementScreenViewModel.swift */, + 69630272FD26D4E5974CC88E /* MultiAccountAnnouncementScreenViewModelProtocol.swift */, + 2C5E4DC51BC09EA05CA1D590 /* View */, + ); + path = MultiAccountAnnouncementScreen; + sourceTree = ""; + }; 605F8221E52991786397FCC9 /* View */ = { isa = PBXGroup; children = ( @@ -7095,6 +7125,7 @@ 87E2774157D9C4894BCFF3F8 /* MediaPickerScreen */, 23605DD08620BE6558242469 /* MediaUploadPreviewScreen */, 3348D14DBDB54E72FC67E2F3 /* MessageForwardingScreen */, + 601F598160369994A6C0C85D /* MultiAccountAnnouncementScreen */, DE07A244ACE83E40D894EDF3 /* NativeCallScreen */, 8F074E22FD93E64211971845 /* Onboarding */, A448A3A8F764174C60CD0CA1 /* Other */, @@ -9109,6 +9140,11 @@ C13128AAA787A4C2CBE4EE82 /* MessageForwardingScreenViewModelProtocol.swift in Sources */, C97325EFDCCEE457432A9E82 /* MessageText.swift in Sources */, AF2ABA2794E376B64104C964 /* MockSoftLogoutScreenState.swift in Sources */, + DD66C863B4232BCDEBE883C8 /* MultiAccountAnnouncementScreen.swift in Sources */, + A0790A97DAD44E8895035704 /* MultiAccountAnnouncementScreenCoordinator.swift in Sources */, + C90A5ABB868F7DDEE2DFD653 /* MultiAccountAnnouncementScreenModels.swift in Sources */, + F5A74869B9899FB178EDCDF9 /* MultiAccountAnnouncementScreenViewModel.swift in Sources */, + 53A182049BEEC6195B91DD79 /* MultiAccountAnnouncementScreenViewModelProtocol.swift in Sources */, E938F7A45D6A3DBBE6789A03 /* NSEUserSession.swift in Sources */, 551E03A935A6B73158A1AB4A /* NSEUserSessionMock.swift in Sources */, F9842667B68DC6FA1F9ECCBB /* NSItemProvider.swift in Sources */, diff --git a/ElementX/Resources/Localizations/en-US.lproj/Localizable.strings b/ElementX/Resources/Localizations/en-US.lproj/Localizable.strings index a43ef4c7f..6126406f0 100644 --- a/ElementX/Resources/Localizations/en-US.lproj/Localizable.strings +++ b/ElementX/Resources/Localizations/en-US.lproj/Localizable.strings @@ -1074,6 +1074,9 @@ "screen_moderation_and_safety_invites_heading" = "Invites"; "screen_moderation_and_safety_other_users_heading" = "Other users"; "screen_moderation_and_safety_share_presence_heading" = "Your appearance"; +"screen_multi_account_announcement_action" = "Add account"; +"screen_multi_account_announcement_description" = "Go to %1$@ to sign into another account. Then you can easily switch between them."; +"screen_multi_account_announcement_title" = "You can now add multiple accounts"; "screen_notification_optin_subtitle" = "You can change your settings later."; "screen_notification_optin_title" = "Allow notifications and never miss a message"; "screen_notification_settings_additional_settings_section_title" = "Additional settings"; diff --git a/ElementX/Resources/Localizations/en.lproj/Localizable.strings b/ElementX/Resources/Localizations/en.lproj/Localizable.strings index 071477e13..14904db8d 100644 --- a/ElementX/Resources/Localizations/en.lproj/Localizable.strings +++ b/ElementX/Resources/Localizations/en.lproj/Localizable.strings @@ -1074,6 +1074,9 @@ "screen_moderation_and_safety_invites_heading" = "Invites"; "screen_moderation_and_safety_other_users_heading" = "Other users"; "screen_moderation_and_safety_share_presence_heading" = "Your appearance"; +"screen_multi_account_announcement_action" = "Add account"; +"screen_multi_account_announcement_description" = "Go to %1$@ to sign into another account. Then you can easily switch between them."; +"screen_multi_account_announcement_title" = "You can now add multiple accounts"; "screen_notification_optin_subtitle" = "You can change your settings later."; "screen_notification_optin_title" = "Allow notifications and never miss a message"; "screen_notification_settings_additional_settings_section_title" = "Additional settings"; diff --git a/ElementX/Sources/Generated/Strings.swift b/ElementX/Sources/Generated/Strings.swift index ec4e37779..342f46b3f 100644 --- a/ElementX/Sources/Generated/Strings.swift +++ b/ElementX/Sources/Generated/Strings.swift @@ -2518,6 +2518,14 @@ internal nonisolated enum L10n { internal static var screenModerationAndSafetyOtherUsersHeading: String { return L10n.tr("Localizable", "screen_moderation_and_safety_other_users_heading") } /// Your appearance internal static var screenModerationAndSafetySharePresenceHeading: String { return L10n.tr("Localizable", "screen_moderation_and_safety_share_presence_heading") } + /// Add account + internal static var screenMultiAccountAnnouncementAction: String { return L10n.tr("Localizable", "screen_multi_account_announcement_action") } + /// Go to %1$@ to sign into another account. Then you can easily switch between them. + internal static func screenMultiAccountAnnouncementDescription(_ p1: Any) -> String { + return L10n.tr("Localizable", "screen_multi_account_announcement_description", String(describing: p1)) + } + /// You can now add multiple accounts + internal static var screenMultiAccountAnnouncementTitle: String { return L10n.tr("Localizable", "screen_multi_account_announcement_title") } /// You can change your settings later. internal static var screenNotificationOptinSubtitle: String { return L10n.tr("Localizable", "screen_notification_optin_subtitle") } /// Allow notifications and never miss a message diff --git a/ElementX/Sources/Other/TestablePreview/TestablePreviewsDictionary.swift b/ElementX/Sources/Other/TestablePreview/TestablePreviewsDictionary.swift index 133cfea16..221c350c0 100644 --- a/ElementX/Sources/Other/TestablePreview/TestablePreviewsDictionary.swift +++ b/ElementX/Sources/Other/TestablePreview/TestablePreviewsDictionary.swift @@ -102,6 +102,7 @@ enum TestablePreviewsDictionary { "MessageComposer_Previews" : MessageComposer_Previews.self, "MessageForwardingScreen_Previews" : MessageForwardingScreen_Previews.self, "MessageText_Previews" : MessageText_Previews.self, + "MultiAccountAnnouncementScreen_Previews" : MultiAccountAnnouncementScreen_Previews.self, "NoticeRoomTimelineView_Previews" : NoticeRoomTimelineView_Previews.self, "NotificationPermissionsScreen_Previews" : NotificationPermissionsScreen_Previews.self, "NotificationSettingsEditScreenRoomCell_Previews" : NotificationSettingsEditScreenRoomCell_Previews.self, diff --git a/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenCoordinator.swift b/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenCoordinator.swift new file mode 100644 index 000000000..3bc124d6e --- /dev/null +++ b/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenCoordinator.swift @@ -0,0 +1,47 @@ +// +// Copyright 2026 Element Creations Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. +// Please see LICENSE files in the repository root for full details. +// + +import Combine +import SwiftUI + +enum MultiAccountAnnouncementScreenCoordinatorAction { + case addAccount + case dismiss +} + +final class MultiAccountAnnouncementScreenCoordinator: CoordinatorProtocol { + private let viewModel: MultiAccountAnnouncementScreenViewModelProtocol + + private var cancellables = Set() + + private let actionsSubject: PassthroughSubject = .init() + var actionsPublisher: AnyPublisher { + actionsSubject.eraseToAnyPublisher() + } + + init() { + viewModel = MultiAccountAnnouncementScreenViewModel() + } + + func start() { + viewModel.actionsPublisher.sink { [weak self] action in + guard let self else { return } + + switch action { + case .addAccount: + actionsSubject.send(.addAccount) + case .dismiss: + actionsSubject.send(.dismiss) + } + } + .store(in: &cancellables) + } + + func toPresentable() -> AnyView { + AnyView(MultiAccountAnnouncementScreen(context: viewModel.context)) + } +} diff --git a/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenModels.swift b/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenModels.swift new file mode 100644 index 000000000..e8c55b81c --- /dev/null +++ b/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenModels.swift @@ -0,0 +1,31 @@ +// +// Copyright 2026 Element Creations Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. +// Please see LICENSE files in the repository root for full details. +// + +import SwiftUI + +enum MultiAccountAnnouncementScreenViewModelAction { + case addAccount + case dismiss +} + +struct MultiAccountAnnouncementScreenViewState: BindableState { + let description: AttributedString + + init() { + let boldPlaceholder = "{bold}" + var description = AttributedString(L10n.screenMultiAccountAnnouncementDescription(boldPlaceholder)) + var boldString = AttributedString("\(L10n.commonSettings) > \(L10n.screenSettingsAddAccount)") + boldString.bold() + description.replace(boldPlaceholder, with: boldString) + self.description = description + } +} + +enum MultiAccountAnnouncementScreenViewAction { + case addAccount + case close +} diff --git a/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenViewModel.swift b/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenViewModel.swift new file mode 100644 index 000000000..7cac7e8ff --- /dev/null +++ b/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenViewModel.swift @@ -0,0 +1,33 @@ +// +// Copyright 2026 Element Creations Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. +// Please see LICENSE files in the repository root for full details. +// + +import Combine +import SwiftUI + +typealias MultiAccountAnnouncementScreenViewModelType = StateStoreViewModelV2 + +class MultiAccountAnnouncementScreenViewModel: MultiAccountAnnouncementScreenViewModelType, MultiAccountAnnouncementScreenViewModelProtocol { + private let actionsSubject: PassthroughSubject = .init() + var actionsPublisher: AnyPublisher { + actionsSubject.eraseToAnyPublisher() + } + + init() { + super.init(initialViewState: .init()) + } + + // MARK: - Public + + override func process(viewAction: MultiAccountAnnouncementScreenViewAction) { + switch viewAction { + case .addAccount: + actionsSubject.send(.addAccount) + case .close: + actionsSubject.send(.dismiss) + } + } +} diff --git a/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenViewModelProtocol.swift b/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenViewModelProtocol.swift new file mode 100644 index 000000000..eafeb99d2 --- /dev/null +++ b/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/MultiAccountAnnouncementScreenViewModelProtocol.swift @@ -0,0 +1,13 @@ +// +// Copyright 2026 Element Creations Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. +// Please see LICENSE files in the repository root for full details. +// + +import Combine + +protocol MultiAccountAnnouncementScreenViewModelProtocol { + var actionsPublisher: AnyPublisher { get } + var context: MultiAccountAnnouncementScreenViewModelType.Context { get } +} diff --git a/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/View/MultiAccountAnnouncementScreen.swift b/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/View/MultiAccountAnnouncementScreen.swift new file mode 100644 index 000000000..9b9dbc480 --- /dev/null +++ b/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/View/MultiAccountAnnouncementScreen.swift @@ -0,0 +1,71 @@ +// +// Copyright 2026 Element Creations Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. +// Please see LICENSE files in the repository root for full details. +// + +import Compound +import SwiftUI + +struct MultiAccountAnnouncementScreen: View { + let context: MultiAccountAnnouncementScreenViewModel.Context + + @State private var contentHeight: CGFloat = .zero + @State private var buttonHeight: CGFloat = .zero + private let topPadding: CGFloat = 44 // For the navigation bar + + var body: some View { + ElementNavigationStack { + ScrollView { + content + .readHeight($contentHeight) + } + .scrollBounceBehavior(.basedOnSize) + .backportSafeAreaBar(edge: .bottom, spacing: 0) { + addAccountButton + .readHeight($buttonHeight) + } + .toolbar { + ToolbarItem(placement: .primaryAction) { + ToolbarButton(role: .close) { context.send(viewAction: .close) } + } + } + } + .presentationDetents([.height(contentHeight + buttonHeight + topPadding)]) + .presentationDragIndicator(.hidden) + .presentationBackground(.compound.bgCanvasDefault) + } + + private var content: some View { + TitleAndIcon(title: L10n.screenMultiAccountAnnouncementTitle, + subtitle: context.viewState.description, + icon: \.userProfileSolid, + iconStyle: .defaultSolid) + .frame(maxWidth: .infinity) + .padding(.horizontal, 24) + .padding(.top, 16) + .padding(.bottom, 24) + } + + private var addAccountButton: some View { + Button { + context.send(viewAction: .addAccount) + } label: { + Label(L10n.screenMultiAccountAnnouncementAction, icon: \.plus) + } + .buttonStyle(.compound(.primary)) + .padding(16) + } +} + +// MARK: - Previews + +struct MultiAccountAnnouncementScreen_Previews: PreviewProvider, TestablePreview { + static let viewModel = MultiAccountAnnouncementScreenViewModel() + + static var previews: some View { + MultiAccountAnnouncementScreen(context: viewModel.context) + .previewDisplayName("Default") + } +} diff --git a/PreviewTests/Sources/GeneratedPreviewTests.swift b/PreviewTests/Sources/GeneratedPreviewTests.swift index 3d2b179d1..deca02123 100644 --- a/PreviewTests/Sources/GeneratedPreviewTests.swift +++ b/PreviewTests/Sources/GeneratedPreviewTests.swift @@ -683,6 +683,13 @@ extension PreviewTests { } } + @Test + func multiAccountAnnouncementScreen() async throws { + for (index, preview) in MultiAccountAnnouncementScreen_Previews._allPreviews.enumerated() { + try await assertSnapshots(matching: preview, step: index) + } + } + @Test func noticeRoomTimelineView() async throws { for (index, preview) in NoticeRoomTimelineView_Previews._allPreviews.enumerated() { diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPad-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPad-en-GB.png new file mode 100644 index 000000000..b658ecf53 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPad-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:257f3948490a4a9ca4b9f2eefebb3f0c010bfb3fae2721e4b95cab52889fe3a5 +size 102613 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPad-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPad-pseudo.png new file mode 100644 index 000000000..cf0adf860 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPad-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2588daf8fa9a61b445545e047799520bbd20388a5dbd3f2a71ad94438aee6149 +size 118735 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPhone-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPhone-en-GB.png new file mode 100644 index 000000000..3cc32d349 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPhone-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:753970b5fa26d39052106d90d2f6ecc807a15eddf031f5f67c6e7457d188675a +size 63416 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPhone-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPhone-pseudo.png new file mode 100644 index 000000000..ddfb9f471 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/multiAccountAnnouncementScreen.Default-iPhone-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d987ab496eec5bfe41d3c1b8f2143da225b5740c7b79eb75d4dfaa7fa4b379c2 +size 85276