#49, #123 - Setup UI integration and performance testing (#148)

This commit is contained in:
Stefan Ceriu
2022-08-18 16:32:29 +03:00
committed by GitHub
parent b6e1d6d1e5
commit 78df4abc7f
27 changed files with 954 additions and 78 deletions
+30
View File
@@ -8,6 +8,9 @@
#elseif os(tvOS) || os(watchOS)
import UIKit
#endif
#if canImport(SwiftUI)
import SwiftUI
#endif
// Deprecated typealiases
@available(*, deprecated, renamed: "ImageAsset.Image", message: "This typealias will be removed in SwiftGen 7.0")
@@ -74,6 +77,13 @@ internal struct ImageAsset {
return result
}
#endif
#if canImport(SwiftUI)
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
internal var swiftUIImage: SwiftUI.Image {
SwiftUI.Image(asset: self)
}
#endif
}
internal extension ImageAsset.Image {
@@ -92,6 +102,26 @@ internal extension ImageAsset.Image {
}
}
#if canImport(SwiftUI)
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
internal extension SwiftUI.Image {
init(asset: ImageAsset) {
let bundle = BundleToken.bundle
self.init(asset.name, bundle: bundle)
}
init(asset: ImageAsset, label: Text) {
let bundle = BundleToken.bundle
self.init(asset.name, bundle: bundle, label: label)
}
init(decorative asset: ImageAsset) {
let bundle = BundleToken.bundle
self.init(decorative: asset.name, bundle: bundle)
}
}
#endif
// swiftlint:disable convenience_type
private final class BundleToken {
static let bundle: Bundle = {
@@ -101,6 +101,7 @@ struct HomeScreen: View {
.font(.headline)
.fontWeight(.bold)
.foregroundColor(.primary)
.accessibilityIdentifier("userDisplayNameView")
}
}
@@ -27,12 +27,10 @@ extension AuthenticationError {
var code: MatrixErrorCode {
guard case let .Generic(message) = self else { return .unknown }
for code in MatrixErrorCode.allCases {
if message.contains(code.rawValue) {
return code
}
guard let first = MatrixErrorCode.allCases.first(where: { message.contains($0.rawValue) }) else {
return .unknown
}
return .unknown
return first
}
}