mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-28 17:08:29 +01:00
Merge pull request #1429 from srothgan/fix/1428-gym-mode-keyboard
Dismiss the number pad after saving a set in Gym Mode
This commit is contained in:
@@ -398,11 +398,14 @@ class _LogFormWidgetState extends ConsumerState<LogFormWidget> {
|
||||
// error handler; the success path below is then skipped. A page
|
||||
// logged before updates its row, and the PageView follows the
|
||||
// page change from the gym state.
|
||||
final inputFocus = FocusManager.instance.primaryFocus;
|
||||
await ref.read(gymStateProvider.notifier).logCurrentSet();
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
inputFocus?.unfocus();
|
||||
|
||||
showSnackbar(
|
||||
context,
|
||||
i18n.successfullySaved,
|
||||
|
||||
@@ -282,6 +282,42 @@ void main() {
|
||||
expect(captured[1], gymState.dayId);
|
||||
});
|
||||
|
||||
for (final fieldKey in ['logs-reps-widget', 'logs-weight-widget']) {
|
||||
testWidgets('save dismisses the keyboard after a successful write from $fieldKey', (
|
||||
tester,
|
||||
) async {
|
||||
final write = Completer<void>();
|
||||
when(
|
||||
mockWorkoutLogRepo.addLocalDrift(any, dayId: anyNamed('dayId')),
|
||||
).thenAnswer((_) => write.future);
|
||||
seedLogPage(testdata.getTestRoutine());
|
||||
await pumpLogPage(tester);
|
||||
|
||||
final field = find.descendant(
|
||||
of: find.byKey(ValueKey(fieldKey)),
|
||||
matching: find.byType(TextFormField),
|
||||
);
|
||||
await tester.enterText(field, '12');
|
||||
await tester.pump();
|
||||
final input = tester.widget<EditableText>(
|
||||
find.descendant(of: field, matching: find.byType(EditableText)),
|
||||
);
|
||||
expect(input.focusNode.hasFocus, isTrue);
|
||||
expect(tester.testTextInput.isVisible, isTrue);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('save-log-button')));
|
||||
await tester.pump();
|
||||
expect(input.focusNode.hasFocus, isTrue);
|
||||
expect(tester.testTextInput.isVisible, isTrue);
|
||||
|
||||
write.complete();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(input.focusNode.hasFocus, isFalse);
|
||||
expect(tester.testTextInput.isVisible, isFalse);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('carries the logged values over to the next set when sticky values are enabled', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user