mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: adjust flutter lint 2.0
This commit is contained in:
parent
a2d8fe9e80
commit
410d150360
@ -31,10 +31,10 @@ class MoveWindowDetector extends StatefulWidget {
|
||||
final Widget? child;
|
||||
|
||||
@override
|
||||
_MoveWindowDetectorState createState() => _MoveWindowDetectorState();
|
||||
MoveWindowDetectorState createState() => MoveWindowDetectorState();
|
||||
}
|
||||
|
||||
class _MoveWindowDetectorState extends State<MoveWindowDetector> {
|
||||
class MoveWindowDetectorState extends State<MoveWindowDetector> {
|
||||
double winX = 0;
|
||||
double winY = 0;
|
||||
|
||||
@ -59,7 +59,8 @@ class _MoveWindowDetectorState extends State<MoveWindowDetector> {
|
||||
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,
|
||||
);
|
||||
|
@ -16,7 +16,10 @@ class EditorCheckboxBuilder extends QuillCheckboxBuilder {
|
||||
EditorCheckboxBuilder(this.theme);
|
||||
|
||||
@override
|
||||
Widget build({required BuildContext context, required bool isChecked, required ValueChanged<bool> onChanged}) {
|
||||
Widget build(
|
||||
{required BuildContext context,
|
||||
required bool isChecked,
|
||||
required ValueChanged<bool> 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<FlowyEditorCheckbox> {
|
||||
class FlowyEditorCheckboxState extends State<FlowyEditorCheckbox> {
|
||||
late bool isChecked;
|
||||
|
||||
@override
|
||||
@ -51,7 +54,9 @@ class _FlowyEditorCheckboxState extends State<FlowyEditorCheckbox> {
|
||||
|
||||
@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(
|
||||
|
@ -28,10 +28,10 @@ class FlowyCheckListButton extends StatefulWidget {
|
||||
final String tooltipText;
|
||||
|
||||
@override
|
||||
_FlowyCheckListButtonState createState() => _FlowyCheckListButtonState();
|
||||
FlowyCheckListButtonState createState() => FlowyCheckListButtonState();
|
||||
}
|
||||
|
||||
class _FlowyCheckListButtonState extends State<FlowyCheckListButton> {
|
||||
class FlowyCheckListButtonState extends State<FlowyCheckListButton> {
|
||||
bool? _isToggled;
|
||||
|
||||
Style get _selectionStyle => widget.controller.getSelectionStyle();
|
||||
|
@ -24,10 +24,10 @@ class FlowyColorButton extends StatefulWidget {
|
||||
final QuillIconTheme? iconTheme;
|
||||
|
||||
@override
|
||||
_FlowyColorButtonState createState() => _FlowyColorButtonState();
|
||||
FlowyColorButtonState createState() => FlowyColorButtonState();
|
||||
}
|
||||
|
||||
class _FlowyColorButtonState extends State<FlowyColorButton> {
|
||||
class FlowyColorButtonState extends State<FlowyColorButton> {
|
||||
late bool _isToggledColor;
|
||||
late bool _isToggledBackground;
|
||||
late bool _isWhite;
|
||||
@ -37,10 +37,14 @@ class _FlowyColorButtonState extends State<FlowyColorButton> {
|
||||
|
||||
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<FlowyColorButton> {
|
||||
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<FlowyColorButton> {
|
||||
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<FlowyColorButton> {
|
||||
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<FlowyColorButton> {
|
||||
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<FlowyColorButton> {
|
||||
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<FlowyColorPicker> createState() => _FlowyColorPickerState();
|
||||
@ -178,8 +194,10 @@ class _FlowyColorPickerState extends State<FlowyColorPicker> {
|
||||
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<FlowyColorPicker> {
|
||||
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) {
|
||||
|
@ -16,10 +16,10 @@ class FlowyHeaderStyleButton extends StatefulWidget {
|
||||
final double iconSize;
|
||||
|
||||
@override
|
||||
_FlowyHeaderStyleButtonState createState() => _FlowyHeaderStyleButtonState();
|
||||
FlowyHeaderStyleButtonState createState() => FlowyHeaderStyleButtonState();
|
||||
}
|
||||
|
||||
class _FlowyHeaderStyleButtonState extends State<FlowyHeaderStyleButton> {
|
||||
class FlowyHeaderStyleButtonState extends State<FlowyHeaderStyleButton> {
|
||||
Attribute? _value;
|
||||
|
||||
Style get _selectionStyle => widget.controller.getSelectionStyle();
|
||||
@ -28,7 +28,8 @@ class _FlowyHeaderStyleButtonState extends State<FlowyHeaderStyleButton> {
|
||||
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<FlowyHeaderStyleButton> {
|
||||
Attribute.h3: 'H3',
|
||||
};
|
||||
|
||||
final valueAttribute = <Attribute>[Attribute.h1, Attribute.h2, Attribute.h3];
|
||||
final valueAttribute = <Attribute>[
|
||||
Attribute.h1,
|
||||
Attribute.h2,
|
||||
Attribute.h3
|
||||
];
|
||||
final valueString = <String>['H1', 'H2', 'H3'];
|
||||
final attributeImageName = <String>['editor/H1', 'editor/H2', 'editor/H3'];
|
||||
|
||||
@ -72,7 +77,8 @@ class _FlowyHeaderStyleButtonState extends State<FlowyHeaderStyleButton> {
|
||||
|
||||
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<FlowyHeaderStyleButton> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,10 @@ class FlowyLinkStyleButton extends StatefulWidget {
|
||||
final double iconSize;
|
||||
|
||||
@override
|
||||
_FlowyLinkStyleButtonState createState() => _FlowyLinkStyleButtonState();
|
||||
FlowyLinkStyleButtonState createState() => FlowyLinkStyleButtonState();
|
||||
}
|
||||
|
||||
class _FlowyLinkStyleButtonState extends State<FlowyLinkStyleButton> {
|
||||
class FlowyLinkStyleButtonState extends State<FlowyLinkStyleButton> {
|
||||
void _didChangeSelection() {
|
||||
setState(() {});
|
||||
}
|
||||
@ -75,7 +75,9 @@ class _FlowyLinkStyleButtonState extends State<FlowyLinkStyleButton> {
|
||||
|
||||
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);
|
||||
|
@ -21,10 +21,10 @@ class FlowyToggleStyleButton extends StatefulWidget {
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ToggleStyleButtonState createState() => _ToggleStyleButtonState();
|
||||
ToggleStyleButtonState createState() => ToggleStyleButtonState();
|
||||
}
|
||||
|
||||
class _ToggleStyleButtonState extends State<FlowyToggleStyleButton> {
|
||||
class ToggleStyleButtonState extends State<FlowyToggleStyleButton> {
|
||||
bool? _isToggled;
|
||||
Style get _selectionStyle => widget.controller.getSelectionStyle();
|
||||
@override
|
||||
@ -77,6 +77,8 @@ class _ToggleStyleButtonState extends State<FlowyToggleStyleButton> {
|
||||
}
|
||||
|
||||
void _toggleAttribute() {
|
||||
widget.controller.formatSelection(_isToggled! ? Attribute.clone(widget.attribute, null) : widget.attribute);
|
||||
widget.controller.formatSelection(_isToggled!
|
||||
? Attribute.clone(widget.attribute, null)
|
||||
: widget.attribute);
|
||||
}
|
||||
}
|
||||
|
@ -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<Widget> buttons;
|
||||
|
||||
@override
|
||||
_ToolbarButtonListState createState() => _ToolbarButtonListState();
|
||||
ToolbarButtonListState createState() => ToolbarButtonListState();
|
||||
}
|
||||
|
||||
class _ToolbarButtonListState extends State<ToolbarButtonList> with WidgetsBindingObserver {
|
||||
class ToolbarButtonListState extends State<ToolbarButtonList>
|
||||
with WidgetsBindingObserver {
|
||||
final ScrollController _controller = ScrollController();
|
||||
bool _showLeftArrow = false;
|
||||
bool _showRightArrow = false;
|
||||
@ -196,7 +198,8 @@ class _ToolbarButtonListState extends State<ToolbarButtonList> with WidgetsBindi
|
||||
return LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
List<Widget> 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<ToolbarButtonList> 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;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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})
|
||||
|
@ -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<void> pushWelcomeScreen(BuildContext context, UserProfilePB userProfile) async {
|
||||
Future<void> 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<AuthRouter>()), RouteDurations.slow.inMilliseconds * .001),
|
||||
PageRoutes.fade(() => SignInScreen(router: getIt<AuthRouter>()),
|
||||
RouteDurations.slow.inMilliseconds * .001),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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<Node> 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 =
|
||||
|
@ -58,10 +58,10 @@ class FadingIndexedStack extends StatefulWidget {
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_FadingIndexedStackState createState() => _FadingIndexedStackState();
|
||||
FadingIndexedStackState createState() => FadingIndexedStackState();
|
||||
}
|
||||
|
||||
class _FadingIndexedStackState extends State<FadingIndexedStack> {
|
||||
class FadingIndexedStackState extends State<FadingIndexedStack> {
|
||||
double _targetOpacity = 1;
|
||||
|
||||
@override
|
||||
|
@ -19,10 +19,10 @@ class AnimatedPanel extends StatefulWidget {
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_AnimatedPanelState createState() => _AnimatedPanelState();
|
||||
AnimatedPanelState createState() => AnimatedPanelState();
|
||||
}
|
||||
|
||||
class _AnimatedPanelState extends State<AnimatedPanel> {
|
||||
class AnimatedPanelState extends State<AnimatedPanel> {
|
||||
bool _isHidden = true;
|
||||
|
||||
@override
|
||||
|
@ -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<DefaultEmojiPickerView> with TickerProviderStateMixin {
|
||||
class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
|
||||
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, <Emoji>[]);
|
||||
|
||||
@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<DefaultEmojiPickerView> 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<DefaultEmojiPickerView> 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<DefaultEmojiPickerView> with Ti
|
||||
: widget.state.categoryEmoji
|
||||
.asMap()
|
||||
.entries
|
||||
.map<Widget>((item) => _buildCategory(item.value.category, emojiSize))
|
||||
.map<Widget>((item) => _buildCategory(
|
||||
item.value.category, emojiSize))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
@ -163,7 +173,9 @@ class _DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView> 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<DefaultEmojiPickerView> 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<DefaultEmojiPickerView> 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<DefaultEmojiPickerView> 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<DefaultEmojiPickerView> with Ti
|
||||
mainAxisSpacing: widget.config.verticalSpacing,
|
||||
crossAxisSpacing: widget.config.horizontalSpacing,
|
||||
children: _categoryEmoji.emoji.isNotEmpty
|
||||
? _categoryEmoji.emoji.map<Widget>((e) => _buildEmoji(emojiSize, categoryEmoji, e)).toList()
|
||||
: categoryEmoji.emoji.map<Widget>((item) => _buildEmoji(emojiSize, categoryEmoji, item)).toList(),
|
||||
? _categoryEmoji.emoji
|
||||
.map<Widget>((e) => _buildEmoji(emojiSize, categoryEmoji, e))
|
||||
.toList()
|
||||
: categoryEmoji.emoji
|
||||
.map<Widget>(
|
||||
(item) => _buildEmoji(emojiSize, categoryEmoji, item))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -20,10 +20,10 @@ class FlowyEmojiStyleButton extends StatefulWidget {
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_EmojiStyleButtonState createState() => _EmojiStyleButtonState();
|
||||
EmojiStyleButtonState createState() => EmojiStyleButtonState();
|
||||
}
|
||||
|
||||
class _EmojiStyleButtonState extends State<FlowyEmojiStyleButton> {
|
||||
class EmojiStyleButtonState extends State<FlowyEmojiStyleButton> {
|
||||
bool _isToggled = false;
|
||||
// Style get _selectionStyle => widget.controller.getSelectionStyle();
|
||||
final GlobalKey emojiButtonKey = GlobalKey();
|
||||
|
@ -101,10 +101,10 @@ class EmojiPicker extends StatefulWidget {
|
||||
final Config config;
|
||||
|
||||
@override
|
||||
_EmojiPickerState createState() => _EmojiPickerState();
|
||||
EmojiPickerState createState() => EmojiPickerState();
|
||||
}
|
||||
|
||||
class _EmojiPickerState extends State<EmojiPicker> {
|
||||
class EmojiPickerState extends State<EmojiPicker> {
|
||||
static const platform = MethodChannel('emoji_picker_flutter');
|
||||
|
||||
List<CategoryEmoji> categoryEmoji = List.empty(growable: true);
|
||||
@ -147,7 +147,8 @@ class _EmojiPickerState extends State<EmojiPicker> {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
if (widget.config.showRecentsTab) {
|
||||
categoryEmoji[0].emoji = recentEmoji.map((e) => e.emoji).toList().cast<Emoji>();
|
||||
categoryEmoji[0].emoji =
|
||||
recentEmoji.map((e) => e.emoji).toList().cast<Emoji>();
|
||||
}
|
||||
|
||||
var state = EmojiViewState(
|
||||
@ -184,23 +185,35 @@ class _EmojiPickerState extends State<EmojiPicker> {
|
||||
categoryEmoji.clear();
|
||||
if (widget.config.showRecentsTab) {
|
||||
recentEmoji = await _getRecentEmojis();
|
||||
final List<Emoji> recentEmojiMap = recentEmoji.map((e) => e.emoji).toList().cast<Emoji>();
|
||||
final List<Emoji> recentEmojiMap =
|
||||
recentEmoji.map((e) => e.emoji).toList().cast<Emoji>();
|
||||
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<List<Emoji>> _getAvailableEmojis(Map<String, String> map, {required String title}) async {
|
||||
Future<List<Emoji>> _getAvailableEmojis(Map<String, String> map,
|
||||
{required String title}) async {
|
||||
Map<String, String>? newMap;
|
||||
|
||||
// Get Emojis cached locally if available
|
||||
@ -216,19 +229,22 @@ class _EmojiPickerState extends State<EmojiPicker> {
|
||||
}
|
||||
|
||||
// Map to Emoji Object
|
||||
return newMap!.entries.map<Emoji>((entry) => Emoji(entry.key, entry.value)).toList();
|
||||
return newMap!.entries
|
||||
.map<Emoji>((entry) => Emoji(entry.key, entry.value))
|
||||
.toList();
|
||||
}
|
||||
|
||||
// Check if emoji is available on current platform
|
||||
Future<Map<String, String>?> _getPlatformAvailableEmoji(Map<String, String> emoji) async {
|
||||
Future<Map<String, String>?> _getPlatformAvailableEmoji(
|
||||
Map<String, String> emoji) async {
|
||||
if (Platform.isAndroid) {
|
||||
Map<String, String>? filtered = {};
|
||||
var delimiter = '|';
|
||||
try {
|
||||
var entries = emoji.values.join(delimiter);
|
||||
var keys = emoji.keys.join(delimiter);
|
||||
var result = (await platform
|
||||
.invokeMethod<String>('checkAvailability', {'emojiKeys': keys, 'emojiEntries': entries})) as String;
|
||||
var result = (await platform.invokeMethod<String>('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<EmojiPicker> {
|
||||
if (emojiJson == null) {
|
||||
return null;
|
||||
}
|
||||
var emojis = Map<String, String>.from(jsonDecode(emojiJson) as Map<String, dynamic>);
|
||||
var emojis =
|
||||
Map<String, String>.from(jsonDecode(emojiJson) as Map<String, dynamic>);
|
||||
return emojis;
|
||||
}
|
||||
|
||||
// Stores filtered emoji locally for faster access next time
|
||||
Future<void> _cacheFilteredEmojis(String title, Map<String, String> emojis) async {
|
||||
Future<void> _cacheFilteredEmojis(
|
||||
String title, Map<String, String> emojis) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var emojiJson = jsonEncode(emojis);
|
||||
prefs.setString(title, emojiJson);
|
||||
@ -274,7 +292,8 @@ class _EmojiPickerState extends State<EmojiPicker> {
|
||||
// Add an emoji to recently used list or increase its counter
|
||||
Future<void> _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<EmojiPicker> {
|
||||
// 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));
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user