mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 14:59:29 +01:00
fix: Hide FAB in new chat page if textfield has focus
This commit is contained in:
parent
fcc41a8d1d
commit
eb429267b1
@ -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 New Issue
Block a user