Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [MDS-1176] Fix input components context menu #417

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 7 additions & 36 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,10 @@ void main() async {
runApp(const MyApp());
}

class MyApp extends StatefulWidget {
class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
bool _isInStorybookMode = true;

void toggleStorybookMode() {
setState(() => _isInStorybookMode = !_isInStorybookMode);
}
bool get _isInStorybookMode => true;

@override
Widget build(BuildContext context) {
Expand All @@ -47,31 +38,11 @@ class _MyAppState extends State<MyApp> {
),
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Moon Design for Flutter",
style: TextStyle(
fontSize:
MediaQuery.of(context).size.width > 800 ? 72 : 32,
),
),
SizedBox(
height: MediaQuery.of(context).size.width > 800 ? 36 : 16,
),
GestureDetector(
onLongPress: toggleStorybookMode,
child: Text(
"Coming soon...",
style: TextStyle(
fontSize:
MediaQuery.of(context).size.width > 800 ? 24 : 20,
color: const Color(0xFF999CA0),
),
),
),
],
child: Text(
"Moon Design for Flutter",
style: TextStyle(
fontSize: MediaQuery.of(context).size.width > 800 ? 72 : 32,
),
),
),
),
Expand Down
15 changes: 10 additions & 5 deletions lib/src/widgets/text_input/text_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1117,16 +1117,16 @@ class _MoonTextInputState extends State<MoonTextInput>
? hoverBorder
: defaultBorder;

final bool paintCursorAboveText;
final Color cursorColor;
final Color selectionColor;

bool? cursorOpacityAnimates = widget.cursorOpacityAnimates;
Color? autocorrectionTextRectColor;
Offset? cursorOffset;
Radius? cursorRadius = widget.cursorRadius;
VoidCallback? handleDidGainAccessibilityFocus;

final bool paintCursorAboveText;
final Color cursorColor;
final Color selectionColor;
final TextSelectionControls? textSelectionControls = widget.selectionControls;
TextSelectionControls? textSelectionControls = widget.selectionControls;

final MouseCursor effectiveMouseCursor = MaterialStateProperty.resolveAs<MouseCursor>(
widget.mouseCursor ?? MaterialStateMouseCursor.textable,
Expand Down Expand Up @@ -1169,6 +1169,7 @@ class _MoonTextInputState extends State<MoonTextInput>
case TargetPlatform.iOS:
final CupertinoThemeData cupertinoTheme = CupertinoTheme.of(context);
forcePressEnabled = true;
textSelectionControls ??= cupertinoTextSelectionHandleControls;
paintCursorAboveText = true;
cursorOpacityAnimates ??= true;
cursorColor = _hasError ? effectiveCursorErrorColor : widget.cursorColor ?? effectiveTextColor;
Expand All @@ -1180,6 +1181,7 @@ class _MoonTextInputState extends State<MoonTextInput>
case TargetPlatform.macOS:
final CupertinoThemeData cupertinoTheme = CupertinoTheme.of(context);
forcePressEnabled = false;
textSelectionControls ??= cupertinoDesktopTextSelectionHandleControls;
paintCursorAboveText = true;
cursorOpacityAnimates ??= false;
cursorColor = _hasError ? effectiveCursorErrorColor : widget.cursorColor ?? effectiveTextColor;
Expand All @@ -1196,20 +1198,23 @@ class _MoonTextInputState extends State<MoonTextInput>
case TargetPlatform.android:
case TargetPlatform.fuchsia:
forcePressEnabled = false;
textSelectionControls ??= materialTextSelectionHandleControls;
paintCursorAboveText = false;
cursorOpacityAnimates ??= false;
cursorColor = _hasError ? effectiveCursorErrorColor : widget.cursorColor ?? effectiveTextColor;
selectionColor = selectionStyle.selectionColor ?? theme.colorScheme.primary.withOpacity(0.40);

case TargetPlatform.linux:
forcePressEnabled = false;
textSelectionControls ??= desktopTextSelectionHandleControls;
paintCursorAboveText = false;
cursorOpacityAnimates ??= false;
cursorColor = _hasError ? effectiveCursorErrorColor : widget.cursorColor ?? effectiveTextColor;
selectionColor = selectionStyle.selectionColor ?? theme.colorScheme.primary.withOpacity(0.40);

case TargetPlatform.windows:
forcePressEnabled = false;
textSelectionControls ??= desktopTextSelectionHandleControls;
paintCursorAboveText = false;
cursorOpacityAnimates ??= false;
cursorColor = _hasError ? effectiveCursorErrorColor : widget.cursorColor ?? effectiveTextColor;
Expand Down