chore: Hide FAB story buttons on focus

This commit is contained in:
Christian Pauly 2022-02-11 22:50:20 +01:00
parent f8a82c96da
commit 87a60feb63
4 changed files with 39 additions and 32 deletions

View File

@ -27,6 +27,7 @@ class AddStoryPage extends StatefulWidget {
class AddStoryController extends State<AddStoryPage> { class AddStoryController extends State<AddStoryPage> {
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
final FocusNode focusNode = FocusNode();
late Color backgroundColor; late Color backgroundColor;
late Color backgroundColorDark; late Color backgroundColorDark;
MatrixImageFile? image; MatrixImageFile? image;
@ -38,6 +39,8 @@ class AddStoryController extends State<AddStoryPage> {
bool hasText = false; bool hasText = false;
bool textFieldHasFocus = false;
Timer? _updateColorsCooldown; Timer? _updateColorsCooldown;
void updateColors() { void updateColors() {
@ -167,6 +170,13 @@ class AddStoryController extends State<AddStoryPage> {
final text = Matrix.of(context).client.userID!; final text = Matrix.of(context).client.userID!;
backgroundColor = text.color; backgroundColor = text.color;
backgroundColorDark = text.darkColor; backgroundColorDark = text.darkColor;
focusNode.addListener(() {
if (textFieldHasFocus != focusNode.hasFocus) {
setState(() {
textFieldHasFocus = focusNode.hasFocus;
});
}
});
final shareContent = Matrix.of(context).shareContent; final shareContent = Matrix.of(context).shareContent;
if (shareContent != null) { if (shareContent != null) {

View File

@ -80,10 +80,11 @@ class AddStoryView extends StatelessWidget {
child: Center( child: Center(
child: TextField( child: TextField(
controller: controller.controller, controller: controller.controller,
focusNode: controller.focusNode,
minLines: 1, minLines: 1,
maxLines: 15, maxLines: 15,
maxLength: 500, maxLength: 500,
autofocus: true, autofocus: false,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 24, fontSize: 24,
@ -114,6 +115,7 @@ class AddStoryView extends StatelessWidget {
floatingActionButton: Column( floatingActionButton: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
if (!controller.hasMedia && !controller.textFieldHasFocus) ...[
FloatingActionButton( FloatingActionButton(
onPressed: controller.captureVideo, onPressed: controller.captureVideo,
backgroundColor: controller.backgroundColorDark, backgroundColor: controller.backgroundColorDark,
@ -137,6 +139,7 @@ class AddStoryView extends StatelessWidget {
heroTag: null, heroTag: null,
child: const Icon(Icons.photo_outlined), child: const Icon(Icons.photo_outlined),
), ),
],
if (controller.hasMedia || controller.hasText) ...[ if (controller.hasMedia || controller.hasText) ...[
const SizedBox(height: 16), const SizedBox(height: 16),
FloatingActionButton( FloatingActionButton(

View File

@ -7,6 +7,7 @@ import Foundation
import audioplayers import audioplayers
import desktop_drop import desktop_drop
import emoji_picker_flutter
import file_selector_macos import file_selector_macos
import flutter_local_notifications import flutter_local_notifications
import flutter_secure_storage_macos import flutter_secure_storage_macos
@ -23,6 +24,7 @@ import wakelock_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioplayersPlugin.register(with: registry.registrar(forPlugin: "AudioplayersPlugin")) AudioplayersPlugin.register(with: registry.registrar(forPlugin: "AudioplayersPlugin"))
DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin")) DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin"))
EmojiPickerFlutterPlugin.register(with: registry.registrar(forPlugin: "EmojiPickerFlutterPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
FlutterSecureStorageMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStorageMacosPlugin")) FlutterSecureStorageMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStorageMacosPlugin"))

View File

@ -9,9 +9,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_windows url_launcher_windows
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES) set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST}) foreach(plugin ${FLUTTER_PLUGIN_LIST})
@ -20,8 +17,3 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>) list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin) 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)