From 87a60feb6381aaad689584a116220c5bb5785330 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Fri, 11 Feb 2022 22:50:20 +0100 Subject: [PATCH] chore: Hide FAB story buttons on focus --- lib/pages/add_story/add_story.dart | 10 ++++ lib/pages/add_story/add_story_view.dart | 51 ++++++++++--------- macos/Flutter/GeneratedPluginRegistrant.swift | 2 + windows/flutter/generated_plugins.cmake | 8 --- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/lib/pages/add_story/add_story.dart b/lib/pages/add_story/add_story.dart index 117b725d..cdf6d0d2 100644 --- a/lib/pages/add_story/add_story.dart +++ b/lib/pages/add_story/add_story.dart @@ -27,6 +27,7 @@ class AddStoryPage extends StatefulWidget { class AddStoryController extends State { final TextEditingController controller = TextEditingController(); + final FocusNode focusNode = FocusNode(); late Color backgroundColor; late Color backgroundColorDark; MatrixImageFile? image; @@ -38,6 +39,8 @@ class AddStoryController extends State { bool hasText = false; + bool textFieldHasFocus = false; + Timer? _updateColorsCooldown; void updateColors() { @@ -167,6 +170,13 @@ class AddStoryController extends State { final text = Matrix.of(context).client.userID!; backgroundColor = text.color; backgroundColorDark = text.darkColor; + focusNode.addListener(() { + if (textFieldHasFocus != focusNode.hasFocus) { + setState(() { + textFieldHasFocus = focusNode.hasFocus; + }); + } + }); final shareContent = Matrix.of(context).shareContent; if (shareContent != null) { diff --git a/lib/pages/add_story/add_story_view.dart b/lib/pages/add_story/add_story_view.dart index bdf942b7..eda2034f 100644 --- a/lib/pages/add_story/add_story_view.dart +++ b/lib/pages/add_story/add_story_view.dart @@ -80,10 +80,11 @@ class AddStoryView extends StatelessWidget { child: Center( child: TextField( controller: controller.controller, + focusNode: controller.focusNode, minLines: 1, maxLines: 15, maxLength: 500, - autofocus: true, + autofocus: false, textAlign: TextAlign.center, style: TextStyle( fontSize: 24, @@ -114,29 +115,31 @@ class AddStoryView extends StatelessWidget { floatingActionButton: Column( mainAxisSize: MainAxisSize.min, children: [ - FloatingActionButton( - onPressed: controller.captureVideo, - backgroundColor: controller.backgroundColorDark, - foregroundColor: Colors.white, - heroTag: null, - child: const Icon(Icons.video_camera_front_outlined), - ), - const SizedBox(height: 16), - FloatingActionButton( - onPressed: controller.capturePhoto, - backgroundColor: controller.backgroundColorDark, - foregroundColor: Colors.white, - heroTag: null, - child: const Icon(Icons.camera_alt_outlined), - ), - const SizedBox(height: 16), - FloatingActionButton( - onPressed: controller.importMedia, - backgroundColor: controller.backgroundColorDark, - foregroundColor: Colors.white, - heroTag: null, - child: const Icon(Icons.photo_outlined), - ), + if (!controller.hasMedia && !controller.textFieldHasFocus) ...[ + FloatingActionButton( + onPressed: controller.captureVideo, + backgroundColor: controller.backgroundColorDark, + foregroundColor: Colors.white, + heroTag: null, + child: const Icon(Icons.video_camera_front_outlined), + ), + const SizedBox(height: 16), + FloatingActionButton( + onPressed: controller.capturePhoto, + backgroundColor: controller.backgroundColorDark, + foregroundColor: Colors.white, + heroTag: null, + child: const Icon(Icons.camera_alt_outlined), + ), + const SizedBox(height: 16), + FloatingActionButton( + onPressed: controller.importMedia, + backgroundColor: controller.backgroundColorDark, + foregroundColor: Colors.white, + heroTag: null, + child: const Icon(Icons.photo_outlined), + ), + ], if (controller.hasMedia || controller.hasText) ...[ const SizedBox(height: 16), FloatingActionButton( diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index d7158b13..27e8d3b0 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,6 +7,7 @@ import Foundation import audioplayers import desktop_drop +import emoji_picker_flutter import file_selector_macos import flutter_local_notifications import flutter_secure_storage_macos @@ -23,6 +24,7 @@ import wakelock_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { AudioplayersPlugin.register(with: registry.registrar(forPlugin: "AudioplayersPlugin")) DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin")) + EmojiPickerFlutterPlugin.register(with: registry.registrar(forPlugin: "EmojiPickerFlutterPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) FlutterSecureStorageMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStorageMacosPlugin")) diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index f4b94444..acf95a15 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -9,9 +9,6 @@ list(APPEND FLUTTER_PLUGIN_LIST url_launcher_windows ) -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -20,8 +17,3 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin)