Skip to content

Commit

Permalink
[MDS-1176] Fix input components context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Birgitt Majas committed Jun 6, 2024
1 parent e4166a7 commit 7244daf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 41 deletions.
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

0 comments on commit 7244daf

Please sign in to comment.