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> {
|
class NewPrivateChatController extends State<NewPrivateChat> {
|
||||||
TextEditingController controller = TextEditingController();
|
final TextEditingController controller = TextEditingController();
|
||||||
|
final FocusNode textFieldFocus = FocusNode();
|
||||||
final formKey = GlobalKey<FormState>();
|
final formKey = GlobalKey<FormState>();
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
|
bool hideFab = false;
|
||||||
|
|
||||||
static const Set<String> supportedSigils = {'@', '!', '#'};
|
static const Set<String> supportedSigils = {'@', '!', '#'};
|
||||||
|
|
||||||
static const String prefix = 'https://matrix.to/#/';
|
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 {
|
void submitAction([_]) async {
|
||||||
controller.text = controller.text.trim();
|
controller.text = controller.text.trim();
|
||||||
if (!formKey.currentState.validate()) return;
|
if (!formKey.currentState.validate()) return;
|
||||||
|
@ -81,6 +81,7 @@ class NewPrivateChatView extends StatelessWidget {
|
|||||||
controller: controller.controller,
|
controller: controller.controller,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
textInputAction: TextInputAction.go,
|
textInputAction: TextInputAction.go,
|
||||||
|
focusNode: controller.textFieldFocus,
|
||||||
onFieldSubmitted: controller.submitAction,
|
onFieldSubmitted: controller.submitAction,
|
||||||
validator: controller.validateForm,
|
validator: controller.validateForm,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@ -105,7 +106,7 @@ class NewPrivateChatView extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: PlatformInfos.isMobile
|
floatingActionButton: PlatformInfos.isMobile && !controller.hideFab
|
||||||
? FloatingActionButton.extended(
|
? FloatingActionButton.extended(
|
||||||
onPressed: controller.openScannerAction,
|
onPressed: controller.openScannerAction,
|
||||||
label: Text(L10n.of(context).scanQrCode),
|
label: Text(L10n.of(context).scanQrCode),
|
||||||
|
Loading…
Reference in New Issue
Block a user