diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index f3619fbf2e..9922f6ab05 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -6692,7 +6692,7 @@ repositoryURL = "https://github.com/vector-im/compound-ios"; requirement = { kind = revision; - revision = 59166acc95a775ba3b7e7d39e5605611cf0e657f; + revision = 8774e358ac6927f041400733ac681456f0910c10; }; }; 9A472EE0218FE7DCF5283429 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 893e8d9000..42022f35cb 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -14,7 +14,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vector-im/compound-ios", "state" : { - "revision" : "59166acc95a775ba3b7e7d39e5605611cf0e657f" + "revision" : "8774e358ac6927f041400733ac681456f0910c10" } }, { diff --git a/ElementX/Sources/Screens/BugReportScreen/View/BugReportScreen.swift b/ElementX/Sources/Screens/BugReportScreen/View/BugReportScreen.swift index f72d4e4876..63967b7c73 100644 --- a/ElementX/Sources/Screens/BugReportScreen/View/BugReportScreen.swift +++ b/ElementX/Sources/Screens/BugReportScreen/View/BugReportScreen.swift @@ -54,7 +54,7 @@ struct BugReportScreen: View { private var textFieldSection: some View { Section { ListRow(label: .plain(title: L10n.screenBugReportEditorPlaceholder), - kind: .textField(text: $context.reportText)) + kind: .textField(text: $context.reportText, axis: .vertical)) .lineLimit(4, reservesSpace: true) .accessibilityIdentifier(A11yIdentifiers.bugReportScreen.report) } footer: { diff --git a/ElementX/Sources/Screens/CreatePollScreen/View/PollFormScreen.swift b/ElementX/Sources/Screens/CreatePollScreen/View/PollFormScreen.swift index e076f0df39..b97d83b90f 100644 --- a/ElementX/Sources/Screens/CreatePollScreen/View/PollFormScreen.swift +++ b/ElementX/Sources/Screens/CreatePollScreen/View/PollFormScreen.swift @@ -34,7 +34,7 @@ struct PollFormScreen: View { deletePollSection } .trackAnalyticsIfNeeded(context: context) - .compoundForm() + .compoundList() .scrollDismissesKeyboard(.immediately) .environment(\.editMode, .constant(.active)) .navigationTitle(context.viewState.navigationTitle) @@ -48,32 +48,31 @@ struct PollFormScreen: View { // MARK: - Private private var questionSection: some View { - Section(L10n.screenCreatePollQuestionDesc) { - TextField(text: $context.question) { - Text(L10n.screenCreatePollQuestionHint) - .compoundFormTextFieldPlaceholder() - } - .introspect(.textField, on: .supportedVersions) { textField in - textField.clearButtonMode = .whileEditing - } - .textFieldStyle(.compoundForm) - .focused($focus, equals: .question) - .accessibilityIdentifier(A11yIdentifiers.pollFormScreen.question) - .onSubmit { - focus = context.options.indices.first.map { .option(index: $0) } - } - .submitLabel(.next) + Section { + ListRow(label: .plain(title: L10n.screenCreatePollQuestionHint), + kind: .textField(text: $context.question)) + .introspect(.textField, on: .supportedVersions) { textField in + textField.clearButtonMode = .whileEditing + } + .focused($focus, equals: .question) + .accessibilityIdentifier(A11yIdentifiers.pollFormScreen.question) + .onSubmit { + focus = context.options.indices.first.map { .option(index: $0) } + } + .submitLabel(.next) + } header: { + Text(L10n.screenCreatePollQuestionDesc) + .compoundListSectionHeader() } - .compoundFormSection() } private var optionsSection: some View { Section { ForEach(context.options) { option in if let index = context.options.firstIndex(of: option) { - PollFormOptionView(text: $context.options[index].text.limited(to: 240), - placeholder: L10n.screenCreatePollAnswerHint(index + 1), - canDeleteItem: context.options.count > 2) { + PollFormOptionRow(text: $context.options[index].text.limited(to: 240), + placeholder: L10n.screenCreatePollAnswerHint(index + 1), + canDeleteItem: context.options.count > 2) { if case .option(let focusedIndex) = focus, focusedIndex == index { focus = nil } @@ -94,22 +93,22 @@ struct PollFormScreen: View { } if context.options.count < context.viewState.maxNumberOfOptions { - Button(L10n.screenCreatePollAddOptionBtn) { - context.send(viewAction: .addOption) - focus = context.options.indices.last.map { .option(index: $0) } - } - .accessibilityIdentifier(A11yIdentifiers.pollFormScreen.addOption) + ListRow(label: .plain(title: L10n.screenCreatePollAddOptionBtn), + kind: .button { + context.send(viewAction: .addOption) + focus = context.options.indices.last.map { .option(index: $0) } + }) + .accessibilityIdentifier(A11yIdentifiers.pollFormScreen.addOption) } } - .compoundFormSection() } private var showResultsSection: some View { Section { - Toggle(L10n.screenCreatePollAnonymousDesc, isOn: $context.isUndisclosed) + ListRow(label: .plain(title: L10n.screenCreatePollAnonymousDesc), + kind: .toggle($context.isUndisclosed)) .accessibilityIdentifier(A11yIdentifiers.pollFormScreen.pollKind) } - .compoundFormSection() } @ViewBuilder @@ -117,13 +116,9 @@ struct PollFormScreen: View { switch context.viewState.mode { case .edit: Section { - Button(role: .destructive) { - context.send(viewAction: .delete) - } label: { - Text(L10n.actionDeletePoll) - } + ListRow(label: .plain(title: L10n.actionDeletePoll, role: .destructive), + kind: .button { context.send(viewAction: .delete) }) } - .compoundFormSection() case .new: EmptyView() } @@ -159,7 +154,7 @@ private extension View { } } -private struct PollFormOptionView: View { +private struct PollFormOptionRow: View { @Environment(\.editMode) var editMode @Binding var text: String let placeholder: String @@ -167,24 +162,30 @@ private struct PollFormOptionView: View { let deleteAction: () -> Void var body: some View { - HStack(spacing: 8) { - if editMode?.wrappedValue == .active { - Button(role: .destructive, action: deleteAction) { - CompoundIcon(\.delete) + ListRow(kind: .custom { + HStack(spacing: 16) { + if editMode?.wrappedValue == .active { + Button(role: .destructive, action: deleteAction) { + CompoundIcon(\.delete) + } + .disabled(!canDeleteItem) + .buttonStyle(.compound(.plain)) + .accessibilityLabel(L10n.actionRemove) } - .disabled(!canDeleteItem) - .buttonStyle(.compound(.plain)) - .accessibilityLabel(L10n.actionRemove) - } - TextField(text: $text) { - Text(placeholder) - .compoundFormTextFieldPlaceholder() - } - .introspect(.textField, on: .supportedVersions) { textField in - textField.clearButtonMode = .whileEditing + + TextField(text: $text) { + Text(placeholder) + .compoundTextFieldPlaceholder() + } + .introspect(.textField, on: .supportedVersions) { textField in + textField.clearButtonMode = .whileEditing + } + .tint(.compound.iconAccentTertiary) + .alignmentGuide(.listRowSeparatorLeading) { _ in 0 } } - .textFieldStyle(.compoundForm) - } + .padding(.horizontal, ListRowPadding.horizontal) + .padding(.vertical, ListRowPadding.vertical) + }) } } @@ -192,10 +193,29 @@ private struct PollFormOptionView: View { struct PollFormScreen_Previews: PreviewProvider, TestablePreview { static let viewModel = PollFormScreenViewModel(mode: .new) + static let editViewModel = PollFormScreenViewModel(mode: .edit(eventID: "1234", poll: poll)) + static let poll = Poll(question: "Cats or Dogs?", + kind: .disclosed, + maxSelections: 1, + options: [ + .init(id: "0", text: "Cats", votes: 0, allVotes: 0, isSelected: false, isWinning: false), + .init(id: "0", text: "Dogs", votes: 0, allVotes: 0, isSelected: false, isWinning: false), + .init(id: "0", text: "Fish", votes: 0, allVotes: 0, isSelected: false, isWinning: false) + ], + votes: [:], + endDate: nil, + createdByAccountOwner: true) + static var previews: some View { NavigationStack { PollFormScreen(context: viewModel.context) } + .previewDisplayName("New") + + NavigationStack { + PollFormScreen(context: editViewModel.context) + } + .previewDisplayName("Edit") } } diff --git a/ElementX/Sources/Screens/ReportContentScreen/View/ReportContentScreen.swift b/ElementX/Sources/Screens/ReportContentScreen/View/ReportContentScreen.swift index 8c4909e9c9..d638a687df 100644 --- a/ElementX/Sources/Screens/ReportContentScreen/View/ReportContentScreen.swift +++ b/ElementX/Sources/Screens/ReportContentScreen/View/ReportContentScreen.swift @@ -43,7 +43,7 @@ struct ReportContentScreen: View { private var reasonSection: some View { Section { ListRow(label: .plain(title: L10n.reportContentHint), - kind: .textField(text: $context.reasonText)) + kind: .textField(text: $context.reasonText, axis: .vertical)) .lineLimit(4, reservesSpace: true) } footer: { Text(L10n.reportContentExplanation) diff --git a/UITests/Sources/PollFormScreenUITests.swift b/UITests/Sources/PollFormScreenUITests.swift index cf4cc88190..2303abf700 100644 --- a/UITests/Sources/PollFormScreenUITests.swift +++ b/UITests/Sources/PollFormScreenUITests.swift @@ -49,7 +49,8 @@ class PollFormScreenUITests: XCTestCase { let addOption = app.buttons[A11yIdentifiers.pollFormScreen.addOption] for _ in 1...18 { - if !addOption.exists { + // Use the frame as a fallback to fix the button being obscured by the home indicator. + if !addOption.isHittable || addOption.frame.maxY > (app.frame.maxY - 20) { app.swipeUp() } addOption.tap() diff --git a/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll-1.png b/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll-1.png index 91c93e5324..f3cb0b2611 100644 --- a/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll-1.png +++ b/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll-1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d5ff2fccc554a739052160b4e224f2845ac09d1bfb733c8f5adb78b860aa6a2 -size 86358 +oid sha256:2955b8a8c24fc65f917c722ed3ed73dc91adcd0c2b690fc1ba9fb0ebcb9a2e65 +size 87226 diff --git a/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll-2.png b/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll-2.png index 13ce13a821..77034c8576 100644 --- a/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll-2.png +++ b/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll-2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f63af9f1e715da12f55d7e91279c47219b42b27125e44f915c47227321a12bdb -size 185844 +oid sha256:46e0da06cd751549c0debc4cc44ca7c05f368387f2b868db79ef33dccc16c368 +size 182444 diff --git a/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll.png b/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll.png index a9ab6043cf..fd574d0e9f 100644 --- a/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll.png +++ b/UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.createPoll.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:49bc0269e6ee23dd860ebe5aa28115500cfa09120db606c072be0f3831804294 -size 89795 +oid sha256:f80d3352ccc3f89a9a68c041145416562c3e5b6c893a6b099c3012f1cfbc300b +size 90898 diff --git a/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll-1.png b/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll-1.png index 071776f5b0..ce0af8a1cb 100644 --- a/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll-1.png +++ b/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll-1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:75e7080c7e2701f3c2225543f0862366af3726b289832f718a1f20687f718852 -size 98596 +oid sha256:55c14d4b93f46ca93e3dcbfceaa41f04c72d07e2208d71579c54960b26e17789 +size 102626 diff --git a/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll-2.png b/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll-2.png index c6ae7a1589..c734a2e8c8 100644 --- a/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll-2.png +++ b/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll-2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aaf56b99ecc5b57d4a22a4c6fbefe5eae6e731c16794ec528072e0c5695d26eb -size 308849 +oid sha256:4b106061996488ae46a3afa4701e44586230601faa5ad5b019f0f1b831637adb +size 296955 diff --git a/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll.png b/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll.png index 3534728da7..47dd058058 100644 --- a/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll.png +++ b/UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.createPoll.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:08badf82fe902d28e5b94cb64b1e018039febf8c440aa9bcdf20278c2c85d0f0 -size 103798 +oid sha256:fd42c7188d81f3f3e9d95dd38b8e1fc91a7606c7cd62fe2d489b174b51cf8253 +size 107729 diff --git a/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll-1.png b/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll-1.png index eb299f39af..fb8f2795e9 100644 --- a/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll-1.png +++ b/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll-1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a3f917bd4c44eaefe4e1d81333ea0f957ab58ea30eb7d9bbfc74b9d341e64107 -size 90650 +oid sha256:0de593a81e150cd96f2b5a7b8dd0b4782c07e6deb1df8d4df4cee773a8283ae7 +size 91558 diff --git a/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll-2.png b/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll-2.png index 127731524e..d2cfa38750 100644 --- a/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll-2.png +++ b/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll-2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5952c0897de9cce140b877dda5413f2ee2a611d5bdfe7747b24289c3280534ef -size 223668 +oid sha256:eb62280b037556efb52b2b0c55f7fc3b9f2b73f34f83d0af9b2c8881c3b66207 +size 217791 diff --git a/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll.png b/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll.png index d4751043ad..1f2c6be662 100644 --- a/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll.png +++ b/UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.createPoll.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e4538a0afc6b1c8e04563ed6b780907bb79e9711c2538ab52347fc207b84feb3 -size 97971 +oid sha256:c5f89615f4a3021fe65d5e1790a3c5b0708bf057cc56f9ed9b31c20ae5975f75 +size 98656 diff --git a/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll-1.png b/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll-1.png index 52ad2a1a90..ca58e729f2 100644 --- a/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll-1.png +++ b/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll-1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6f58f283d752f71111d6256fb4900811d4acd5c9986e49974079929eb8886e0b -size 113717 +oid sha256:4cd6ee2d916ff6d436ac3c88c65f2483591997aeaa8e61b7be1db9d3d81beb1d +size 116890 diff --git a/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll-2.png b/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll-2.png index a0e3b88505..3af456877a 100644 --- a/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll-2.png +++ b/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll-2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:394201a98ed59bf494453a5746cd069058548d52bee6df79981489d4abe36540 -size 351267 +oid sha256:e3dc7dc02f3a91e3bde9eedff35921ac6d0686ed477387493a7e81dec2a512c4 +size 338429 diff --git a/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll.png b/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll.png index 32abec430d..319043a4ec 100644 --- a/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll.png +++ b/UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.createPoll.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1bbc082476832b1cdd4ec0eee854bbe885b6c71189b77c8b578c10934b0d4c86 -size 123787 +oid sha256:b146f3309a3356836781c2ce0a5b5bf89ecc5094a4ec5776d2f3a9f36e023379 +size 129146 diff --git a/UnitTests/__Snapshots__/PreviewTests/test_pollFormScreen.1.png b/UnitTests/__Snapshots__/PreviewTests/test_pollFormScreen.1.png deleted file mode 100644 index f7f14fad24..0000000000 --- a/UnitTests/__Snapshots__/PreviewTests/test_pollFormScreen.1.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c8a37f2e525c24464f4a99e7110abad6bff7923429d5de27f25167c2b62b7241 -size 122848 diff --git a/UnitTests/__Snapshots__/PreviewTests/test_pollFormScreen.Edit.png b/UnitTests/__Snapshots__/PreviewTests/test_pollFormScreen.Edit.png new file mode 100644 index 0000000000..3993362f82 --- /dev/null +++ b/UnitTests/__Snapshots__/PreviewTests/test_pollFormScreen.Edit.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b35a659b867b21712bceb7523dfa3c3f3c726b0dca8baea425aeb99c4c952e29 +size 128152 diff --git a/UnitTests/__Snapshots__/PreviewTests/test_pollFormScreen.New.png b/UnitTests/__Snapshots__/PreviewTests/test_pollFormScreen.New.png new file mode 100644 index 0000000000..363342a5c8 --- /dev/null +++ b/UnitTests/__Snapshots__/PreviewTests/test_pollFormScreen.New.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:838e1140a68573de8781e620fa52652caf6b5ab8f53c25a277c8ec7762965c3d +size 124067 diff --git a/UnitTests/__Snapshots__/PreviewTests/test_templateScreen.1.png b/UnitTests/__Snapshots__/PreviewTests/test_templateScreen.1.png index 2980edd6d1..40226e408c 100644 --- a/UnitTests/__Snapshots__/PreviewTests/test_templateScreen.1.png +++ b/UnitTests/__Snapshots__/PreviewTests/test_templateScreen.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:857f429b2a73b1c154e624afd9458440d82793abf7a79227614331179130fd71 -size 84175 +oid sha256:23ef3965d902febf307ece27a688b9daebd9d2fa474dbc933fec76079224405e +size 84182 diff --git a/changelog.d/pr-2183.change b/changelog.d/pr-2183.change new file mode 100644 index 0000000000..2d0cc904fc --- /dev/null +++ b/changelog.d/pr-2183.change @@ -0,0 +1 @@ +Use the Compound List component on PollFormScreen. \ No newline at end of file diff --git a/project.yml b/project.yml index ebd3d6859f..154c493f2a 100644 --- a/project.yml +++ b/project.yml @@ -49,7 +49,7 @@ packages: # path: ../matrix-rust-sdk Compound: url: https://github.com/vector-im/compound-ios - revision: 59166acc95a775ba3b7e7d39e5605611cf0e657f + revision: 8774e358ac6927f041400733ac681456f0910c10 # path: ../compound-ios AnalyticsEvents: url: https://github.com/matrix-org/matrix-analytics-events