diff --git a/DesignKit/Package.swift b/DesignKit/Package.swift index b92122157..ef3a03f65 100644 --- a/DesignKit/Package.swift +++ b/DesignKit/Package.swift @@ -12,7 +12,7 @@ let package = Package( .library(name: "DesignKit", targets: ["DesignKit"]) ], dependencies: [ - .package(url: "https://github.com/vector-im/compound-ios", revision: "4d6300e7d9f5fd7e5c448605bd6bf89537add4b8"), + .package(url: "https://github.com/vector-im/compound-ios", revision: "0966ff92b2670e3a96259c87016edd92d7ea7797"), .package(url: "https://github.com/vector-im/element-design-tokens", exact: "0.0.3"), .package(url: "https://github.com/siteline/SwiftUI-Introspect", from: "0.9.0") ], diff --git a/DesignKit/Sources/Extensions/PlatformViewVersionPredicate.swift b/DesignKit/Sources/Extensions/PlatformViewVersionPredicate.swift new file mode 100644 index 000000000..b104cc4c9 --- /dev/null +++ b/DesignKit/Sources/Extensions/PlatformViewVersionPredicate.swift @@ -0,0 +1,26 @@ +// +// Copyright 2023 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import UIKit + +import SwiftUIIntrospect + +// This can be removed once DesignKit has been migrated in the main app +extension PlatformViewVersionPredicate { + static var supportedVersions: Self { + .iOS(.v16, .v17) + } +} diff --git a/DesignKit/Sources/TextFields/ElementTextFieldStyle.swift b/DesignKit/Sources/TextFields/ElementTextFieldStyle.swift index 681120924..6d1d2b62f 100644 --- a/DesignKit/Sources/TextFields/ElementTextFieldStyle.swift +++ b/DesignKit/Sources/TextFields/ElementTextFieldStyle.swift @@ -131,7 +131,7 @@ public struct ElementTextFieldStyle: TextFieldStyle { } .onTapGesture { isFocused = true } // Set focus with taps outside of the text field } - .introspect(.textField, on: .iOS(.v16, .v17)) { textField in + .introspect(.textField, on: .supportedVersions) { textField in textField.clearButtonMode = .whileEditing textField.attributedPlaceholder = NSAttributedString(string: textField.placeholder ?? "", attributes: [NSAttributedString.Key.foregroundColor: placeholderColor]) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 568ebf19a..1efe0f50e 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -780,6 +780,7 @@ EC280623A42904341363EAAF /* Collections in Frameworks */ = {isa = PBXBuildFile; productRef = A20EA00CCB9DBE0FFB17DD09 /* Collections */; }; EC658A57E715699C52DFBC77 /* CreatePollScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EB1D0C69FEDD93404DF927E /* CreatePollScreenViewModelTests.swift */; }; ECA636DAF071C611FDC2BB57 /* Strings+Untranslated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A18F6CE4D694D21E4EA9B25 /* Strings+Untranslated.swift */; }; + ED564C8C7C43CF5F67000368 /* PlatformViewVersionPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26813CCE39221FE30BF22CD /* PlatformViewVersionPredicate.swift */; }; EDF8919F15DE0FF00EF99E70 /* DocumentPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F5567A7EF6F2AB9473236F6 /* DocumentPicker.swift */; }; EE4E2C1922BBF5169E213555 /* PillAttachmentViewProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B53D6C5C0D14B04D3AB3F6E /* PillAttachmentViewProvider.swift */; }; EE4F5601356228FF72FC56B6 /* MockClientProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F40F48279322E504153AB0D /* MockClientProxy.swift */; }; @@ -1526,6 +1527,7 @@ D1897720266C036471AD9D1B /* FormRowLabelStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormRowLabelStyle.swift; sourceTree = ""; }; D1BC84BA0AF11C2128D58ABD /* Common.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Common.swift; sourceTree = ""; }; D263254AFE5B7993FFBBF324 /* NSE.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NSE.entitlements; sourceTree = ""; }; + D26813CCE39221FE30BF22CD /* PlatformViewVersionPredicate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlatformViewVersionPredicate.swift; sourceTree = ""; }; D316BB02636AF2174F2580E6 /* SoftLogoutScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoftLogoutScreenViewModelProtocol.swift; sourceTree = ""; }; D33116993D54FADC0C721C1F /* Application.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Application.swift; sourceTree = ""; }; D38391154120264910D19528 /* PollMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollMock.swift; sourceTree = ""; }; @@ -2320,6 +2322,7 @@ 4151163F666ED94FD959475A /* NotificationName.swift */, F72EFC8C634469F9262659C7 /* NSItemProvider.swift */, 95BAC0F6C9644336E9567EE6 /* NSRegularExpresion.swift */, + D26813CCE39221FE30BF22CD /* PlatformViewVersionPredicate.swift */, 7310D8DFE01AF45F0689C3AA /* Publisher.swift */, 584A61D9C459FAFEF038A7C0 /* Section.swift */, 40B21E611DADDEF00307E7AC /* String.swift */, @@ -4878,6 +4881,7 @@ 9D79B94493FB32249F7E472F /* PlaceholderAvatarImage.swift in Sources */, 1BA04D05EBC6646958B1BE60 /* PlaceholderScreenCoordinator.swift in Sources */, EF0D0155DD104C7A41A2EB0E /* PlainMentionBuilder.swift in Sources */, + ED564C8C7C43CF5F67000368 /* PlatformViewVersionPredicate.swift in Sources */, 16CBD087038DE3815CDA512C /* PollMock.swift in Sources */, 6B4BF4A6450F55939B49FAEF /* PollOptionView.swift in Sources */, 864C0D3A4077BF433DBC691F /* PollRoomTimelineItem.swift in Sources */, @@ -5829,7 +5833,7 @@ repositoryURL = "https://github.com/vector-im/compound-ios"; requirement = { kind = revision; - revision = 4d6300e7d9f5fd7e5c448605bd6bf89537add4b8; + revision = 0966ff92b2670e3a96259c87016edd92d7ea7797; }; }; 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 f2ce8eb37..4fd9ea8f9 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -13,7 +13,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vector-im/compound-ios", "state" : { - "revision" : "4d6300e7d9f5fd7e5c448605bd6bf89537add4b8" + "revision" : "0966ff92b2670e3a96259c87016edd92d7ea7797" } }, { @@ -66,8 +66,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/nicklockwood/GZIP", "state" : { - "revision" : "c45c8526dad61240a79aaff5b1cf6e082d2b90b2", - "version" : "1.3.0" + "revision" : "bd55f1d89e71ae3f481da74cd4adeadbb849620c", + "version" : "1.3.1" } }, { diff --git a/ElementX/Sources/Application/Application.swift b/ElementX/Sources/Application/Application.swift index e7bb7e68e..cc6c52ba7 100644 --- a/ElementX/Sources/Application/Application.swift +++ b/ElementX/Sources/Application/Application.swift @@ -48,7 +48,7 @@ struct Application: App { openURL($0) } } - .introspect(.window, on: .iOS(.v16, .v17)) { window in + .introspect(.window, on: .supportedVersions) { window in // Workaround for SwiftUI not consistently applying the tint colour to Alerts/Confirmation Dialogs. window.tintColor = .compound.textActionPrimary } diff --git a/ElementX/Sources/Other/Extensions/PlatformViewVersionPredicate.swift b/ElementX/Sources/Other/Extensions/PlatformViewVersionPredicate.swift new file mode 100644 index 000000000..8cc6659e8 --- /dev/null +++ b/ElementX/Sources/Other/Extensions/PlatformViewVersionPredicate.swift @@ -0,0 +1,49 @@ +// +// Copyright 2023 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import UIKit + +import SwiftUIIntrospect + +extension PlatformViewVersionPredicate { + static var supportedVersions: Self { + .iOS(.v16, .v17) + } +} + +extension PlatformViewVersionPredicate { + static var supportedVersions: Self { + .iOS(.v16, .v17) + } +} + +extension PlatformViewVersionPredicate { + static var supportedVersions: Self { + .iOS(.v16, .v17) + } +} + +extension PlatformViewVersionPredicate { + static var supportedVersions: Self { + .iOS(.v16, .v17) + } +} + +extension PlatformViewVersionPredicate { + static var supportedVersions: Self { + .iOS(.v16, .v17) + } +} diff --git a/ElementX/Sources/Other/SwiftUI/Search.swift b/ElementX/Sources/Other/SwiftUI/Search.swift index f80179be1..72d19e877 100644 --- a/ElementX/Sources/Other/SwiftUI/Search.swift +++ b/ElementX/Sources/Other/SwiftUI/Search.swift @@ -38,7 +38,7 @@ extension View { /// This modifier may be moved into Compound once styles for the various configuration options have been defined. func searchableConfiguration(hidesNavigationBar: Bool = true, showsCancelButton: Bool = true) -> some View { - introspect(.navigationStack, on: .iOS(.v16), scope: .ancestor) { navigationController in + introspect(.navigationStack, on: .supportedVersions, scope: .ancestor) { navigationController in guard let searchController = navigationController.navigationBar.topItem?.searchController else { return } searchController.hidesNavigationBarDuringPresentation = hidesNavigationBar searchController.automaticallyShowsCancelButton = showsCancelButton diff --git a/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift b/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift index 64367bb70..d5e81cb9d 100644 --- a/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift +++ b/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift @@ -27,7 +27,7 @@ struct ServerConfirmationScreen: View { } .background() .environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault)) - .introspect(.window, on: .iOS(.v16, .v17)) { window in + .introspect(.window, on: .supportedVersions) { window in context.send(viewAction: .updateWindow(window)) } } diff --git a/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/View/SoftLogoutScreen.swift b/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/View/SoftLogoutScreen.swift index 22c00d358..16f9dc0b3 100644 --- a/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/View/SoftLogoutScreen.swift +++ b/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/View/SoftLogoutScreen.swift @@ -49,7 +49,7 @@ struct SoftLogoutScreen: View { } .background(Color.compound.bgCanvasDefault.ignoresSafeArea()) .alert(item: $context.alertInfo) - .introspect(.window, on: .iOS(.v16, .v17)) { window in + .introspect(.window, on: .supportedVersions) { window in context.send(viewAction: .updateWindow(window)) } } diff --git a/ElementX/Sources/Screens/CreatePollScreen/View/CreatePollScreen.swift b/ElementX/Sources/Screens/CreatePollScreen/View/CreatePollScreen.swift index 289dd6779..8f557014d 100644 --- a/ElementX/Sources/Screens/CreatePollScreen/View/CreatePollScreen.swift +++ b/ElementX/Sources/Screens/CreatePollScreen/View/CreatePollScreen.swift @@ -52,7 +52,7 @@ struct CreatePollScreen: View { Text(L10n.screenCreatePollQuestionHint) .compoundFormTextFieldPlaceholder() } - .introspect(.textField, on: .iOS(.v16, .v17)) { textField in + .introspect(.textField, on: .supportedVersions) { textField in textField.clearButtonMode = .whileEditing } .textFieldStyle(.compoundForm) @@ -151,7 +151,7 @@ private struct CreatePollOptionView: View { Text(placeholder) .compoundFormTextFieldPlaceholder() } - .introspect(.textField, on: .iOS(.v16, .v17)) { textField in + .introspect(.textField, on: .supportedVersions) { textField in textField.clearButtonMode = .whileEditing } .textFieldStyle(.compoundForm) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift index 60dc4ab7d..d45bbf699 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift @@ -62,7 +62,7 @@ struct HomeScreen: View { .disableAutocorrection(true) } } - .introspect(.scrollView, on: .iOS(.v16, .v17)) { scrollView in + .introspect(.scrollView, on: .supportedVersions) { scrollView in guard scrollView != scrollViewAdapter.scrollView else { return } scrollViewAdapter.scrollView = scrollView } @@ -92,7 +92,7 @@ struct HomeScreen: View { .toolbar { toolbar } .background(Color.compound.bgCanvasDefault.ignoresSafeArea()) .track(screen: .home) - .introspect(.viewController, on: .iOS(.v16, .v17)) { controller in + .introspect(.viewController, on: .supportedVersions) { controller in Task { if bloomView == nil { makeBloomView(controller: controller) diff --git a/ElementX/Sources/Screens/RoomScreen/View/TimelineView.swift b/ElementX/Sources/Screens/RoomScreen/View/TimelineView.swift index cd6c835ec..74427ff7b 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/TimelineView.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/TimelineView.swift @@ -36,7 +36,7 @@ struct TimelineView: View { var body: some View { ScrollViewReader { scrollView in timelineScrollView - .introspect(.scrollView, on: .iOS(.v16, .v17)) { uiScrollView in + .introspect(.scrollView, on: .supportedVersions) { uiScrollView in guard uiScrollView != scrollViewAdapter.scrollView else { return } diff --git a/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift b/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift index fe2b264a7..9012f5763 100644 --- a/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift +++ b/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift @@ -45,7 +45,7 @@ struct SettingsScreen: View { .navigationTitle(L10n.commonSettings) .navigationBarTitleDisplayMode(.inline) .toolbar { toolbar } - .introspect(.window, on: .iOS(.v16, .v17)) { window in + .introspect(.window, on: .supportedVersions) { window in context.send(viewAction: .updateWindow(window)) } } diff --git a/project.yml b/project.yml index 34ccebcd1..b019236cb 100644 --- a/project.yml +++ b/project.yml @@ -52,7 +52,7 @@ packages: path: DesignKit Compound: url: https://github.com/vector-im/compound-ios - revision: 4d6300e7d9f5fd7e5c448605bd6bf89537add4b8 + revision: 0966ff92b2670e3a96259c87016edd92d7ea7797 # path: ../compound-ios AnalyticsEvents: url: https://github.com/matrix-org/matrix-analytics-events