DESCRIPTION OF PROBLEM
We need to add an implementation that will have the same swipe/scroll behavior as the Apple Translator extension, here is the code that we are currently using:
import SwiftUI
import TranslationUIProvider
@main
class TranslationProviderExtension: TranslationUIProviderExtension {
required init() {}
var body: some TranslationUIProviderExtensionScene {
TranslationUIProviderSelectedTextScene { context in
VStack {
TranslationProviderView(context: context)
}
}
}
}
struct TranslationProviderView: View {
@State var context: TranslationUIProviderContext
init(context c: TranslationUIProviderContext) {
context = c
}
var body: some View {
ScrollableSheetView()
}
}
struct ScrollableSheetView: View {
var body: some View {
ScrollView {
VStack(spacing: 20) {
ForEach(0..<50) { index in
Text("Item (index)")
.padding()
.frame(maxWidth: .infinity)
.background(Color.blue.opacity(0.1))
.cornerRadius(8)
}
}
.padding()
}
.padding()
}
}
Using this code, on the first extension run, swipe up will expand the extension (which is OK) but swiping down on the expanded state of the extension works only as a scroll instead of swiping the extension from expanded mode back to compact mode.
STEPS TO REPRODUCE
Select a text in Safari
Tap on Translate in the contextual menu
Swipe up on the text ->the extension expands into full mode
Swipe down->only scrolls work, I cannot swipe the extension from full mode to compact mode.
Expected behavior: when i swipe down on the expanded extension, the extension should get into compact mode, not continuously scroll down.
Topic:
UI Frameworks
SubTopic:
SwiftUI