diff --git a/CHANGELOG.md b/CHANGELOG.md index c8198a5..14eaa42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ * Fixed the bug with backspace key. -## [0.2.1] - 19/03/2020. +## [0.2.2] - 19/03/2020. * Adding multi-language support. * Customizable layout. \ No newline at end of file diff --git a/README.md b/README.md index 58a2db9..c251dfd 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,10 @@ VirtualKeyboardLayoutKeys customLayoutKeys; /// will be ignored if customLayoutKeys is not null List defaultLayouts; ``` +```dart +/// inverse the layout to fix the issues with right to left languages, default is false. +bool reverseLayout; +``` ### VirtualKeyboardType enum of Available Virtual Keyboard Types. diff --git a/example/lib/main.dart b/example/lib/main.dart index dce9c9b..d4543aa 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -87,6 +87,7 @@ class _MyHomePageState extends State { textController: _controllerText, //customLayoutKeys: _customLayoutKeys, defaultLayouts: [VirtualKeyboardDefaultLayouts.Arabic,VirtualKeyboardDefaultLayouts.English], + //reverseLayout :true, type: isNumericMode ? VirtualKeyboardType.Numeric : VirtualKeyboardType.Alphanumeric, diff --git a/lib/src/keyboard.dart b/lib/src/keyboard.dart index 8464b65..6c137a1 100644 --- a/lib/src/keyboard.dart +++ b/lib/src/keyboard.dart @@ -38,6 +38,9 @@ class VirtualKeyboard extends StatefulWidget { /// Set to true if you want only to show Caps letters. final bool alwaysCaps; + /// inverse the layout to fix the issues with right to left languages. + final bool reverseLayout; + /// used for multi-languages with default layouts, the default is English only /// will be ignored if customLayoutKeys is not null final List defaultLayouts; @@ -51,6 +54,7 @@ class VirtualKeyboard extends StatefulWidget { this.defaultLayouts, this.customLayoutKeys, this.textController, + this.reverseLayout = false, this.height = _virtualKeyboardDefaultHeight, this.textColor = Colors.black, this.fontSize = 14, @@ -75,6 +79,7 @@ class _VirtualKeyboardState extends State { Color textColor; double fontSize; bool alwaysCaps; + bool reverseLayout; VirtualKeyboardLayoutKeys customLayoutKeys; // Text Style for keys. TextStyle textStyle; @@ -126,6 +131,7 @@ class _VirtualKeyboardState extends State { textColor = widget.textColor; fontSize = widget.fontSize; alwaysCaps = widget.alwaysCaps; + reverseLayout = widget.reverseLayout ?? false; textController = widget.textController ?? textController; customLayoutKeys = widget.customLayoutKeys ?? customLayoutKeys ; // Init the Text Style for keys. @@ -149,7 +155,7 @@ class _VirtualKeyboardState extends State { textColor = widget.textColor; fontSize = widget.fontSize; alwaysCaps = widget.alwaysCaps; - + reverseLayout = widget.reverseLayout ?? false; // Init the Text Style for keys. textStyle = TextStyle( fontSize: fontSize, @@ -196,13 +202,7 @@ class _VirtualKeyboardState extends State { // Generate keyboard row. List rows = List.generate(keyboardRows.length, (int rowNum) { - return Material( - color: Colors.transparent, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - // Generate keboard keys - children: List.generate( + var items =List.generate( keyboardRows[rowNum].length, (int keyNum) { // Get the VirtualKeyboardKey object. @@ -236,8 +236,17 @@ class _VirtualKeyboardState extends State { } return keyWidget; - }, - ), + }); + + if(this.reverseLayout) + items = items.reversed.toList(); + return Material( + color: Colors.transparent, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + // Generate keboard keys + children: items, ), ); }); diff --git a/pubspec.yaml b/pubspec.yaml index 652cadf..1a2b76c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: virtual_keyboard_multi_language description: A simple package for dispaying virtual keyboards on a devices like kiosks and ATMs. The library is written in Dart and has no native code dependancy. -version: 0.2.1 -author: Ahmed El-Araby +version: 0.2.2 +#author: Ahmed El-Araby homepage: https://github.com/ahmed-eg/virtual_keyboard_multi_language environment: