mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user