supported versions (#1848)

This commit is contained in:
Mauro
2023-10-03 10:10:38 +02:00
committed by GitHub
parent 325ac63d66
commit 7124f24d7c
15 changed files with 96 additions and 17 deletions
@@ -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
}
@@ -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<WindowType, UIWindow> {
static var supportedVersions: Self {
.iOS(.v16, .v17)
}
}
extension PlatformViewVersionPredicate<TextFieldType, UITextField> {
static var supportedVersions: Self {
.iOS(.v16, .v17)
}
}
extension PlatformViewVersionPredicate<ScrollViewType, UIScrollView> {
static var supportedVersions: Self {
.iOS(.v16, .v17)
}
}
extension PlatformViewVersionPredicate<ViewControllerType, UIViewController> {
static var supportedVersions: Self {
.iOS(.v16, .v17)
}
}
extension PlatformViewVersionPredicate<NavigationStackType, UINavigationController> {
static var supportedVersions: Self {
.iOS(.v16, .v17)
}
}
+1 -1
View File
@@ -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
@@ -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))
}
}
@@ -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))
}
}
@@ -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)
@@ -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)
@@ -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
}
@@ -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))
}
}