mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add quote and copy context menu actions.
This commit is contained in:
@@ -129,9 +129,9 @@ private struct UITextViewWrapper: UIViewRepresentable {
|
||||
self.maxHeight = maxHeight
|
||||
}
|
||||
|
||||
func textViewDidChange(_ uiView: UITextView) {
|
||||
text.wrappedValue = uiView.text
|
||||
UITextViewWrapper.recalculateHeight(view: uiView,
|
||||
func textViewDidChange(_ textView: UITextView) {
|
||||
text.wrappedValue = textView.text
|
||||
UITextViewWrapper.recalculateHeight(view: textView,
|
||||
result: calculatedHeight,
|
||||
maxHeight: maxHeight)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// TimelineItemContextMenu.swift
|
||||
// ElementX
|
||||
//
|
||||
// Created by Stefan Ceriu on 18/04/2022.
|
||||
// Copyright © 2022 element.io. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
public struct TimelineItemContextMenu: View {
|
||||
|
||||
let contextMenuActions: [TimelineItemContextMenuAction]
|
||||
let callback: (TimelineItemContextMenuAction) -> Void
|
||||
|
||||
@ViewBuilder
|
||||
public var body: some View {
|
||||
ForEach(contextMenuActions, id: \.self) { item in
|
||||
switch item {
|
||||
case .copy:
|
||||
Button("Copy") {
|
||||
callback(item)
|
||||
}
|
||||
case .quote:
|
||||
Button("Quote") {
|
||||
callback(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,9 @@ struct TimelineItemList: View {
|
||||
// No idea why previews don't work otherwise
|
||||
ForEach(isPreview ? context.viewState.items : timelineItems) { timelineItem in
|
||||
timelineItem
|
||||
.contextMenu(menuItems: {
|
||||
context.viewState.contextMenuBuilder?(timelineItem.id)
|
||||
})
|
||||
.listRowSeparator(.hidden)
|
||||
.onAppear {
|
||||
context.send(viewAction: .itemAppeared(id: timelineItem.id))
|
||||
|
||||
Reference in New Issue
Block a user