Signal-iOS/Signal/ConversationView/CellViews/MessageSelectionView.swift
Igor Solomennikov 296aa8cc46
Improved message selection indicators in chat.
• use SelectionIndicatorView in chat.
• modify SelectionIndicatorView to allow to configure ring color.
• improve legibility by using custom shade of gray for selection indicator in "not selected" state in chat when in light mode and with a wallpaper set.
2026-05-15 14:35:43 -07:00

47 lines
1.4 KiB
Swift

//
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import SignalServiceKit
import SignalUI
/// ManualLayoutView wrapper around SelectionIndicatorView.
class MessageSelectionView: ManualLayoutView {
private let selectionIndicatorView = SelectionIndicatorView(style: .list)
var isSelected: Bool {
get {
selectionIndicatorView.isSelected
}
set {
selectionIndicatorView.isSelected = newValue
}
}
init() {
super.init(name: "MessageSelectionView")
addSubviewToFillSuperviewEdges(selectionIndicatorView)
}
static var preferredSize: CGSize {
CGSize(square: SelectionIndicatorView.preferredSize)
}
func updateStyle(conversationStyle: ConversationStyle) {
selectionIndicatorView.fillColor = conversationStyle.chatColorValue.asChatUIElementTintColor()
// Less transparent empty circle when there's a wallpaper and we're in light theme
// to improve legibility over darker wallpapers.
if
conversationStyle.isDarkThemeEnabled == false,
conversationStyle.hasWallpaper
{
selectionIndicatorView.unselectedListIndicatorColor = UIColor(rgbHex: 0x808080, alpha: 0.5)
} else {
selectionIndicatorView.unselectedListIndicatorColor = nil // reset to default
}
}
}