Skip to content

Commit

Permalink
feat(keyboard): implement in app keyboard
Browse files Browse the repository at this point in the history
Signed-off-by: Vatsal Gandhi <gandhivatsal17@gmail.com>
  • Loading branch information
vatsal201 authored and singhtaranjeet committed Aug 16, 2024
1 parent 6f5883a commit 25cd2e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import 'package:flutter/material.dart';

class KeyboardController {
final _keyboardInputSubject = PublishSubject<String?>();

Stream<String?> get keyboardInput => _keyboardInputSubject.stream;

void setKeyboardInput(String? input) => _keyboardInputSubject.add(input);

final _showKeyboardSubject = BehaviorSubject<bool>.seeded(false);
Stream<bool> get showKeyboard => _showKeyboardSubject.stream;
void toggleKeyboardVisibility(value) => _showKeyboardSubject.add(value);

void dispose() {
_keyboardInputSubject.close();
_showKeyboardSubject.close();
}
}

Expand Down
4 changes: 4 additions & 0 deletions lib/src/modules/order/widgets/qty_input_text_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ class _QtyInputTextBoxState extends State<QtyInputTextBox> {
return;
}
if (isFocused) {
toggleKeyboardVisibility(true);
FocusManager.instance.primaryFocus?.unfocus();
FocusScope.of(context).requestFocus(_focusNode);
_subscribeToKeyboardEvents();
Expand All @@ -297,6 +298,9 @@ class _QtyInputTextBoxState extends State<QtyInputTextBox> {
}
}

void toggleKeyboardVisibility(value) =>
widget.keyboardController?.toggleKeyboardVisibility(value);

String? _validateText(String? value) {
if (widget.maxValue == null && widget.minValue == null) {
return null;
Expand Down

0 comments on commit 25cd2e2

Please sign in to comment.