Untitled
unknown
plain_text
2 years ago
3.9 kB
10
Indexable
import "package:flutter/material.dart";
class Klavye extends StatefulWidget {
final Function(String) onTextInput;
final Function onDelete;
final Function onDone;
final Color background1;
final Color background2;
const Klavye({
super.key,
required this.onTextInput,
required this.onDelete,
required this.onDone,
required this.background1,
required this.background2,
});
@override
State<Klavye> createState() => _KlavyeState();
}
class _KlavyeState extends State<Klavye> {
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
widget.background1,
widget.background2,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
padding: const EdgeInsets.only(bottom: 15),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
buildRow(
['Q', 'W', 'E', 'R', 'T', 'Y', "U", "ı", "O", "P", "Ğ", "Ü"],
),
buildRow(
['A', 'S', 'D', 'F', 'G', 'H', 'J', "K", "L", "Ş", "i"],
),
buildRow(
['Z', 'X', 'C', 'V', 'B', 'N', 'M', "Ö", "Ç", "SİL"],
isDeleteRow: true,
),
],
),
);
}
Widget buildRow(
List<String> keys, {
MainAxisSize mainAxisSize = MainAxisSize.min,
bool isDeleteRow = false,
}) {
final size = MediaQuery.of(context).size;
double harfGenislik = size.width / 12;
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
widget.background1,
widget.background2,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
width: isDeleteRow
? (keys.length * harfGenislik * 2)
: keys.length * harfGenislik,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: mainAxisSize,
children: keys.map((String key) {
return Flexible(
child: InkWell(
onTap: () {
if (key == 'Tamam') {
widget.onDone();
} else if (key == 'SİL') {
widget.onDelete();
} else {
widget.onTextInput(key);
}
},
child: Card(
elevation: 2.0,
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 1),
child: Container(
alignment: Alignment.center,
height: harfGenislik + 13,
width: (key == 'SİL') ? (harfGenislik * 3) : harfGenislik,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
child: Container(
alignment: Alignment.center,
height: harfGenislik + 13,
width: (key == 'SİL') ? (harfGenislik * 3) : harfGenislik,
child: key == 'SİL'
? Icon(
Icons.backspace_outlined,
size: 18,
color: Colors.orange.shade600,
)
: Text(
key,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
),
);
}).toList(),
),
);
}
}
Editor is loading...
Leave a Comment