option to reverse the Layout

This commit is contained in:
Ahmed El-Araby 2020-03-19 17:10:33 +03:00
parent f5c6e2be5a
commit 4e823d35b8
5 changed files with 27 additions and 13 deletions

View File

@ -18,7 +18,7 @@
* Fixed the bug with backspace key. * Fixed the bug with backspace key.
## [0.2.1] - 19/03/2020. ## [0.2.2] - 19/03/2020.
* Adding multi-language support. * Adding multi-language support.
* Customizable layout. * Customizable layout.

View File

@ -68,6 +68,10 @@ VirtualKeyboardLayoutKeys customLayoutKeys;
/// will be ignored if customLayoutKeys is not null /// will be ignored if customLayoutKeys is not null
List<VirtualKeyboardDefaultLayouts> defaultLayouts; List<VirtualKeyboardDefaultLayouts> defaultLayouts;
``` ```
```dart
/// inverse the layout to fix the issues with right to left languages, default is false.
bool reverseLayout;
```
### VirtualKeyboardType ### VirtualKeyboardType
enum of Available Virtual Keyboard Types. enum of Available Virtual Keyboard Types.

View File

@ -87,6 +87,7 @@ class _MyHomePageState extends State<MyHomePage> {
textController: _controllerText, textController: _controllerText,
//customLayoutKeys: _customLayoutKeys, //customLayoutKeys: _customLayoutKeys,
defaultLayouts: [VirtualKeyboardDefaultLayouts.Arabic,VirtualKeyboardDefaultLayouts.English], defaultLayouts: [VirtualKeyboardDefaultLayouts.Arabic,VirtualKeyboardDefaultLayouts.English],
//reverseLayout :true,
type: isNumericMode type: isNumericMode
? VirtualKeyboardType.Numeric ? VirtualKeyboardType.Numeric
: VirtualKeyboardType.Alphanumeric, : VirtualKeyboardType.Alphanumeric,

View File

@ -38,6 +38,9 @@ class VirtualKeyboard extends StatefulWidget {
/// Set to true if you want only to show Caps letters. /// Set to true if you want only to show Caps letters.
final bool alwaysCaps; 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 /// used for multi-languages with default layouts, the default is English only
/// will be ignored if customLayoutKeys is not null /// will be ignored if customLayoutKeys is not null
final List<VirtualKeyboardDefaultLayouts> defaultLayouts; final List<VirtualKeyboardDefaultLayouts> defaultLayouts;
@ -51,6 +54,7 @@ class VirtualKeyboard extends StatefulWidget {
this.defaultLayouts, this.defaultLayouts,
this.customLayoutKeys, this.customLayoutKeys,
this.textController, this.textController,
this.reverseLayout = false,
this.height = _virtualKeyboardDefaultHeight, this.height = _virtualKeyboardDefaultHeight,
this.textColor = Colors.black, this.textColor = Colors.black,
this.fontSize = 14, this.fontSize = 14,
@ -75,6 +79,7 @@ class _VirtualKeyboardState extends State<VirtualKeyboard> {
Color textColor; Color textColor;
double fontSize; double fontSize;
bool alwaysCaps; bool alwaysCaps;
bool reverseLayout;
VirtualKeyboardLayoutKeys customLayoutKeys; VirtualKeyboardLayoutKeys customLayoutKeys;
// Text Style for keys. // Text Style for keys.
TextStyle textStyle; TextStyle textStyle;
@ -126,6 +131,7 @@ class _VirtualKeyboardState extends State<VirtualKeyboard> {
textColor = widget.textColor; textColor = widget.textColor;
fontSize = widget.fontSize; fontSize = widget.fontSize;
alwaysCaps = widget.alwaysCaps; alwaysCaps = widget.alwaysCaps;
reverseLayout = widget.reverseLayout ?? false;
textController = widget.textController ?? textController; textController = widget.textController ?? textController;
customLayoutKeys = widget.customLayoutKeys ?? customLayoutKeys ; customLayoutKeys = widget.customLayoutKeys ?? customLayoutKeys ;
// Init the Text Style for keys. // Init the Text Style for keys.
@ -149,7 +155,7 @@ class _VirtualKeyboardState extends State<VirtualKeyboard> {
textColor = widget.textColor; textColor = widget.textColor;
fontSize = widget.fontSize; fontSize = widget.fontSize;
alwaysCaps = widget.alwaysCaps; alwaysCaps = widget.alwaysCaps;
reverseLayout = widget.reverseLayout ?? false;
// Init the Text Style for keys. // Init the Text Style for keys.
textStyle = TextStyle( textStyle = TextStyle(
fontSize: fontSize, fontSize: fontSize,
@ -196,13 +202,7 @@ class _VirtualKeyboardState extends State<VirtualKeyboard> {
// Generate keyboard row. // Generate keyboard row.
List<Widget> rows = List.generate(keyboardRows.length, (int rowNum) { List<Widget> rows = List.generate(keyboardRows.length, (int rowNum) {
return Material( var items =List.generate(
color: Colors.transparent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
// Generate keboard keys
children: List.generate(
keyboardRows[rowNum].length, keyboardRows[rowNum].length,
(int keyNum) { (int keyNum) {
// Get the VirtualKeyboardKey object. // Get the VirtualKeyboardKey object.
@ -236,8 +236,17 @@ class _VirtualKeyboardState extends State<VirtualKeyboard> {
} }
return keyWidget; 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,
), ),
); );
}); });

View File

@ -1,7 +1,7 @@
name: virtual_keyboard_multi_language 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. 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 version: 0.2.2
author: Ahmed El-Araby <ahmed-eg@live.com> #author: Ahmed El-Araby <ahmed-eg@live.com>
homepage: https://github.com/ahmed-eg/virtual_keyboard_multi_language homepage: https://github.com/ahmed-eg/virtual_keyboard_multi_language
environment: environment: