Skip to content
Open
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
70 changes: 32 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This causes a lot of inconvenience for users, so this package allows adding func
- You can use it for Android, iOS or both platforms.
- Compatible with Dialog.

Example of the custom footer:
Example of the custom footer:

<img width="250" alt="Screen Shot 2019-05-22 at 5 46 50 PM" src="https://user-images.githubusercontent.com/3268245/58218221-0409f200-7cbb-11e9-91d8-592f2e99fa8a.png">

Expand Down Expand Up @@ -84,16 +84,14 @@ class _ContentState extends State<Content> {
KeyboardActionsItem(
focusNode: _nodeText1,
),
KeyboardActionsItem(focusNode: _nodeText2, toolbarButtons: [
(node) {
return GestureDetector(
onTap: () => node.unfocus(),
child: Padding(
padding: EdgeInsets.all(8.0),
child: Icon(Icons.close),
),
);
}
KeyboardActionsItem(focusNode: _nodeText2, toolbarButtons: (node, _, __, ___) => [
GestureDetector(
onTap: () => node.unfocus(),
child: Padding(
padding: EdgeInsets.all(8.0),
child: Icon(Icons.close),
),
),
]),
KeyboardActionsItem(
focusNode: _nodeText3,
Expand All @@ -117,37 +115,33 @@ class _ContentState extends State<Content> {
focusNode: _nodeText4,
displayCloseWidget: false,
),
KeyboardActionsItem(
KeyboardActionsItem(
focusNode: _nodeText5,
toolbarButtons: [
toolbarButtons: (node, _, __, ___) => [
//button 1
(node) {
return GestureDetector(
onTap: () => node.unfocus(),
child: Container(
color: Colors.white,
padding: EdgeInsets.all(8.0),
child: Text(
"CLOSE",
style: TextStyle(color: Colors.black),
),
GestureDetector(
onTap: () => node.unfocus(),
child: Container(
color: Colors.white,
padding: EdgeInsets.all(8.0),
child: Text(
"CLOSE",
style: TextStyle(color: Colors.black),
),
);
},
),
),
//button 2
(node) {
return GestureDetector(
onTap: () => node.unfocus(),
child: Container(
color: Colors.black,
padding: EdgeInsets.all(8.0),
child: Text(
"DONE",
style: TextStyle(color: Colors.white),
),
GestureDetector(
onTap: () => node.unfocus(),
child: Container(
color: Colors.black,
padding: EdgeInsets.all(8.0),
child: Text(
"DONE",
style: TextStyle(color: Colors.white),
),
);
}
),
)
],
),
KeyboardActionsItem(
Expand Down Expand Up @@ -413,4 +407,4 @@ class CounterKeyboard extends StatelessWidget



You can follow me on twitter [@diegoveloper](https://www.twitter.com/diegoveloper)
You can follow me on twitter [@diegoveloper](https://www.twitter.com/diegoveloper)
75 changes: 29 additions & 46 deletions example/lib/content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,18 @@ class Content extends StatefulWidget {

class _ContentState extends State<Content> {
final FocusNode _nodeText1 = FocusNode();

final FocusNode _nodeText2 = FocusNode();

final FocusNode _nodeText3 = FocusNode();

final FocusNode _nodeText4 = FocusNode();

final FocusNode _nodeText5 = FocusNode();

final FocusNode _nodeText6 = FocusNode();

final FocusNode _nodeText7 = FocusNode();

final FocusNode _nodeText8 = FocusNode();

final FocusNode _nodeText9 = FocusNode();

final FocusNode _nodeText10 = FocusNode();

final custom1Notifier = ValueNotifier<String>("0");

final custom2Notifier = ValueNotifier<Color>(Colors.blue);

final custom3Notifier = ValueNotifier<String>("");

/// Creates the [KeyboardActionsConfig] to hook up the fields
Expand All @@ -50,16 +39,14 @@ class _ContentState extends State<Content> {
KeyboardActionsItem(
focusNode: _nodeText1,
),
KeyboardActionsItem(focusNode: _nodeText2, toolbarButtons: [
(node) {
return GestureDetector(
onTap: () => node.unfocus(),
child: Padding(
padding: EdgeInsets.all(8.0),
child: Icon(Icons.close),
),
);
}
KeyboardActionsItem(focusNode: _nodeText2, toolbarButtons: (node, _, __, ___) => [
GestureDetector(
onTap: () => node.unfocus(),
child: Padding(
padding: EdgeInsets.all(8.0),
child: Icon(Icons.close),
),
),
]),
KeyboardActionsItem(
focusNode: _nodeText3,
Expand All @@ -85,35 +72,31 @@ class _ContentState extends State<Content> {
),
KeyboardActionsItem(
focusNode: _nodeText5,
toolbarButtons: [
toolbarButtons: (node, _, __, ___) => [
//button 1
(node) {
return GestureDetector(
onTap: () => node.unfocus(),
child: Container(
color: Colors.white,
padding: EdgeInsets.all(8.0),
child: Text(
"CLOSE",
style: TextStyle(color: Colors.black),
),
GestureDetector(
onTap: () => node.unfocus(),
child: Container(
color: Colors.white,
padding: EdgeInsets.all(8.0),
child: Text(
"CLOSE",
style: TextStyle(color: Colors.black),
),
);
},
),
),
//button 2
(node) {
return GestureDetector(
onTap: () => node.unfocus(),
child: Container(
color: Colors.black,
padding: EdgeInsets.all(8.0),
child: Text(
"DONE",
style: TextStyle(color: Colors.white),
),
GestureDetector(
onTap: () => node.unfocus(),
child: Container(
color: Colors.black,
padding: EdgeInsets.all(8.0),
child: Text(
"DONE",
style: TextStyle(color: Colors.white),
),
);
}
),
)
],
),
KeyboardActionsItem(
Expand Down
1 change: 1 addition & 0 deletions example/lib/sample.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Sample extends StatelessWidget {
tapOutsideBehavior: TapOutsideBehavior.opaqueDismiss,
config: KeyboardActionsConfig(
keyboardSeparatorColor: Colors.purple,
keyboardSeparatorThickness: 5,
actions: [
KeyboardActionsItem(
focusNode: _focusNodeName,
Expand Down
31 changes: 17 additions & 14 deletions example/lib/sample3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import 'package:keyboard_actions/keyboard_actions.dart';

/// Sample [Widget] demonstrating the usage of [KeyboardActionsConfig.defaultDoneWidget].
class Sample3 extends StatelessWidget {
final _focusNodes =
Iterable<int>.generate(7).map((_) => FocusNode()).toList();
final _focusNodes = Iterable<int>.generate(7).map((_) => FocusNode()).toList();

@override
Widget build(BuildContext context) {
Expand All @@ -19,10 +18,8 @@ class Sample3 extends StatelessWidget {
tapOutsideBehavior: TapOutsideBehavior.translucentDismiss,
config: KeyboardActionsConfig(
// Define ``defaultDoneWidget`` only once in the config
defaultDoneWidget: _buildMyDoneWidget(),
actions: _focusNodes
.map((focusNode) => KeyboardActionsItem(focusNode: focusNode))
.toList(),
defaultDoneWidget: _buildMyDoneWidget,
actions: _focusNodes.map((focusNode) => KeyboardActionsItem(focusNode: focusNode)).toList(),
),
child: ListView.separated(
itemBuilder: (ctx, idx) => TextField(
Expand All @@ -42,14 +39,20 @@ class Sample3 extends StatelessWidget {
}

/// Returns the custom [Widget] to be rendered as the *"Done"* button.
Widget _buildMyDoneWidget() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('My Done Widget'),
const SizedBox(width: 10.0),
Icon(Icons.arrow_drop_down, size: 20.0),
],
Widget _buildMyDoneWidget(void Function() closeAction) {
return Padding(
padding: const EdgeInsets.all(5.0),
child: InkWell(
onTap: closeAction,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('My Done Widget'),
const SizedBox(width: 10.0),
Icon(Icons.arrow_drop_down, size: 20.0),
],
),
),
);
}
}
38 changes: 15 additions & 23 deletions example/lib/sample4.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,23 @@ class Sample4 extends StatelessWidget {
toolbarAlignment: MainAxisAlignment.spaceAround,
focusNode: _focusSample,
displayArrows: false,
toolbarButtons: [
(_) {
return IconButton(
icon: Icon(Icons.format_bold),
onPressed: () {},
);
},
(_) {
return IconButton(
icon: Icon(Icons.format_italic),
onPressed: () {},
);
},
(_) {
return IconButton(
toolbarButtons: (_, __, ___, ____) => [
IconButton(
icon: Icon(Icons.format_bold),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.format_italic),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.format_underline),
onPressed: () {},
);
},
(_) {
return IconButton(
icon: Icon(Icons.format_strikethrough),
onPressed: () {},
);
},
),
IconButton(
icon: Icon(Icons.format_strikethrough),
onPressed: () {},
),
],
),
],
Expand Down
Loading