From 43d76362697376a616bb958ab6ab3c0e1c2829b0 Mon Sep 17 00:00:00 2001 From: appflowy Date: Mon, 25 Oct 2021 19:25:58 +0800 Subject: [PATCH] [flutter]: auto focus if the document is empty --- .../presentation/stack_page/doc/doc_page.dart | 2 +- .../stack_page/doc/widget/toolbar/color_picker.dart | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app_flowy/lib/workspace/presentation/stack_page/doc/doc_page.dart b/app_flowy/lib/workspace/presentation/stack_page/doc/doc_page.dart index 247ed3e53a..4b8bdcc9de 100644 --- a/app_flowy/lib/workspace/presentation/stack_page/doc/doc_page.dart +++ b/app_flowy/lib/workspace/presentation/stack_page/doc/doc_page.dart @@ -73,7 +73,7 @@ class _DocPageState extends State { controller: controller, focusNode: _focusNode, scrollable: true, - autoFocus: false, + autoFocus: controller.document.isEmpty(), expands: false, padding: const EdgeInsets.symmetric(horizontal: 8.0), readOnly: false, diff --git a/app_flowy/lib/workspace/presentation/stack_page/doc/widget/toolbar/color_picker.dart b/app_flowy/lib/workspace/presentation/stack_page/doc/widget/toolbar/color_picker.dart index af5ba59615..5800fdaab8 100644 --- a/app_flowy/lib/workspace/presentation/stack_page/doc/widget/toolbar/color_picker.dart +++ b/app_flowy/lib/workspace/presentation/stack_page/doc/widget/toolbar/color_picker.dart @@ -83,13 +83,6 @@ class _FlowyColorButtonState extends State { @override Widget build(BuildContext context) { final theme = Theme.of(context); - final iconColor = _isToggledColor && !widget.background && !_isWhite - ? stringToColor(_selectionStyle.attributes['color']!.value) - : (widget.iconTheme?.iconUnselectedColor ?? theme.iconTheme.color); - - final iconColorBackground = _isToggledBackground && widget.background && !_isWhitebackground - ? stringToColor(_selectionStyle.attributes['background']!.value) - : (widget.iconTheme?.iconUnselectedColor ?? theme.iconTheme.color); final fillColor = _isToggledColor && !widget.background && _isWhite ? stringToColor('#ffffff') @@ -102,7 +95,7 @@ class _FlowyColorButtonState extends State { highlightElevation: 0, hoverElevation: 0, size: widget.iconSize * kIconButtonFactor, - icon: Icon(widget.icon, size: widget.iconSize, color: widget.background ? iconColorBackground : iconColor), + icon: Icon(widget.icon, size: widget.iconSize, color: theme.iconTheme.color), fillColor: widget.background ? fillColorBackground : fillColor, onPressed: _showColorPicker, ); @@ -168,7 +161,6 @@ class FlowyColorPicker extends StatefulWidget { 0xfff5ffdc, 0xffddffd6, 0xffdefff1, - 0xffdefff1, ]; final Function(Color?) onColorChanged; final int initailColor;