-
Notifications
You must be signed in to change notification settings - Fork 28.7k
The timing of the Haptic Feedback triggered by CupertinoPicker is incorrect. #169606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
a: fidelity
Matching the OEM platforms better
f: cupertino
flutter/packages/flutter/cupertino repository
found in release: 3.32
Found to occur in 3.32
found in release: 3.33
Found to occur in 3.33
framework
flutter/packages/flutter repository. See also f: labels.
has reproducible steps
The issue has been confirmed reproducible and is ready to work on
team-design
Owned by Design Languages team
Comments
Reproducible using the code sample provided above. As noted above, compared to swiftui, flutter's selection is too fast. In SwiftUI, selection only happens when I let go of the selection unlike flutter which changes the moment a new item sort of comes into focus. The haptic feedback time in flutter is also too fast as compared to swiftui.
swiftui sampleimport SwiftUI
struct ContentView: View {
@State private var selectedFruitIndex: Int = 0
@State private var showingFruitPicker: Bool = false
let fruitNames: [String] = [
"Apple",
"Mango",
"Banana",
"Orange",
"Pineapple",
"Strawberry",
]
var body: some View {
NavigationView {
VStack {
Text("Selected fruit: ")
// Button to trigger the display of the fruit picker
Button(action: {
showingFruitPicker.toggle()
}) {
Text(fruitNames[selectedFruitIndex])
.font(.title3)
.padding(.vertical, 5)
.padding(.horizontal, 10)
.background(Capsule().stroke(Color.blue, lineWidth: 1))
.foregroundColor(.blue)
}
}
.navigationTitle("Fruit Picker Sample")
.sheet(isPresented: $showingFruitPicker) {
// The custom fruit picker view presented as a sheet
FruitPickerView(selectedFruitIndex: $selectedFruitIndex, fruitNames: fruitNames, showingFruitPicker: $showingFruitPicker)
// Customize the presentation detents to mimic CupertinoModalPopup height
.presentationDetents([.height(250)])
}
}
}
}
// Custom View for the Fruit Picker, mimicking the CupertinoPicker style
struct FruitPickerView: View {
@Binding var selectedFruitIndex: Int
let fruitNames: [String]
@Binding var showingFruitPicker: Bool
var body: some View {
VStack {
// Optional: A "Done" button to dismiss the picker
HStack {
Spacer()
Button("Done") {
showingFruitPicker = false
}
.padding()
}
// The SwiftUI Picker, styled to look like CupertinoPicker
Picker("Fruits", selection: $selectedFruitIndex) {
ForEach(0..<fruitNames.count, id: \.self) { index in
Text(fruitNames[index]).tag(index)
}
}
.pickerStyle(.wheel) // This provides the spinning wheel effect
.labelsHidden() // Hide the default label for a cleaner look
}
}
}
// MARK: - Preview
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
} flutter doctor -v
|
The timing of HapticFeedback also varies. |
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
a: fidelity
Matching the OEM platforms better
f: cupertino
flutter/packages/flutter/cupertino repository
found in release: 3.32
Found to occur in 3.32
found in release: 3.33
Found to occur in 3.33
framework
flutter/packages/flutter repository. See also f: labels.
has reproducible steps
The issue has been confirmed reproducible and is ready to work on
team-design
Owned by Design Languages team
Uh oh!
There was an error while loading. Please reload this page.
Steps to reproduce
Scroll
CupertinoPicker
and feel the Haptic Feedback on iPhone.Expected results
Haptic Feedback should be triggered at the position where an item is selected.
BTW, the
onSelectedItemChanged
should get the value only when the scrolling settles, use aNotificationListener
, listen forScrollEndNotification
and read its FixedExtentMetrics.(ref #92644)Actual results
Haptic Feedback will be triggered at the mid-position between two items.
Code sample
Code sample
The text was updated successfully, but these errors were encountered: