More Space tweaks. (#5086)
* Centre align the title in the space filter cells. * Update SpaceRoomCell and SpaceHeaderView with consistent content.
This commit is contained in:
@@ -61,27 +61,36 @@ struct ChatsSpaceFilterCell: View {
|
||||
}
|
||||
|
||||
private var content: some View {
|
||||
HStack(spacing: 16) {
|
||||
ZStack {
|
||||
// Hidden text to maintain consistent height.
|
||||
placeholderContent.hidden()
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(filter.room.name)
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
.lineLimit(1)
|
||||
|
||||
ZStack {
|
||||
// Hidden text to maintain consistent height.
|
||||
Text("")
|
||||
.hidden()
|
||||
|
||||
if let alias = filter.room.canonicalAlias {
|
||||
Text(alias)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
if let alias = filter.room.canonicalAlias {
|
||||
Text(alias)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
private var placeholderContent: some View {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(filter.room.name)
|
||||
.font(.compound.bodyLG)
|
||||
.lineLimit(1)
|
||||
|
||||
Text(" ")
|
||||
.font(.compound.bodyMD)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,14 +76,15 @@ struct SpaceHeaderView: View {
|
||||
CompoundIcon(spaceDetailsVisibilityIcon, size: .small, relativeTo: .compound.bodyLG)
|
||||
.foregroundStyle(.compound.iconTertiary)
|
||||
}
|
||||
.labelStyle(.custom(spacing: 4))
|
||||
}
|
||||
|
||||
private var spaceDetailsVisibilityTitle: String {
|
||||
switch spaceServiceRoom.visibility {
|
||||
case .public: L10n.commonPublicSpace
|
||||
case .private: L10n.commonPrivateSpace
|
||||
case .restricted: L10n.commonSharedSpace
|
||||
case .none: L10n.commonPrivateSpace
|
||||
case .public: L10n.commonPublic
|
||||
case .private: L10n.commonPrivate
|
||||
case .restricted: L10n.commonSpaceMembers
|
||||
case .none: L10n.commonPrivate
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,36 +33,24 @@ struct SpaceRoomCell: View {
|
||||
isSelected && !isEditModeActive
|
||||
}
|
||||
|
||||
private var subtitle: String {
|
||||
if spaceServiceRoom.isSpace {
|
||||
switch spaceServiceRoom.visibility {
|
||||
case .public: L10n.commonPublicSpace
|
||||
case .private: L10n.commonPrivateSpace
|
||||
case .restricted: L10n.commonSharedSpace
|
||||
case .none: L10n.commonPrivateSpace
|
||||
}
|
||||
} else {
|
||||
L10n.commonMemberCount(spaceServiceRoom.joinedMembersCount)
|
||||
private var visibilityTitle: String {
|
||||
switch spaceServiceRoom.visibility {
|
||||
case .public: L10n.commonPublic
|
||||
case .private: L10n.commonPrivate
|
||||
case .restricted: L10n.commonSpaceMembers
|
||||
case .none: L10n.commonPrivate
|
||||
}
|
||||
}
|
||||
|
||||
var visibilityIcon: KeyPath<CompoundIcons, Image>? {
|
||||
var visibilityIcon: KeyPath<CompoundIcons, Image> {
|
||||
switch spaceServiceRoom.visibility {
|
||||
case .public: \.public
|
||||
case .private: \.lockSolid
|
||||
case .restricted: nil
|
||||
case .restricted: \.spaceSolid
|
||||
case .none: \.lockSolid
|
||||
}
|
||||
}
|
||||
|
||||
private var details: String {
|
||||
if spaceServiceRoom.isSpace {
|
||||
L10n.commonMemberCount(spaceServiceRoom.joinedMembersCount)
|
||||
} else {
|
||||
spaceServiceRoom.topic ?? " " // Use a single space to reserve a consistent amount of space.
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
action(.select(spaceServiceRoom))
|
||||
@@ -121,9 +109,9 @@ struct SpaceRoomCell: View {
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
.lineLimit(1)
|
||||
|
||||
subtitleLabel
|
||||
visibilityLabel
|
||||
|
||||
Text(details)
|
||||
Text(L10n.commonMemberCount(spaceServiceRoom.joinedMembersCount))
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.lineLimit(1)
|
||||
@@ -134,19 +122,17 @@ struct SpaceRoomCell: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var subtitleLabel: some View {
|
||||
private var visibilityLabel: some View {
|
||||
Label {
|
||||
Text(subtitle)
|
||||
Text(visibilityTitle)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundStyle(.compound.textSecondary)
|
||||
.lineLimit(1)
|
||||
} icon: {
|
||||
if let visibilityIcon {
|
||||
CompoundIcon(visibilityIcon,
|
||||
size: .xSmall,
|
||||
relativeTo: .compound.bodyMD)
|
||||
.foregroundStyle(.compound.iconTertiary)
|
||||
}
|
||||
CompoundIcon(visibilityIcon,
|
||||
size: .xSmall,
|
||||
relativeTo: .compound.bodyMD)
|
||||
.foregroundStyle(.compound.iconTertiary)
|
||||
}
|
||||
.labelStyle(.custom(spacing: 4))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user