mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 11:05:10 +00:00
fix: Hide FAB in new chat page if textfield has focus
This commit is contained in:
parent
56b83727b7
commit
3a37d41ba6
2 changed files with 23 additions and 2 deletions
|
@ -18,14 +18,34 @@ class NewPrivateChat extends StatefulWidget {
|
|||
}
|
||||
|
||||
class NewPrivateChatController extends State<NewPrivateChat> {
|
||||
TextEditingController controller = TextEditingController();
|
||||
final TextEditingController controller = TextEditingController();
|
||||
final FocusNode textFieldFocus = FocusNode();
|
||||
final formKey = GlobalKey<FormState>();
|
||||
bool loading = false;
|
||||
bool hideFab = false;
|
||||
|
||||
static const Set<String> supportedSigils = {'@', '!', '#'};
|
||||
|
||||
static const String prefix = 'https://matrix.to/#/';
|
||||
|
||||
void setHideFab() {
|
||||
if (textFieldFocus.hasFocus != hideFab) {
|
||||
setState(() => hideFab = textFieldFocus.hasFocus);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
textFieldFocus.addListener(setHideFab);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
textFieldFocus.removeListener(setHideFab);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void submitAction([_]) async {
|
||||
controller.text = controller.text.trim();
|
||||
if (!formKey.currentState.validate()) return;
|
||||
|
|
|
@ -81,6 +81,7 @@ class NewPrivateChatView extends StatelessWidget {
|
|||
controller: controller.controller,
|
||||
autocorrect: false,
|
||||
textInputAction: TextInputAction.go,
|
||||
focusNode: controller.textFieldFocus,
|
||||
onFieldSubmitted: controller.submitAction,
|
||||
validator: controller.validateForm,
|
||||
decoration: InputDecoration(
|
||||
|
@ -105,7 +106,7 @@ class NewPrivateChatView extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: PlatformInfos.isMobile
|
||||
floatingActionButton: PlatformInfos.isMobile && !controller.hideFab
|
||||
? FloatingActionButton.extended(
|
||||
onPressed: controller.openScannerAction,
|
||||
label: Text(L10n.of(context).scanQrCode),
|
||||
|
|
Loading…
Reference in a new issue