Fix visibility of navigation bar when searching the forwarding screen. (#1357)

* Fix visibility of navigation bar when searching the forwarding screen.

- Update Introspect and replace deprecated calls with new ones.
- Remove obsoleted colours from DesignKit.
This commit is contained in:
Doug
2023-07-19 16:55:21 +01:00
committed by GitHub
parent 982379e38a
commit 59dcb9cef4
14 changed files with 39 additions and 78 deletions

View File

@@ -12,16 +12,16 @@ let package = Package(
.library(name: "DesignKit", targets: ["DesignKit"])
],
dependencies: [
.package(url: "https://github.com/vector-im/compound-ios.git", revision: "d1a28b8a311e33ddb517d10391037f1547a3c7b6"),
.package(url: "https://github.com/vector-im/compound-ios.git", revision: "29233e1c95a17372d5e5afe689c31680bb07b1ea"),
.package(url: "https://github.com/vector-im/element-design-tokens.git", exact: "0.0.3"),
.package(url: "https://github.com/siteline/SwiftUI-Introspect.git", from: "0.1.4")
.package(url: "https://github.com/siteline/SwiftUI-Introspect.git", from: "0.9.0")
],
targets: [
.target(name: "DesignKit",
dependencies: [
.product(name: "Compound", package: "compound-ios"),
.product(name: "DesignTokens", package: "element-design-tokens"),
.product(name: "Introspect", package: "SwiftUI-Introspect")
.product(name: "SwiftUIIntrospect", package: "SwiftUI-Introspect")
],
path: "Sources"),
.testTarget(name: "DesignKitTests",

View File

@@ -21,7 +21,6 @@ import SwiftUI
public extension Color {
static let element = ElementColors()
static let global = Color.global
}
public struct ElementColors {
@@ -29,26 +28,6 @@ public struct ElementColors {
private let colors = DesignTokens.CompoundColors()
@available(swift, obsoleted: 5.0, message: "Use textActionPrimary from Compound.")
public var accent: Color { colors.primaryContent }
@available(swift, obsoleted: 5.0, message: "Use textCriticalPrimary/iconCriticalPrimary from Compound.")
public var alert: Color { colors.alert }
@available(swift, obsoleted: 5.0, message: "Use textLinkExternal from Compound.")
public var links: Color { colors.links }
@available(swift, obsoleted: 5.0, message: "Use textPrimary/iconPrimary from Compound.")
public var primaryContent: Color { colors.primaryContent }
@available(swift, obsoleted: 5.0, message: "Use textSecondary/iconSecondary from Compound.")
public var secondaryContent: Color { colors.secondaryContent }
@available(swift, obsoleted: 5.0, message: "Use iconTertiary form Compound for icons. For text use textSecondary. For borders and backgrounds check with Design.")
public var tertiaryContent: Color { colors.tertiaryContent }
@available(swift, obsoleted: 5.0, message: "Use iconQuaternary from Compound for icons. For text, borders and backgrounds check with Design.")
public var quaternaryContent: Color { colors.quaternaryContent }
@available(swift, obsoleted: 5.0, message: "Check with Design for the tokens to use from Compound.")
public var quinaryContent: Color { colors.quinaryContent }
@available(swift, obsoleted: 5.0, message: "Use bgSubtleSecondary from Compound.")
public var system: Color { colors.system }
@available(swift, obsoleted: 5.0, message: "Use bgCanvasDefault from Compound for backgrounds. For text or icons use textOnSolidPrimary/iconOnSolidPrimary.")
public var background: Color { colors.background }
@available(swift, deprecated: 5.0, message: "Use textActionAccent/iconAccentTertiary from Compound.")
public var brand: Color { colors.accent }

View File

@@ -15,8 +15,8 @@
//
import DesignTokens
import Introspect
import SwiftUI
import SwiftUIIntrospect
public extension TextFieldStyle where Self == ElementTextFieldStyle {
static func elementInput(labelText: String? = nil,
@@ -131,7 +131,7 @@ public struct ElementTextFieldStyle: TextFieldStyle {
}
.onTapGesture { isFocused = true } // Set focus with taps outside of the text field
}
.introspectTextField { textField in
.introspect(.textField, on: .iOS(.v16)) { textField in
textField.clearButtonMode = .whileEditing
textField.attributedPlaceholder = NSAttributedString(string: textField.placeholder ?? "",
attributes: [NSAttributedString.Key.foregroundColor: UIColor(placeholderColor)])

View File

@@ -58,7 +58,6 @@
1555A7643D85187D4851040C /* TemplateScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4549FCB53F43DB0B278374BC /* TemplateScreen.swift */; };
157E5FDDF419C0B2CA7E2C28 /* TimelineItemBubbledStylerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98A2932515EA11D3DD8A3506 /* TimelineItemBubbledStylerView.swift */; };
158A2D528CC78C4E7A8ED608 /* MockRoomTimelineControllerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71556206CD5E8B1F53F07178 /* MockRoomTimelineControllerFactory.swift */; };
15D867E638BFD0E5E71DB1EF /* List.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AFEF3AC64B1358083F76B8B /* List.swift */; };
167D00CAA13FAFB822298021 /* MediaProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62A81CCC2516D9CF9322DF01 /* MediaProviderTests.swift */; };
1702981A8085BE4FB0EC001B /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = D33116993D54FADC0C721C1F /* Application.swift */; };
172E6E9A612ADCF10A62CF13 /* BugReportServiceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A68BCE6438873D2661D93D0 /* BugReportServiceProtocol.swift */; };
@@ -920,7 +919,6 @@
2A96A67AD0E32C48941EFBB3 /* SessionVerificationScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionVerificationScreenCoordinator.swift; sourceTree = "<group>"; };
2AB2C848BB9A7A9B618B7B89 /* TextBasedRoomTimelineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextBasedRoomTimelineTests.swift; sourceTree = "<group>"; };
2AF715D4FD4710EBB637D661 /* SettingsScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsScreenViewModelProtocol.swift; sourceTree = "<group>"; };
2AFEF3AC64B1358083F76B8B /* List.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = List.swift; sourceTree = "<group>"; };
2BB385E148DE55C85C0A02D6 /* SoftLogoutScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoftLogoutScreenModels.swift; sourceTree = "<group>"; };
2C0197EAE9D45A662B8847B6 /* RoomTimelineControllerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomTimelineControllerProtocol.swift; sourceTree = "<group>"; };
2CA028DCD4157F9A1F999827 /* BackgroundTaskProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundTaskProtocol.swift; sourceTree = "<group>"; };
@@ -2081,7 +2079,6 @@
E26747B3154A5DBC3A7E24A5 /* Image.swift */,
4E2245243369B99216C7D84E /* ImageCache.swift */,
C14D83B2B7CD5501A0089EFC /* LayoutDirection.swift */,
2AFEF3AC64B1358083F76B8B /* List.swift */,
23AA3F4B285570805CB0CCDD /* MapTiler.swift */,
4151163F666ED94FD959475A /* NotificationName.swift */,
F72EFC8C634469F9262659C7 /* NSItemProvider.swift */,
@@ -3618,7 +3615,7 @@
path = Timeline;
sourceTree = "<group>";
};
"TEMP_F9C0D387-4F2A-4721-B83D-6CECB81A6B6F" /* element-x-ios */ = {
"TEMP_B63C29BF-60FF-4E4E-9DAA-679D9808BBBF" /* element-x-ios */ = {
isa = PBXGroup;
children = (
41553551C55AD59885840F0E /* secrets.xcconfig */,
@@ -3851,7 +3848,6 @@
C13F55E4518415CB4C278E73 /* XCRemoteSwiftPackageReference "DTCoreText" */,
D5F7D47BBAAE0CF1DDEB3034 /* XCRemoteSwiftPackageReference "DeviceKit" */,
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */,
9A472EE0218FE7DCF5283429 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */,
395DE6AE429B7ACC7C7FE31D /* XCRemoteSwiftPackageReference "KZFileWatchers" */,
61916C63E3F5BD900F08DA0C /* XCRemoteSwiftPackageReference "KeychainAccess" */,
D283517192CAC3E2E6920765 /* XCRemoteSwiftPackageReference "Kingfisher" */,
@@ -3861,6 +3857,7 @@
A08925A9D5E3770DEB9D8509 /* XCRemoteSwiftPackageReference "sentry-cocoa" */,
E9C4F3A12AA1F65C13A8C8EB /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */,
6582B5AF3F104B0F7E031E7D /* XCRemoteSwiftPackageReference "SwiftState" */,
9A472EE0218FE7DCF5283429 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */,
0020F10A9DA1895036A72013 /* XCRemoteSwiftPackageReference "swift-url-routing" */,
EC6D0C817B1C21D9D096505A /* XCRemoteSwiftPackageReference "Version" */,
);
@@ -4348,7 +4345,6 @@
F40B097470D3110DFDB1FAAA /* LegalInformationScreenModels.swift in Sources */,
BDED6DA7AD1E76018C424143 /* LegalInformationScreenViewModel.swift in Sources */,
A9D349478F7D4A2B1E40CEF9 /* LegalInformationScreenViewModelProtocol.swift in Sources */,
15D867E638BFD0E5E71DB1EF /* List.swift in Sources */,
6E47D126DD7585E8F8237CE7 /* LoadableAvatarImage.swift in Sources */,
D9F80CE61BF8FF627FDB0543 /* LoadableImage.swift in Sources */,
256D76972BA3254F7CB7F88B /* LocationAnnotation.swift in Sources */,
@@ -5343,7 +5339,7 @@
repositoryURL = "https://github.com/vector-im/compound-ios";
requirement = {
kind = revision;
revision = d1a28b8a311e33ddb517d10391037f1547a3c7b6;
revision = 29233e1c95a17372d5e5afe689c31680bb07b1ea;
};
};
9A472EE0218FE7DCF5283429 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {
@@ -5351,7 +5347,7 @@
repositoryURL = "https://github.com/siteline/SwiftUI-Introspect";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.2.0;
minimumVersion = 0.9.0;
};
};
A08925A9D5E3770DEB9D8509 /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = {

View File

@@ -13,7 +13,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vector-im/compound-ios",
"state" : {
"revision" : "d1a28b8a311e33ddb517d10391037f1547a3c7b6"
"revision" : "29233e1c95a17372d5e5afe689c31680bb07b1ea"
}
},
{
@@ -183,8 +183,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "cef5b3f6f11781dd4591bdd1dd0a3d22bd609334",
"version" : "1.11.0"
"revision" : "dc46eeb3928a75390651fac6c1ef7f93ad59a73b",
"version" : "1.11.1"
}
},
{
@@ -210,8 +210,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect.git",
"state" : {
"revision" : "c18951c747ab62af7c15e17a81bd37d4fd5a9979",
"version" : "0.2.3"
"revision" : "730ab9e6cdbb3122ad88277b295c4cecd284a311",
"version" : "0.9.1"
}
},
{

View File

@@ -1,26 +0,0 @@
//
// Copyright 2022 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 Introspect
import SwiftUI
extension View {
/// Finds a `UICollectionView` from a `SwiftUI.List`, or `SwiftUI.List` child.
/// Stop gap until https://github.com/siteline/SwiftUI-Introspect/pull/169
func introspectCollectionView(customize: @escaping (UICollectionView) -> Void) -> some View {
introspect(selector: TargetViewSelector.ancestorOrSiblingContaining, customize: customize)
}
}

View File

@@ -15,6 +15,7 @@
//
import SwiftUI
import SwiftUIIntrospect
extension View {
/// Disable the interactive dismiss while the search is on.
@@ -28,6 +29,21 @@ extension View {
func dismissSearchOnDisappear() -> some View {
modifier(DismissSearchOnDisappear())
}
/// Configures a searchable's underlying search controller.
/// - Parameters:
/// - hidesNavigationBar: A Boolean indicating whether to hide the navigation bar when searching.
/// - showsCancelButton: A Boolean indicating whether the search controller manages the visibility of the search bars cancel button.
///
/// 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
guard let searchController = navigationController.navigationBar.topItem?.searchController else { return }
searchController.hidesNavigationBarDuringPresentation = hidesNavigationBar
searchController.automaticallyShowsCancelButton = showsCancelButton
}
}
}
private struct InteractiveDismissSearchModifier: ViewModifier {

View File

@@ -27,8 +27,7 @@ struct ServerConfirmationScreen: View {
}
.background()
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
.introspectViewController { viewController in
guard let window = viewController.view.window else { return }
.introspect(.window, on: .iOS(.v16)) { window in
context.send(viewAction: .updateWindow(window))
}
}

View File

@@ -49,8 +49,7 @@ struct SoftLogoutScreen: View {
}
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
.alert(item: $context.alertInfo)
.introspectViewController { viewController in
guard let window = viewController.view.window else { return }
.introspect(.window, on: .iOS(.v16)) { window in
context.send(viewAction: .updateWindow(window))
}
}

View File

@@ -17,6 +17,7 @@
import Combine
import Compound
import SwiftUI
import SwiftUIIntrospect
struct HomeScreen: View {
enum Constants {
@@ -69,7 +70,7 @@ struct HomeScreen: View {
.disableAutocorrection(true)
}
}
.introspectScrollView { scrollView in
.introspect(.scrollView, on: .iOS(.v16)) { scrollView in
guard scrollView != scrollViewAdapter.scrollView else { return }
scrollViewAdapter.scrollView = scrollView
}

View File

@@ -30,9 +30,7 @@ struct InviteUsersScreen: View {
.disableInteractiveDismissOnSearch()
.dismissSearchOnDisappear()
.searchable(text: $context.searchQuery, placement: .navigationBarDrawer(displayMode: .always), prompt: L10n.commonSearchForSomeone)
.introspectSearchController { searchViewController in
searchViewController.hidesNavigationBarDuringPresentation = false
}
.searchableConfiguration(hidesNavigationBar: false)
.compoundSearchField()
.alert(item: $context.alertInfo)
.background(ViewFrameReader(frame: $frame))

View File

@@ -46,6 +46,7 @@ struct MessageForwardingScreen: View {
}
}
.searchable(text: $context.searchQuery, placement: .navigationBarDrawer(displayMode: .always))
.searchableConfiguration(hidesNavigationBar: false)
.compoundSearchField()
.disableAutocorrection(true)
}

View File

@@ -18,8 +18,6 @@ import Combine
import Foundation
import SwiftUI
import Introspect
struct RoomHeaderView: View {
@ObservedObject var context: RoomScreenViewModel.Context

View File

@@ -54,7 +54,7 @@ packages:
minorVersion: 5.13.0
Compound:
url: https://github.com/vector-im/compound-ios
revision: d1a28b8a311e33ddb517d10391037f1547a3c7b6
revision: 29233e1c95a17372d5e5afe689c31680bb07b1ea
# path: ../compound-ios
Algorithms:
url: https://github.com/apple/swift-algorithms
@@ -80,9 +80,9 @@ packages:
KZFileWatchers:
url: https://github.com/krzysztofzablocki/KZFileWatchers
branch: master
Introspect:
SwiftUIIntrospect:
url: https://github.com/siteline/SwiftUI-Introspect
minorVersion: 0.2.0
minorVersion: 0.9.0
PostHog:
url: https://github.com/PostHog/posthog-ios
minorVersion: 2.0.3