Add support for copying a caption. (#3563)

* Add timeline item action for copying a media caption.

* Fix the action colours when long pressing a timeline item.

Nice side effect: Reasonable sized buttons when button shapes are enabled.

* Re-arrange the Timeline Item Menu.

* Add timeline item menu snapshots for media items.
This commit is contained in:
Doug
2024-11-29 12:26:59 +00:00
committed by GitHub
parent fdbacbc22d
commit c8627cfd64
56 changed files with 401 additions and 199 deletions
@@ -7,14 +7,34 @@
import SwiftUI
extension LabelStyle where Self == MenuSheetLabelStyle {
/// A label style for labels that are within a menu that is being presented as a sheet.
static var menuSheet: Self { MenuSheetLabelStyle() }
extension ButtonStyle where Self == MenuSheetButtonStyle {
/// A button style for buttons that are within a menu that is being presented as a sheet.
static var menuSheet: Self { MenuSheetButtonStyle() }
}
/// The style used for labels that are part of a menu that's presented as
/// a sheet as `TimelineItemMenu` and `RoomAttachmentPicker`.
struct MenuSheetLabelStyle: LabelStyle {
/// The style used for buttons that are part of a menu that's presented as
/// a sheet such as `TimelineItemMenu`.
struct MenuSheetButtonStyle: ButtonStyle {
@Environment(\.accessibilityShowButtonShapes) private var accessibilityShowButtonShapes
func makeBody(configuration: Configuration) -> some View {
configuration.label
.labelStyle(MenuSheetLabelStyle())
.foregroundStyle(configuration.role == .destructive ? .compound.textCriticalPrimary : .compound.textActionPrimary)
.contentShape(.rect)
.opacity(configuration.isPressed ? 0.3 : 1)
.background {
if accessibilityShowButtonShapes {
RoundedRectangle(cornerRadius: 12)
.fill(Color(uiColor: .secondarySystemFill))
.opacity(configuration.isPressed ? 0.8 : 1)
.padding(4)
}
}
}
}
private struct MenuSheetLabelStyle: LabelStyle {
var spacing: CGFloat = 16
func makeBody(configuration: Configuration) -> some View {