Skip to content

Commit

Permalink
loosely cyrillic support
Browse files Browse the repository at this point in the history
  • Loading branch information
vonqo committed Oct 30, 2020
1 parent 875ba8b commit c3fbf53
Show file tree
Hide file tree
Showing 12 changed files with 448 additions and 175 deletions.
1 change: 1 addition & 0 deletions .idea/libraries/Flutter_Plugins.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 20 additions & 12 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import 'package:block_input/block_input.dart';

```dart
BlockInput(
blockInputController: blockInputController,
blockInputKeyboardType: BlockInputKeyboardType.number, // Number or Text
controller: blockInputController,
keyboardType: BlockInputKeyboardType.number, // Number or Text
axisAlignment: MainAxisAlignment.spaceBetween, // Same as Row/Column MainAxisAlignment
blockInputStyle: BlockInputStyle(
backgroundColor: Colors.black12, // Color
Expand All @@ -34,6 +34,32 @@ BlockInput(
)
)
```
### Cyrillic support
Mongolian cyrillic input is **loosely** supported for now. This feature will help you to build Mongolian Registration No input. Cyrillic input triggers custom keyboard layout. Usage:

```dart
BlockInput(
keyboardType: BlockInputKeyboardType.mnCyrillic
...
)
```
Cyrillic keyboard styling:
```dart
BlockInputStyle(
keyboardStyle: BlockKeyboardStyle(
keyColor: Colors.blueAccent,
backgroundColor: Colors.white,
width: 40,
height: 40,
textStyle: TextStyle(),
keyShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: Colors.red)
),
),
...
),
```

## Controller and Listener

Expand All @@ -60,6 +86,7 @@ blockInputController.dispose();
```

## Attributes

### BlockInput
| Attribute | Type |
|------------------------|------------------------|
Expand All @@ -70,6 +97,8 @@ blockInputController.dispose();
| errorMessageStyle | TextStyle |
| axisAlignment | MainAxisAlignment |



### BlockInputStyle
| Attribute | Type |
|-----------------|--------------------|
Expand All @@ -79,6 +108,9 @@ blockInputController.dispose();
| padding | EdgeInsets |
| width | double |
| textStyle | TextStyle |
| keyboardStyle | BlockKeyboardStyle |



## Licence
**Apache License version 2.0**
Expand Down
229 changes: 123 additions & 106 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:math';
import 'package:block_input/block_input_controller.dart';
import 'package:block_input/block_input_keyboard_type.dart';
import 'package:block_input/block_input_style.dart';
import 'package:block_input/block_keyboard_style.dart';
import 'package:flutter/material.dart';

import 'package:block_input/block_input.dart';
Expand Down Expand Up @@ -44,100 +45,96 @@ class _MyAppState extends State<MyApp> {

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Block Input Example'),
),
body: SingleChildScrollView(
child: Column(
children: [
Container(
padding: EdgeInsets.all(10),
child: BlockInput(
blockInputController: blockInputController,
blockInputKeyboardType: BlockInputKeyboardType.number,
axisAlignment: MainAxisAlignment.spaceBetween,
blockInputStyle: BlockInputStyle(
backgroundColor: Colors.black12,
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
borderSide: BorderSide(color: Colors.deepOrange, width: 1)
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
borderSide: BorderSide(color: Colors.blueAccent, width: 2)
)
),
),
),
Container(
padding: EdgeInsets.all(10),
child: Row(
children: [
RaisedButton(
child: Text('CLEAR'),
onPressed: () {
blockInputController.clear();
},
),
SizedBox(width: 10,),
RaisedButton(
child: Text('RANDOM FILL'),
onPressed: () {
Random rand = Random();
StringBuffer strBuffer = StringBuffer();
for(int i = 0; i < blockInputController.size; i++) {
strBuffer.write(rand.nextInt(9).toString());
}
blockInputController.text = strBuffer.toString();
},
),
SizedBox(width: 10,),
RaisedButton(
child: Text('TEST'),
onPressed: () {
blockInputController.text = 'MARAAAAAAA';
},
)
],
),
),

// ------ MONGOLIAN REGISTER NO DEMO ------
Divider(),
Container(
padding: EdgeInsets.all(10),
child: Row(
children: [
Container(
width: 90,
child: BlockInput(
blockInputController: cyrillicInputController,
blockInputKeyboardType: BlockInputKeyboardType.mnCyrillic,
axisAlignment: MainAxisAlignment.spaceBetween,
blockInputStyle: BlockInputStyle(
backgroundColor: Colors.white,
return GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
child: MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Block Input Example'),
),
body: SingleChildScrollView(
child: Column(
children: [
Container(
padding: EdgeInsets.all(10),
child: BlockInput(
controller: blockInputController,
keyboardType: BlockInputKeyboardType.number,
axisAlignment: MainAxisAlignment.spaceBetween,
style: BlockInputStyle(
backgroundColor: Colors.black12,
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(7)),
borderSide: BorderSide(color: Colors.blueGrey, width: 1)
borderRadius: BorderRadius.all(Radius.circular(10)),
borderSide: BorderSide(color: Colors.deepOrange, width: 1)
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(7)),
borderSide: BorderSide(color: Colors.blue, width: 3)
borderRadius: BorderRadius.all(Radius.circular(10)),
borderSide: BorderSide(color: Colors.blueAccent, width: 2)
)
),
),
),
SizedBox(width: 10,),
Container(
child: Expanded(
child: TextField(
controller: numberInputController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 0, horizontal: 5),
enabledBorder: OutlineInputBorder(
),
Container(
padding: EdgeInsets.all(10),
child: Row(
children: [
RaisedButton(
child: Text('CLEAR'),
onPressed: () {
blockInputController.clear();
},
),
SizedBox(width: 10,),
RaisedButton(
child: Text('RANDOM FILL'),
onPressed: () {
Random rand = Random();
StringBuffer strBuffer = StringBuffer();
for(int i = 0; i < blockInputController.size; i++) {
strBuffer.write(rand.nextInt(9).toString());
}
blockInputController.text = strBuffer.toString();
},
),
SizedBox(width: 10,),
RaisedButton(
child: Text('TEST'),
onPressed: () {
blockInputController.text = 'MARAAAAAAA';
},
)
],
),
),

// ------ MONGOLIAN REGISTER NO DEMO ------
Divider(),
Container(
padding: EdgeInsets.all(10),
child: Row(
children: [
Container(
width: 90,
child: BlockInput(
controller: cyrillicInputController,
keyboardType: BlockInputKeyboardType.mnCyrillic,
axisAlignment: MainAxisAlignment.spaceBetween,
style: BlockInputStyle(
keyboardStyle: BlockKeyboardStyle(
keyColor: Colors.blueAccent,
backgroundColor: Colors.white,
width: 40,
height: 40,
textStyle: TextStyle(),
keyShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: Colors.red)
),
),
backgroundColor: Colors.white,
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(7)),
borderSide: BorderSide(color: Colors.blueGrey, width: 1)
),
Expand All @@ -147,27 +144,47 @@ class _MyAppState extends State<MyApp> {
)
),
),
),
SizedBox(width: 10,),
Container(
child: Expanded(
child: TextField(
controller: numberInputController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 0, horizontal: 5),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(7)),
borderSide: BorderSide(color: Colors.blueGrey, width: 1)
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(7)),
borderSide: BorderSide(color: Colors.blue, width: 3)
)
),
),
)
)
)
],
),
),
Container(
padding: EdgeInsets.all(10),
child: Row(
children: [
RaisedButton(
child: Text('GET REGISTER'),
onPressed: () {
print(cyrillicInputController.text + numberInputController.text);
},
],
),
),
Container(
padding: EdgeInsets.all(10),
child: Row(
children: [
RaisedButton(
child: Text('GET REGISTER'),
onPressed: () {
print(cyrillicInputController.text + numberInputController.text);
},
),
],
),
],
),
),
],
),
],
),
)
)
),
),
);
}
Expand Down
Loading

0 comments on commit c3fbf53

Please sign in to comment.