mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Some random tweaks made on a train 🚆 (#4636)
* Fix the search text field's tint colour. * Don't allow optional content IDs in the placeholder avatar. * Use SwiftUI to resolve the hex values in the Inspector app. This fixes incorrect values being shown in dark/high-contrast modes. * Fix a layout bug with the colour swatch in the Inspector app on iPhone. * Switch to the chats tab when selecting a room with the global search screen. * Run the latest SwiftFormat.
This commit is contained in:
@@ -10,7 +10,7 @@ import SwiftUI
|
||||
struct LoadableAvatarImage: View {
|
||||
private let url: URL?
|
||||
private let name: String?
|
||||
private let contentID: String?
|
||||
private let contentID: String
|
||||
private let isSpace: Bool
|
||||
private let avatarSize: Avatars.Size
|
||||
private let mediaProvider: MediaProviderProtocol?
|
||||
@@ -20,7 +20,7 @@ struct LoadableAvatarImage: View {
|
||||
|
||||
init(url: URL?,
|
||||
name: String?,
|
||||
contentID: String?,
|
||||
contentID: String,
|
||||
isSpace: Bool = false,
|
||||
avatarSize: Avatars.Size,
|
||||
mediaProvider: MediaProviderProtocol?,
|
||||
|
||||
@@ -5,28 +5,16 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct OverridableAvatarImage: View {
|
||||
private let overrideURL: URL?
|
||||
private let url: URL?
|
||||
private let name: String?
|
||||
private let contentID: String?
|
||||
private let avatarSize: Avatars.Size
|
||||
private let mediaProvider: MediaProviderProtocol?
|
||||
|
||||
@ScaledMetric private var frameSize: CGFloat
|
||||
|
||||
init(overrideURL: URL?, url: URL?, name: String?, contentID: String?, avatarSize: Avatars.Size, mediaProvider: MediaProviderProtocol?) {
|
||||
self.overrideURL = overrideURL
|
||||
self.url = url
|
||||
self.name = name
|
||||
self.contentID = contentID
|
||||
self.avatarSize = avatarSize
|
||||
self.mediaProvider = mediaProvider
|
||||
|
||||
_frameSize = ScaledMetric(wrappedValue: avatarSize.value)
|
||||
}
|
||||
let overrideURL: URL?
|
||||
let url: URL?
|
||||
let name: String?
|
||||
let contentID: String
|
||||
let avatarSize: Avatars.Size
|
||||
let mediaProvider: MediaProviderProtocol?
|
||||
|
||||
var body: some View {
|
||||
if let overrideURL {
|
||||
@@ -37,7 +25,7 @@ struct OverridableAvatarImage: View {
|
||||
} placeholder: {
|
||||
ProgressView()
|
||||
}
|
||||
.frame(width: frameSize, height: frameSize)
|
||||
.scaledFrame(size: avatarSize.value)
|
||||
.clipShape(Circle())
|
||||
} else {
|
||||
LoadableAvatarImage(url: url,
|
||||
|
||||
@@ -12,7 +12,7 @@ struct PlaceholderAvatarImage: View {
|
||||
@Environment(\.redactionReasons) private var redactionReasons
|
||||
|
||||
private let textForImage: String
|
||||
private let contentID: String?
|
||||
private let contentID: String
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geometry in
|
||||
@@ -32,9 +32,9 @@ struct PlaceholderAvatarImage: View {
|
||||
.aspectRatio(1, contentMode: .fill)
|
||||
}
|
||||
|
||||
init(name: String?, contentID: String?) {
|
||||
let baseName = name ?? contentID?.trimmingCharacters(in: .punctuationCharacters)
|
||||
textForImage = baseName?.first?.uppercased() ?? ""
|
||||
init(name: String?, contentID: String) {
|
||||
let baseName = name ?? contentID.trimmingCharacters(in: .punctuationCharacters)
|
||||
textForImage = baseName.first?.uppercased() ?? ""
|
||||
self.contentID = contentID
|
||||
}
|
||||
|
||||
@@ -47,11 +47,7 @@ struct PlaceholderAvatarImage: View {
|
||||
}
|
||||
|
||||
private var avatarColor: DecorativeColor? {
|
||||
guard let contentID else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return Color.compound.decorativeColor(for: contentID)
|
||||
Color.compound.decorativeColor(for: contentID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ struct RoomAvatarImage: View {
|
||||
// We will expand upon this with more stack sizes in the future.
|
||||
if users.count == 0 {
|
||||
let _ = assertionFailure("We should never pass empty heroes here.")
|
||||
PlaceholderAvatarImage(name: nil, contentID: nil)
|
||||
PlaceholderAvatarImage(name: nil, contentID: "")
|
||||
} else if users.count == 2 {
|
||||
let clusterSize = avatarSize.value * 1.6
|
||||
ZStack {
|
||||
|
||||
Reference in New Issue
Block a user