Skip to content

Commit

Permalink
Merge pull request #27 from KingGorrin/fix-context-menu
Browse files Browse the repository at this point in the history
Fix context menu
  • Loading branch information
alienc0der authored Feb 1, 2023
2 parents c88f17a + 25f1ed2 commit 0bfb475
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/utils/app_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class AppTheme {
scaffoldBackgroundColor: AppColors.backgroundLight,
textSelectionTheme: const TextSelectionThemeData(
cursorColor: AppColors.znnColor,
selectionHandleColor: AppColors.znnColor,
),
fontFamily: 'Roboto',
inputDecorationTheme: InputDecorationTheme(
Expand Down Expand Up @@ -276,6 +277,7 @@ class AppTheme {
textSelectionTheme: TextSelectionThemeData(
selectionColor: Colors.white.withOpacity(0.1),
cursorColor: AppColors.znnColor,
selectionHandleColor: AppColors.znnColor,
),
fontFamily: 'Roboto',
inputDecorationTheme: InputDecorationTheme(
Expand Down
20 changes: 20 additions & 0 deletions lib/widgets/reusable_widgets/input_fields/input_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ class _InputFieldState extends State<InputField> {
@override
Widget build(BuildContext context) {
return TextFormField(
contextMenuBuilder: (context, editableTextState) {
return AdaptiveTextSelectionToolbar(
anchors: editableTextState.contextMenuAnchors,
children: editableTextState.contextMenuButtonItems
.map((ContextMenuButtonItem buttonItem) {
return Row(children: [
Expanded(
child: TextButton(
onPressed: buttonItem.onPressed,
style: TextButton.styleFrom(
shape: const RoundedRectangleBorder(),
),
child: Text(
AdaptiveTextSelectionToolbar.getButtonLabel(
context, buttonItem),
style: const TextStyle(color: Colors.white)),
))
]);
}).toList());
},
maxLines: widget.maxLines,
obscureText: widget.obscureText,
onChanged: widget.onChanged,
Expand Down

0 comments on commit 0bfb475

Please sign in to comment.