From 410d150360d4f4df8078a1bc17735cb0512317b8 Mon Sep 17 00:00:00 2001 From: appflowy Date: Wed, 31 Aug 2022 09:28:08 +0800 Subject: [PATCH] chore: adjust flutter lint 2.0 --- .../app_flowy/lib/core/frameless_window.dart | 7 +- .../doc/presentation/style_widgets.dart | 13 ++-- .../presentation/toolbar/check_button.dart | 4 +- .../presentation/toolbar/color_picker.dart | 64 ++++++++++++------- .../presentation/toolbar/header_button.dart | 19 ++++-- .../doc/presentation/toolbar/link_button.dart | 8 ++- .../presentation/toolbar/toggle_button.dart | 8 ++- .../doc/presentation/toolbar/tool_bar.dart | 17 +++-- .../cell/select_option_editor_bloc.dart | 6 +- .../widgets/header/type_option/number.dart | 4 +- .../lib/user/presentation/router.dart | 19 ++++-- .../markdown/src/inline_parser.dart | 19 +++--- .../presentation/home/home_stack.dart | 4 +- .../widgets/edit_panel/panel_animation.dart | 4 +- .../src/default_emoji_picker_view.dart | 59 +++++++++++------ .../emoji_picker/src/emoji_button.dart | 4 +- .../emoji_picker/src/emoji_picker.dart | 62 ++++++++++++------ .../presentation/widgets/pop_up_window.dart | 6 +- frontend/app_flowy/pubspec.yaml | 7 ++ 19 files changed, 219 insertions(+), 115 deletions(-) diff --git a/frontend/app_flowy/lib/core/frameless_window.dart b/frontend/app_flowy/lib/core/frameless_window.dart index a7d6417cd3..3641aeef4d 100644 --- a/frontend/app_flowy/lib/core/frameless_window.dart +++ b/frontend/app_flowy/lib/core/frameless_window.dart @@ -31,10 +31,10 @@ class MoveWindowDetector extends StatefulWidget { final Widget? child; @override - _MoveWindowDetectorState createState() => _MoveWindowDetectorState(); + MoveWindowDetectorState createState() => MoveWindowDetectorState(); } -class _MoveWindowDetectorState extends State { +class MoveWindowDetectorState extends State { double winX = 0; double winY = 0; @@ -59,7 +59,8 @@ class _MoveWindowDetectorState extends State { final double dy = windowPos[1]; final deltaX = details.globalPosition.dx - winX; final deltaY = details.globalPosition.dy - winY; - await CocoaWindowChannel.instance.setWindowPosition(Offset(dx + deltaX, dy - deltaY)); + await CocoaWindowChannel.instance + .setWindowPosition(Offset(dx + deltaX, dy - deltaY)); }, child: widget.child, ); diff --git a/frontend/app_flowy/lib/plugins/doc/presentation/style_widgets.dart b/frontend/app_flowy/lib/plugins/doc/presentation/style_widgets.dart index 4f09b64053..8bbd5bc0d0 100644 --- a/frontend/app_flowy/lib/plugins/doc/presentation/style_widgets.dart +++ b/frontend/app_flowy/lib/plugins/doc/presentation/style_widgets.dart @@ -16,7 +16,10 @@ class EditorCheckboxBuilder extends QuillCheckboxBuilder { EditorCheckboxBuilder(this.theme); @override - Widget build({required BuildContext context, required bool isChecked, required ValueChanged onChanged}) { + Widget build( + {required BuildContext context, + required bool isChecked, + required ValueChanged onChanged}) { return FlowyEditorCheckbox( theme: theme, isChecked: isChecked, @@ -37,10 +40,10 @@ class FlowyEditorCheckbox extends StatefulWidget { }) : super(key: key); @override - _FlowyEditorCheckboxState createState() => _FlowyEditorCheckboxState(); + FlowyEditorCheckboxState createState() => FlowyEditorCheckboxState(); } -class _FlowyEditorCheckboxState extends State { +class FlowyEditorCheckboxState extends State { late bool isChecked; @override @@ -51,7 +54,9 @@ class _FlowyEditorCheckboxState extends State { @override Widget build(BuildContext context) { - final icon = isChecked ? svgWidget('editor/editor_check') : svgWidget('editor/editor_uncheck'); + final icon = isChecked + ? svgWidget('editor/editor_check') + : svgWidget('editor/editor_uncheck'); return Align( alignment: Alignment.centerLeft, child: FlowyIconButton( diff --git a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/check_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/check_button.dart index 55f17ac558..280209c64a 100644 --- a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/check_button.dart +++ b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/check_button.dart @@ -28,10 +28,10 @@ class FlowyCheckListButton extends StatefulWidget { final String tooltipText; @override - _FlowyCheckListButtonState createState() => _FlowyCheckListButtonState(); + FlowyCheckListButtonState createState() => FlowyCheckListButtonState(); } -class _FlowyCheckListButtonState extends State { +class FlowyCheckListButtonState extends State { bool? _isToggled; Style get _selectionStyle => widget.controller.getSelectionStyle(); diff --git a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/color_picker.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/color_picker.dart index 57299bd6cc..1f262483a8 100644 --- a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/color_picker.dart +++ b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/color_picker.dart @@ -24,10 +24,10 @@ class FlowyColorButton extends StatefulWidget { final QuillIconTheme? iconTheme; @override - _FlowyColorButtonState createState() => _FlowyColorButtonState(); + FlowyColorButtonState createState() => FlowyColorButtonState(); } -class _FlowyColorButtonState extends State { +class FlowyColorButtonState extends State { late bool _isToggledColor; late bool _isToggledBackground; late bool _isWhite; @@ -37,10 +37,14 @@ class _FlowyColorButtonState extends State { void _didChangeEditingValue() { setState(() { - _isToggledColor = _getIsToggledColor(widget.controller.getSelectionStyle().attributes); - _isToggledBackground = _getIsToggledBackground(widget.controller.getSelectionStyle().attributes); - _isWhite = _isToggledColor && _selectionStyle.attributes['color']!.value == '#ffffff'; - _isWhitebackground = _isToggledBackground && _selectionStyle.attributes['background']!.value == '#ffffff'; + _isToggledColor = + _getIsToggledColor(widget.controller.getSelectionStyle().attributes); + _isToggledBackground = _getIsToggledBackground( + widget.controller.getSelectionStyle().attributes); + _isWhite = _isToggledColor && + _selectionStyle.attributes['color']!.value == '#ffffff'; + _isWhitebackground = _isToggledBackground && + _selectionStyle.attributes['background']!.value == '#ffffff'; }); } @@ -49,8 +53,10 @@ class _FlowyColorButtonState extends State { super.initState(); _isToggledColor = _getIsToggledColor(_selectionStyle.attributes); _isToggledBackground = _getIsToggledBackground(_selectionStyle.attributes); - _isWhite = _isToggledColor && _selectionStyle.attributes['color']!.value == '#ffffff'; - _isWhitebackground = _isToggledBackground && _selectionStyle.attributes['background']!.value == '#ffffff'; + _isWhite = _isToggledColor && + _selectionStyle.attributes['color']!.value == '#ffffff'; + _isWhitebackground = _isToggledBackground && + _selectionStyle.attributes['background']!.value == '#ffffff'; widget.controller.addListener(_didChangeEditingValue); } @@ -69,9 +75,12 @@ class _FlowyColorButtonState extends State { oldWidget.controller.removeListener(_didChangeEditingValue); widget.controller.addListener(_didChangeEditingValue); _isToggledColor = _getIsToggledColor(_selectionStyle.attributes); - _isToggledBackground = _getIsToggledBackground(_selectionStyle.attributes); - _isWhite = _isToggledColor && _selectionStyle.attributes['color']!.value == '#ffffff'; - _isWhitebackground = _isToggledBackground && _selectionStyle.attributes['background']!.value == '#ffffff'; + _isToggledBackground = + _getIsToggledBackground(_selectionStyle.attributes); + _isWhite = _isToggledColor && + _selectionStyle.attributes['color']!.value == '#ffffff'; + _isWhitebackground = _isToggledBackground && + _selectionStyle.attributes['background']!.value == '#ffffff'; } } @@ -88,9 +97,10 @@ class _FlowyColorButtonState extends State { final fillColor = _isToggledColor && !widget.background && _isWhite ? stringToColor('#ffffff') : (widget.iconTheme?.iconUnselectedFillColor ?? theme.canvasColor); - final fillColorBackground = _isToggledBackground && widget.background && _isWhitebackground - ? stringToColor('#ffffff') - : (widget.iconTheme?.iconUnselectedFillColor ?? theme.canvasColor); + final fillColorBackground = + _isToggledBackground && widget.background && _isWhitebackground + ? stringToColor('#ffffff') + : (widget.iconTheme?.iconUnselectedFillColor ?? theme.canvasColor); return Tooltip( message: LocaleKeys.toolbar_highlight.tr(), @@ -99,7 +109,8 @@ class _FlowyColorButtonState extends State { highlightElevation: 0, hoverElevation: 0, size: widget.iconSize * kIconButtonFactor, - icon: Icon(widget.icon, size: widget.iconSize, color: theme.iconTheme.color), + icon: Icon(widget.icon, + size: widget.iconSize, color: theme.iconTheme.color), fillColor: widget.background ? fillColorBackground : fillColor, onPressed: _showColorPicker, ), @@ -112,13 +123,16 @@ class _FlowyColorButtonState extends State { hex = hex.substring(2); } hex = '#$hex'; - widget.controller.formatSelection(widget.background ? BackgroundAttribute(hex) : ColorAttribute(hex)); + widget.controller.formatSelection( + widget.background ? BackgroundAttribute(hex) : ColorAttribute(hex)); Navigator.of(context).pop(); } void _showColorPicker() { final style = widget.controller.getSelectionStyle(); - final values = style.values.where((v) => v.key == Attribute.background.key).map((v) => v.value); + final values = style.values + .where((v) => v.key == Attribute.background.key) + .map((v) => v.value); int initialColor = 0; if (values.isNotEmpty) { assert(values.length == 1); @@ -160,7 +174,9 @@ class FlowyColorPicker extends StatefulWidget { ]; final Function(Color?) onColorChanged; final int initialColor; - FlowyColorPicker({Key? key, required this.onColorChanged, this.initialColor = 0}) : super(key: key); + FlowyColorPicker( + {Key? key, required this.onColorChanged, this.initialColor = 0}) + : super(key: key); @override State createState() => _FlowyColorPickerState(); @@ -178,8 +194,10 @@ class _FlowyColorPickerState extends State { const double crossAxisSpacing = 10; final numberOfRows = (widget.colors.length / crossAxisCount).ceil(); - const perRowHeight = ((width - ((crossAxisCount - 1) * mainAxisSpacing)) / crossAxisCount); - final totalHeight = numberOfRows * perRowHeight + numberOfRows * crossAxisSpacing; + const perRowHeight = + ((width - ((crossAxisCount - 1) * mainAxisSpacing)) / crossAxisCount); + final totalHeight = + numberOfRows * perRowHeight + numberOfRows * crossAxisSpacing; return Container( constraints: BoxConstraints.tightFor(width: width, height: totalHeight), @@ -198,7 +216,8 @@ class _FlowyColorPickerState extends State { delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { if (widget.colors.length > index) { - final isSelected = widget.colors[index] == widget.initialColor; + final isSelected = + widget.colors[index] == widget.initialColor; return ColorItem( color: Color(widget.colors[index]), onPressed: widget.onColorChanged, @@ -242,7 +261,8 @@ class ColorItem extends StatelessWidget { ); } else { return RawMaterialButton( - shape: const CircleBorder(side: BorderSide(color: Colors.white, width: 8)) + + shape: const CircleBorder( + side: BorderSide(color: Colors.white, width: 8)) + CircleBorder(side: BorderSide(color: color, width: 4)), onPressed: () { if (isSelected) { diff --git a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/header_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/header_button.dart index 2da700df47..2db98b5af0 100644 --- a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/header_button.dart +++ b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/header_button.dart @@ -16,10 +16,10 @@ class FlowyHeaderStyleButton extends StatefulWidget { final double iconSize; @override - _FlowyHeaderStyleButtonState createState() => _FlowyHeaderStyleButtonState(); + FlowyHeaderStyleButtonState createState() => FlowyHeaderStyleButtonState(); } -class _FlowyHeaderStyleButtonState extends State { +class FlowyHeaderStyleButtonState extends State { Attribute? _value; Style get _selectionStyle => widget.controller.getSelectionStyle(); @@ -28,7 +28,8 @@ class _FlowyHeaderStyleButtonState extends State { void initState() { super.initState(); setState(() { - _value = _selectionStyle.attributes[Attribute.header.key] ?? Attribute.header; + _value = + _selectionStyle.attributes[Attribute.header.key] ?? Attribute.header; }); widget.controller.addListener(_didChangeEditingValue); } @@ -41,7 +42,11 @@ class _FlowyHeaderStyleButtonState extends State { Attribute.h3: 'H3', }; - final valueAttribute = [Attribute.h1, Attribute.h2, Attribute.h3]; + final valueAttribute = [ + Attribute.h1, + Attribute.h2, + Attribute.h3 + ]; final valueString = ['H1', 'H2', 'H3']; final attributeImageName = ['editor/H1', 'editor/H2', 'editor/H3']; @@ -72,7 +77,8 @@ class _FlowyHeaderStyleButtonState extends State { void _didChangeEditingValue() { setState(() { - _value = _selectionStyle.attributes[Attribute.header.key] ?? Attribute.header; + _value = + _selectionStyle.attributes[Attribute.header.key] ?? Attribute.header; }); } @@ -82,7 +88,8 @@ class _FlowyHeaderStyleButtonState extends State { if (oldWidget.controller != widget.controller) { oldWidget.controller.removeListener(_didChangeEditingValue); widget.controller.addListener(_didChangeEditingValue); - _value = _selectionStyle.attributes[Attribute.header.key] ?? Attribute.header; + _value = + _selectionStyle.attributes[Attribute.header.key] ?? Attribute.header; } } diff --git a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/link_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/link_button.dart index 60b654302f..428c45e400 100644 --- a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/link_button.dart +++ b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/link_button.dart @@ -19,10 +19,10 @@ class FlowyLinkStyleButton extends StatefulWidget { final double iconSize; @override - _FlowyLinkStyleButtonState createState() => _FlowyLinkStyleButtonState(); + FlowyLinkStyleButtonState createState() => FlowyLinkStyleButtonState(); } -class _FlowyLinkStyleButtonState extends State { +class FlowyLinkStyleButtonState extends State { void _didChangeSelection() { setState(() {}); } @@ -75,7 +75,9 @@ class _FlowyLinkStyleButtonState extends State { void _openLinkDialog(BuildContext context) { final style = widget.controller.getSelectionStyle(); - final values = style.values.where((v) => v.key == Attribute.link.key).map((v) => v.value); + final values = style.values + .where((v) => v.key == Attribute.link.key) + .map((v) => v.value); String value = ""; if (values.isNotEmpty) { assert(values.length == 1); diff --git a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toggle_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toggle_button.dart index 89fd72981d..2ecb98c3ea 100644 --- a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toggle_button.dart +++ b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toggle_button.dart @@ -21,10 +21,10 @@ class FlowyToggleStyleButton extends StatefulWidget { }) : super(key: key); @override - _ToggleStyleButtonState createState() => _ToggleStyleButtonState(); + ToggleStyleButtonState createState() => ToggleStyleButtonState(); } -class _ToggleStyleButtonState extends State { +class ToggleStyleButtonState extends State { bool? _isToggled; Style get _selectionStyle => widget.controller.getSelectionStyle(); @override @@ -77,6 +77,8 @@ class _ToggleStyleButtonState extends State { } void _toggleAttribute() { - widget.controller.formatSelection(_isToggled! ? Attribute.clone(widget.attribute, null) : widget.attribute); + widget.controller.formatSelection(_isToggled! + ? Attribute.clone(widget.attribute, null) + : widget.attribute); } } diff --git a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/tool_bar.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/tool_bar.dart index 8dae41f986..d649340066 100644 --- a/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/tool_bar.dart +++ b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/tool_bar.dart @@ -32,7 +32,8 @@ class EditorToolbar extends StatelessWidget implements PreferredSizeWidget { return Container( color: Theme.of(context).canvasColor, constraints: BoxConstraints.tightFor(height: preferredSize.height), - child: ToolbarButtonList(buttons: children).padding(horizontal: 4, vertical: 4), + child: ToolbarButtonList(buttons: children) + .padding(horizontal: 4, vertical: 4), ); } @@ -168,10 +169,11 @@ class ToolbarButtonList extends StatefulWidget { final List buttons; @override - _ToolbarButtonListState createState() => _ToolbarButtonListState(); + ToolbarButtonListState createState() => ToolbarButtonListState(); } -class _ToolbarButtonListState extends State with WidgetsBindingObserver { +class ToolbarButtonListState extends State + with WidgetsBindingObserver { final ScrollController _controller = ScrollController(); bool _showLeftArrow = false; bool _showRightArrow = false; @@ -196,7 +198,8 @@ class _ToolbarButtonListState extends State with WidgetsBindi return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { List children = []; - double width = (widget.buttons.length + 2) * defaultIconSize * kIconButtonFactor; + double width = + (widget.buttons.length + 2) * defaultIconSize * kIconButtonFactor; final isFit = constraints.maxWidth > width; if (!isFit) { children.add(_buildLeftArrow()); @@ -233,8 +236,10 @@ class _ToolbarButtonListState extends State with WidgetsBindi void _handleScroll() { if (!mounted) return; setState(() { - _showLeftArrow = _controller.position.minScrollExtent != _controller.position.pixels; - _showRightArrow = _controller.position.maxScrollExtent != _controller.position.pixels; + _showLeftArrow = + _controller.position.minScrollExtent != _controller.position.pixels; + _showRightArrow = + _controller.position.maxScrollExtent != _controller.position.pixels; }); } diff --git a/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart index 8d52252e2a..349d95d13f 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart @@ -1,12 +1,14 @@ import 'dart:async'; + +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; +import 'package:collection/collection.dart'; import 'package:dartz/dartz.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; + import 'select_option_service.dart'; -import 'package:collection/collection.dart'; part 'select_option_editor_bloc.freezed.dart'; diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart index d15be4a6a0..590a025a41 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart @@ -90,10 +90,10 @@ class NumberTypeOptionWidget extends TypeOptionWidget { } } -typedef _SelectNumberFormatCallback = Function(NumberFormat format); +typedef SelectNumberFormatCallback = Function(NumberFormat format); class NumberFormatList extends StatelessWidget { - final _SelectNumberFormatCallback onSelected; + final SelectNumberFormatCallback onSelected; final NumberFormat selectedFormat; const NumberFormatList( {required this.selectedFormat, required this.onSelected, Key? key}) diff --git a/frontend/app_flowy/lib/user/presentation/router.dart b/frontend/app_flowy/lib/user/presentation/router.dart index 2928154ebe..82ff46ada9 100644 --- a/frontend/app_flowy/lib/user/presentation/router.dart +++ b/frontend/app_flowy/lib/user/presentation/router.dart @@ -28,16 +28,19 @@ class AuthRouter { ); } - void pushHomeScreen(BuildContext context, UserProfilePB profile, CurrentWorkspaceSettingPB workspaceSetting) { + void pushHomeScreen(BuildContext context, UserProfilePB profile, + CurrentWorkspaceSettingPB workspaceSetting) { Navigator.push( context, - PageRoutes.fade(() => HomeScreen(profile, workspaceSetting), RouteDurations.slow.inMilliseconds * .001), + PageRoutes.fade(() => HomeScreen(profile, workspaceSetting), + RouteDurations.slow.inMilliseconds * .001), ); } } class SplashRoute { - Future pushWelcomeScreen(BuildContext context, UserProfilePB userProfile) async { + Future pushWelcomeScreen( + BuildContext context, UserProfilePB userProfile) async { final screen = WelcomeScreen(userProfile: userProfile); final workspaceId = await Navigator.of(context).push( PageRoutes.fade( @@ -46,20 +49,24 @@ class SplashRoute { ), ); + // ignore: use_build_context_synchronously pushHomeScreen(context, userProfile, workspaceId); } - void pushHomeScreen(BuildContext context, UserProfilePB userProfile, CurrentWorkspaceSettingPB workspaceSetting) { + void pushHomeScreen(BuildContext context, UserProfilePB userProfile, + CurrentWorkspaceSettingPB workspaceSetting) { Navigator.push( context, - PageRoutes.fade(() => HomeScreen(userProfile, workspaceSetting), RouteDurations.slow.inMilliseconds * .001), + PageRoutes.fade(() => HomeScreen(userProfile, workspaceSetting), + RouteDurations.slow.inMilliseconds * .001), ); } void pushSignInScreen(BuildContext context) { Navigator.push( context, - PageRoutes.fade(() => SignInScreen(router: getIt()), RouteDurations.slow.inMilliseconds * .001), + PageRoutes.fade(() => SignInScreen(router: getIt()), + RouteDurations.slow.inMilliseconds * .001), ); } diff --git a/frontend/app_flowy/lib/workspace/application/markdown/src/inline_parser.dart b/frontend/app_flowy/lib/workspace/application/markdown/src/inline_parser.dart index 8b47a97433..ce0f11302e 100644 --- a/frontend/app_flowy/lib/workspace/application/markdown/src/inline_parser.dart +++ b/frontend/app_flowy/lib/workspace/application/markdown/src/inline_parser.dart @@ -399,8 +399,8 @@ class AutolinkExtensionSyntax extends InlineSyntax { } } -class _DelimiterRun { - _DelimiterRun._( +class DelimiterRun { + DelimiterRun._( {this.char, this.length, this.isLeftFlanking, @@ -420,8 +420,7 @@ class _DelimiterRun { final bool? isFollowedByPunctuation; // ignore: prefer_constructors_over_static_methods - static _DelimiterRun? tryParse( - InlineParser parser, int runStart, int runEnd) { + static DelimiterRun? tryParse(InlineParser parser, int runStart, int runEnd) { bool leftFlanking, rightFlanking, precededByPunctuation, @@ -466,7 +465,7 @@ class _DelimiterRun { return null; } - return _DelimiterRun._( + return DelimiterRun._( char: parser.charAt(runStart), length: runEnd - runStart + 1, isLeftFlanking: leftFlanking, @@ -516,7 +515,7 @@ class TagSyntax extends InlineSyntax { return true; } - final delimiterRun = _DelimiterRun.tryParse(parser, matchStart, matchEnd); + final delimiterRun = DelimiterRun.tryParse(parser, matchStart, matchEnd); if (delimiterRun != null && delimiterRun.canOpen) { parser.openTag(TagState(parser.pos, matchEnd + 1, this, delimiterRun)); return true; @@ -531,7 +530,7 @@ class TagSyntax extends InlineSyntax { final matchStart = parser.pos; final matchEnd = parser.pos + runLength - 1; final openingRunLength = state.endPos - state.startPos; - final delimiterRun = _DelimiterRun.tryParse(parser, matchStart, matchEnd); + final delimiterRun = DelimiterRun.tryParse(parser, matchStart, matchEnd); if (openingRunLength == 1 && runLength == 1) { parser.addNode(Element('em', state.children)); @@ -579,7 +578,7 @@ class StrikethroughSyntax extends TagSyntax { final runLength = match.group(0)!.length; final matchStart = parser.pos; final matchEnd = parser.pos + runLength - 1; - final delimiterRun = _DelimiterRun.tryParse(parser, matchStart, matchEnd)!; + final delimiterRun = DelimiterRun.tryParse(parser, matchStart, matchEnd)!; if (!delimiterRun.isRightFlanking!) { return false; } @@ -1170,7 +1169,7 @@ class TagState { /// The children of this node. Will be `null` for text nodes. final List children; - final _DelimiterRun? openingDelimiterRun; + final DelimiterRun? openingDelimiterRun; /// Attempts to close this tag by matching the current text against its end /// pattern. @@ -1193,7 +1192,7 @@ class TagState { final closingMatchStart = parser.pos; final closingMatchEnd = parser.pos + runLength - 1; final closingDelimiterRun = - _DelimiterRun.tryParse(parser, closingMatchStart, closingMatchEnd); + DelimiterRun.tryParse(parser, closingMatchStart, closingMatchEnd); if (closingDelimiterRun != null && closingDelimiterRun.canClose) { // Emphasis rules #9 and #10: final oneRunOpensAndCloses = diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart index 5099dcddfc..eed9eb6f4a 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart @@ -58,10 +58,10 @@ class FadingIndexedStack extends StatefulWidget { }) : super(key: key); @override - _FadingIndexedStackState createState() => _FadingIndexedStackState(); + FadingIndexedStackState createState() => FadingIndexedStackState(); } -class _FadingIndexedStackState extends State { +class FadingIndexedStackState extends State { double _targetOpacity = 1; @override diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart index e88c6b09b6..614ff356cb 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart @@ -19,10 +19,10 @@ class AnimatedPanel extends StatefulWidget { : super(key: key); @override - _AnimatedPanelState createState() => _AnimatedPanelState(); + AnimatedPanelState createState() => AnimatedPanelState(); } -class _AnimatedPanelState extends State { +class AnimatedPanelState extends State { bool _isHidden = true; @override diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/default_emoji_picker_view.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/default_emoji_picker_view.dart index d6b605332f..271a3b6dd2 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/default_emoji_picker_view.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/default_emoji_picker_view.dart @@ -10,28 +10,34 @@ import 'emoji_picker_builder.dart'; import 'emoji_view_state.dart'; class DefaultEmojiPickerView extends EmojiPickerBuilder { - const DefaultEmojiPickerView(Config config, EmojiViewState state, {Key? key}) : super(config, state, key: key); + const DefaultEmojiPickerView(Config config, EmojiViewState state, {Key? key}) + : super(config, state, key: key); @override - _DefaultEmojiPickerViewState createState() => _DefaultEmojiPickerViewState(); + DefaultEmojiPickerViewState createState() => DefaultEmojiPickerViewState(); } -class _DefaultEmojiPickerViewState extends State with TickerProviderStateMixin { +class DefaultEmojiPickerViewState extends State + with TickerProviderStateMixin { PageController? _pageController; TabController? _tabController; final TextEditingController _emojiController = TextEditingController(); final FocusNode _emojiFocusNode = FocusNode(); - final CategoryEmoji _categoryEmoji = CategoryEmoji(Category.SEARCH, List.empty(growable: true)); + final CategoryEmoji _categoryEmoji = + CategoryEmoji(Category.SEARCH, List.empty(growable: true)); CategoryEmoji searchEmojiList = CategoryEmoji(Category.SEARCH, []); @override void initState() { - var initCategory = - widget.state.categoryEmoji.indexWhere((element) => element.category == widget.config.initCategory); + var initCategory = widget.state.categoryEmoji.indexWhere( + (element) => element.category == widget.config.initCategory); if (initCategory == -1) { initCategory = 0; } - _tabController = TabController(initialIndex: initCategory, length: widget.state.categoryEmoji.length, vsync: this); + _tabController = TabController( + initialIndex: initCategory, + length: widget.state.categoryEmoji.length, + vsync: this); _pageController = PageController(initialPage: initCategory); _emojiFocusNode.requestFocus(); @@ -83,7 +89,8 @@ class _DefaultEmojiPickerViewState extends State with Ti } bool isEmojiSearching() { - bool result = searchEmojiList.emoji.isNotEmpty || _emojiController.text.isNotEmpty; + bool result = + searchEmojiList.emoji.isNotEmpty || _emojiController.text.isNotEmpty; return result; } @@ -133,7 +140,9 @@ class _DefaultEmojiPickerViewState extends State with Ti child: TabBar( labelColor: widget.config.iconColorSelected, unselectedLabelColor: widget.config.iconColor, - controller: isEmojiSearching() ? TabController(length: 1, vsync: this) : _tabController, + controller: isEmojiSearching() + ? TabController(length: 1, vsync: this) + : _tabController, labelPadding: EdgeInsets.zero, indicatorColor: widget.config.indicatorColor, padding: const EdgeInsets.symmetric(vertical: 5.0), @@ -154,7 +163,8 @@ class _DefaultEmojiPickerViewState extends State with Ti : widget.state.categoryEmoji .asMap() .entries - .map((item) => _buildCategory(item.value.category, emojiSize)) + .map((item) => _buildCategory( + item.value.category, emojiSize)) .toList(), ), ), @@ -163,7 +173,9 @@ class _DefaultEmojiPickerViewState extends State with Ti ), Flexible( child: PageView.builder( - itemCount: searchEmojiList.emoji.isNotEmpty ? 1 : widget.state.categoryEmoji.length, + itemCount: searchEmojiList.emoji.isNotEmpty + ? 1 + : widget.state.categoryEmoji.length, controller: _pageController, physics: const NeverScrollableScrollPhysics(), // onPageChanged: (index) { @@ -173,7 +185,9 @@ class _DefaultEmojiPickerViewState extends State with Ti // ); // }, itemBuilder: (context, index) { - CategoryEmoji catEmoji = isEmojiSearching() ? searchEmojiList : widget.state.categoryEmoji[index]; + CategoryEmoji catEmoji = isEmojiSearching() + ? searchEmojiList + : widget.state.categoryEmoji[index]; return _buildPage(emojiSize, catEmoji); }, ), @@ -195,7 +209,8 @@ class _DefaultEmojiPickerViewState extends State with Ti ); } - Widget _buildButtonWidget({required VoidCallback onPressed, required Widget child}) { + Widget _buildButtonWidget( + {required VoidCallback onPressed, required Widget child}) { if (widget.config.buttonMode == ButtonMode.MATERIAL) { return TextButton( onPressed: onPressed, @@ -203,16 +218,19 @@ class _DefaultEmojiPickerViewState extends State with Ti child: child, ); } - return CupertinoButton(padding: EdgeInsets.zero, onPressed: onPressed, child: child); + return CupertinoButton( + padding: EdgeInsets.zero, onPressed: onPressed, child: child); } Widget _buildPage(double emojiSize, CategoryEmoji categoryEmoji) { // Display notice if recent has no entries yet final scrollController = ScrollController(); - if (categoryEmoji.category == Category.RECENT && categoryEmoji.emoji.isEmpty) { + if (categoryEmoji.category == Category.RECENT && + categoryEmoji.emoji.isEmpty) { return _buildNoRecent(); - } else if (categoryEmoji.category == Category.SEARCH && categoryEmoji.emoji.isEmpty) { + } else if (categoryEmoji.category == Category.SEARCH && + categoryEmoji.emoji.isEmpty) { return const Center(child: Text("No Emoji Found")); } // Build page normally @@ -236,8 +254,13 @@ class _DefaultEmojiPickerViewState extends State with Ti mainAxisSpacing: widget.config.verticalSpacing, crossAxisSpacing: widget.config.horizontalSpacing, children: _categoryEmoji.emoji.isNotEmpty - ? _categoryEmoji.emoji.map((e) => _buildEmoji(emojiSize, categoryEmoji, e)).toList() - : categoryEmoji.emoji.map((item) => _buildEmoji(emojiSize, categoryEmoji, item)).toList(), + ? _categoryEmoji.emoji + .map((e) => _buildEmoji(emojiSize, categoryEmoji, e)) + .toList() + : categoryEmoji.emoji + .map( + (item) => _buildEmoji(emojiSize, categoryEmoji, item)) + .toList(), ), ), ); diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart index 37ce933618..28cf268a46 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart @@ -20,10 +20,10 @@ class FlowyEmojiStyleButton extends StatefulWidget { }) : super(key: key); @override - _EmojiStyleButtonState createState() => _EmojiStyleButtonState(); + EmojiStyleButtonState createState() => EmojiStyleButtonState(); } -class _EmojiStyleButtonState extends State { +class EmojiStyleButtonState extends State { bool _isToggled = false; // Style get _selectionStyle => widget.controller.getSelectionStyle(); final GlobalKey emojiButtonKey = GlobalKey(); diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker.dart index 650cd185f1..8852b12799 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker.dart @@ -101,10 +101,10 @@ class EmojiPicker extends StatefulWidget { final Config config; @override - _EmojiPickerState createState() => _EmojiPickerState(); + EmojiPickerState createState() => EmojiPickerState(); } -class _EmojiPickerState extends State { +class EmojiPickerState extends State { static const platform = MethodChannel('emoji_picker_flutter'); List categoryEmoji = List.empty(growable: true); @@ -147,7 +147,8 @@ class _EmojiPickerState extends State { return const Center(child: CircularProgressIndicator()); } if (widget.config.showRecentsTab) { - categoryEmoji[0].emoji = recentEmoji.map((e) => e.emoji).toList().cast(); + categoryEmoji[0].emoji = + recentEmoji.map((e) => e.emoji).toList().cast(); } var state = EmojiViewState( @@ -184,23 +185,35 @@ class _EmojiPickerState extends State { categoryEmoji.clear(); if (widget.config.showRecentsTab) { recentEmoji = await _getRecentEmojis(); - final List recentEmojiMap = recentEmoji.map((e) => e.emoji).toList().cast(); + final List recentEmojiMap = + recentEmoji.map((e) => e.emoji).toList().cast(); categoryEmoji.add(CategoryEmoji(Category.RECENT, recentEmojiMap)); } categoryEmoji.addAll([ - CategoryEmoji(Category.SMILEYS, await _getAvailableEmojis(emoji_list.smileys, title: 'smileys')), - CategoryEmoji(Category.ANIMALS, await _getAvailableEmojis(emoji_list.animals, title: 'animals')), - CategoryEmoji(Category.FOODS, await _getAvailableEmojis(emoji_list.foods, title: 'foods')), - CategoryEmoji(Category.ACTIVITIES, await _getAvailableEmojis(emoji_list.activities, title: 'activities')), - CategoryEmoji(Category.TRAVEL, await _getAvailableEmojis(emoji_list.travel, title: 'travel')), - CategoryEmoji(Category.OBJECTS, await _getAvailableEmojis(emoji_list.objects, title: 'objects')), - CategoryEmoji(Category.SYMBOLS, await _getAvailableEmojis(emoji_list.symbols, title: 'symbols')), - CategoryEmoji(Category.FLAGS, await _getAvailableEmojis(emoji_list.flags, title: 'flags')) + CategoryEmoji(Category.SMILEYS, + await _getAvailableEmojis(emoji_list.smileys, title: 'smileys')), + CategoryEmoji(Category.ANIMALS, + await _getAvailableEmojis(emoji_list.animals, title: 'animals')), + CategoryEmoji(Category.FOODS, + await _getAvailableEmojis(emoji_list.foods, title: 'foods')), + CategoryEmoji( + Category.ACTIVITIES, + await _getAvailableEmojis(emoji_list.activities, + title: 'activities')), + CategoryEmoji(Category.TRAVEL, + await _getAvailableEmojis(emoji_list.travel, title: 'travel')), + CategoryEmoji(Category.OBJECTS, + await _getAvailableEmojis(emoji_list.objects, title: 'objects')), + CategoryEmoji(Category.SYMBOLS, + await _getAvailableEmojis(emoji_list.symbols, title: 'symbols')), + CategoryEmoji(Category.FLAGS, + await _getAvailableEmojis(emoji_list.flags, title: 'flags')) ]); } // Get available emoji for given category title - Future> _getAvailableEmojis(Map map, {required String title}) async { + Future> _getAvailableEmojis(Map map, + {required String title}) async { Map? newMap; // Get Emojis cached locally if available @@ -216,19 +229,22 @@ class _EmojiPickerState extends State { } // Map to Emoji Object - return newMap!.entries.map((entry) => Emoji(entry.key, entry.value)).toList(); + return newMap!.entries + .map((entry) => Emoji(entry.key, entry.value)) + .toList(); } // Check if emoji is available on current platform - Future?> _getPlatformAvailableEmoji(Map emoji) async { + Future?> _getPlatformAvailableEmoji( + Map emoji) async { if (Platform.isAndroid) { Map? filtered = {}; var delimiter = '|'; try { var entries = emoji.values.join(delimiter); var keys = emoji.keys.join(delimiter); - var result = (await platform - .invokeMethod('checkAvailability', {'emojiKeys': keys, 'emojiEntries': entries})) as String; + var result = (await platform.invokeMethod('checkAvailability', + {'emojiKeys': keys, 'emojiEntries': entries})) as String; var resultKeys = result.split(delimiter); for (var i = 0; i < resultKeys.length; i++) { filtered[resultKeys[i]] = emoji[resultKeys[i]]!; @@ -249,12 +265,14 @@ class _EmojiPickerState extends State { if (emojiJson == null) { return null; } - var emojis = Map.from(jsonDecode(emojiJson) as Map); + var emojis = + Map.from(jsonDecode(emojiJson) as Map); return emojis; } // Stores filtered emoji locally for faster access next time - Future _cacheFilteredEmojis(String title, Map emojis) async { + Future _cacheFilteredEmojis( + String title, Map emojis) async { final prefs = await SharedPreferences.getInstance(); var emojiJson = jsonEncode(emojis); prefs.setString(title, emojiJson); @@ -274,7 +292,8 @@ class _EmojiPickerState extends State { // Add an emoji to recently used list or increase its counter Future _addEmojiToRecentlyUsed(Emoji emoji) async { final prefs = await SharedPreferences.getInstance(); - var recentEmojiIndex = recentEmoji.indexWhere((element) => element.emoji.emoji == emoji.emoji); + var recentEmojiIndex = + recentEmoji.indexWhere((element) => element.emoji.emoji == emoji.emoji); if (recentEmojiIndex != -1) { // Already exist in recent list // Just update counter @@ -285,7 +304,8 @@ class _EmojiPickerState extends State { // Sort by counter desc recentEmoji.sort((a, b) => b.counter - a.counter); // Limit entries to recentsLimit - recentEmoji = recentEmoji.sublist(0, min(widget.config.recentsLimit, recentEmoji.length)); + recentEmoji = recentEmoji.sublist( + 0, min(widget.config.recentsLimit, recentEmoji.length)); // save locally prefs.setString('recent', jsonEncode(recentEmoji)); } diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_window.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_window.dart index 4f30248ed2..9ad25dc70c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_window.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_window.dart @@ -21,6 +21,7 @@ class FlowyPoppuWindow extends StatelessWidget { required Size size, }) async { final window = await getWindowInfo(); + // ignore: use_build_context_synchronously FlowyOverlay.of(context).insertWithRect( widget: FlowyPoppuWindow(child: child), identifier: 'FlowyPoppuWindow', @@ -49,7 +50,10 @@ class PopupTextField extends StatelessWidget { ); } - static void show({required BuildContext context, required Size size, required void Function(String) textDidChange}) { + static void show( + {required BuildContext context, + required Size size, + required void Function(String) textDidChange}) { FlowyPoppuWindow.show( context, size: size, diff --git a/frontend/app_flowy/pubspec.yaml b/frontend/app_flowy/pubspec.yaml index 7447ae999d..5ebf486947 100644 --- a/frontend/app_flowy/pubspec.yaml +++ b/frontend/app_flowy/pubspec.yaml @@ -82,6 +82,13 @@ dependencies: linked_scroll_controller: ^0.2.0 hotkey_manager: ^0.1.7 fixnum: ^1.0.1 + tuple: ^2.0.0 + protobuf: "2.0.0" + charcode: ^1.3.1 + collection: ^1.16.0 + bloc: ^8.1.0 + textstyle_extensions: ^1.1.0 + shared_preferences: ^2.0.15 dev_dependencies: flutter_lints: ^2.0.1