Skip to content

Commit

Permalink
feature: enanble custom TextSelectionControls
Browse files Browse the repository at this point in the history
  • Loading branch information
kfdykme committed Aug 11, 2024
1 parent e7c7a9a commit 4d0a258
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/fleather/lib/src/widgets/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ class FleatherEditor extends StatefulWidget {

final GlobalKey<EditorState>? editorKey;

final TextSelectionControls? textSelectionControls;

const FleatherEditor({
super.key,
required this.controller,
Expand Down Expand Up @@ -314,6 +316,7 @@ class FleatherEditor extends StatefulWidget {
this.contextMenuBuilder = defaultContextMenuBuilder,
this.embedBuilder = defaultFleatherEmbedBuilder,
this.linkActionPickerDelegate = defaultLinkActionPickerDelegate,
this.textSelectionControls
});

@override
Expand Down Expand Up @@ -412,10 +415,11 @@ class _FleatherEditorState extends State<FleatherEditor>

final keyboardAppearance = widget.keyboardAppearance ?? theme.brightness;


switch (theme.platform) {
case TargetPlatform.iOS:
final cupertinoTheme = CupertinoTheme.of(context);
textSelectionControls = cupertinoTextSelectionControls;
textSelectionControls = widget.textSelectionControls ?? cupertinoTextSelectionControls;
paintCursorAboveText = true;
cursorOpacityAnimates = true;
cursorColor = selectionTheme.cursorColor ?? cupertinoTheme.primaryColor;
Expand All @@ -428,7 +432,7 @@ class _FleatherEditorState extends State<FleatherEditor>

case TargetPlatform.macOS:
final CupertinoThemeData cupertinoTheme = CupertinoTheme.of(context);
textSelectionControls = cupertinoDesktopTextSelectionControls;
textSelectionControls = widget.textSelectionControls ?? cupertinoDesktopTextSelectionControls;
paintCursorAboveText = true;
cursorOpacityAnimates = false;
cursorColor = selectionTheme.cursorColor ?? cupertinoTheme.primaryColor;
Expand All @@ -441,7 +445,7 @@ class _FleatherEditorState extends State<FleatherEditor>

case TargetPlatform.android:
case TargetPlatform.fuchsia:
textSelectionControls = materialTextSelectionControls;
textSelectionControls = widget.textSelectionControls ?? materialTextSelectionControls;
paintCursorAboveText = false;
cursorOpacityAnimates = false;
cursorColor = selectionTheme.cursorColor ?? theme.colorScheme.primary;
Expand All @@ -451,7 +455,7 @@ class _FleatherEditorState extends State<FleatherEditor>

case TargetPlatform.linux:
case TargetPlatform.windows:
textSelectionControls = desktopTextSelectionControls;
textSelectionControls = widget.textSelectionControls ?? desktopTextSelectionControls;
paintCursorAboveText = false;
cursorOpacityAnimates = false;
cursorColor = selectionTheme.cursorColor ?? theme.colorScheme.primary;
Expand Down

0 comments on commit 4d0a258

Please sign in to comment.