56 lines
1.7 KiB
Dart
56 lines
1.7 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
class Dialpad extends StatelessWidget {
|
||
|
|
final void Function(String digit) onDigit;
|
||
|
|
final VoidCallback onClose;
|
||
|
|
|
||
|
|
const Dialpad({super.key, required this.onDigit, required this.onClose});
|
||
|
|
|
||
|
|
static const _keys = [
|
||
|
|
['1', '2', '3'],
|
||
|
|
['4', '5', '6'],
|
||
|
|
['7', '8', '9'],
|
||
|
|
['*', '0', '#'],
|
||
|
|
];
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Padding(
|
||
|
|
padding: const EdgeInsets.symmetric(horizontal: 48),
|
||
|
|
child: Column(
|
||
|
|
mainAxisSize: MainAxisSize.min,
|
||
|
|
children: [
|
||
|
|
..._keys.map((row) => Row(
|
||
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||
|
|
children: row
|
||
|
|
.map((key) => Padding(
|
||
|
|
padding: const EdgeInsets.all(4),
|
||
|
|
child: InkWell(
|
||
|
|
onTap: () => onDigit(key),
|
||
|
|
borderRadius: BorderRadius.circular(40),
|
||
|
|
child: Container(
|
||
|
|
width: 64,
|
||
|
|
height: 64,
|
||
|
|
alignment: Alignment.center,
|
||
|
|
child: Text(
|
||
|
|
key,
|
||
|
|
style: Theme.of(context)
|
||
|
|
.textTheme
|
||
|
|
.headlineSmall,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
))
|
||
|
|
.toList(),
|
||
|
|
)),
|
||
|
|
const SizedBox(height: 8),
|
||
|
|
TextButton(
|
||
|
|
onPressed: onClose,
|
||
|
|
child: const Text('Close'),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|