-
Notifications
You must be signed in to change notification settings - Fork 497
/
Copy pathpin_widget.dart
87 lines (79 loc) · 2.6 KB
/
pin_widget.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import 'package:flutter/material.dart';
import 'package:flutter_paystack/src/widgets/base_widget.dart';
import 'package:flutter_paystack/src/widgets/common/extensions.dart';
import 'package:flutter_paystack/src/widgets/custom_dialog.dart';
import 'package:flutter_paystack/src/widgets/input/pin_field.dart';
import 'buttons.dart';
class PinWidget extends StatefulWidget {
@override
_PinWidgetState createState() => _PinWidgetState();
}
class _PinWidgetState extends BaseState<PinWidget> {
var heightBox = const SizedBox(height: 20.0);
@override
void initState() {
confirmationMessage = 'Do you want to cancel PIN input?';
super.initState();
}
@override
Widget buildChild(BuildContext context) {
return new CustomAlertDialog(
content: new SingleChildScrollView(
child: new Container(
padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
buildStar(),
heightBox,
Text(
'To confirm you\'re the owner of this card, please '
'enter your card pin.',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.w500,
color: context.textTheme().titleLarge?.color,
fontSize: 15.0,
),
),
heightBox,
new PinField(
onSaved: (String pin) => Navigator.of(context).pop(pin)),
heightBox,
new WhiteButton(
onPressed: onCancelPress,
text: 'Cancel',
flat: true,
bold: true,
),
],
),
),
),
);
}
Widget buildStar() {
Icon star(Color color) => new Icon(
Icons.star,
color: color,
size: 12.0,
);
return new Container(
padding: const EdgeInsets.fromLTRB(6.0, 15.0, 6.0, 6.0),
decoration: BoxDecoration(
color: Theme.of(context).primaryColorDark,
borderRadius: const BorderRadius.all(Radius.circular(5.0))),
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: List.generate(
_startCount,
(i) => star(i == (_startCount - 1)
? context.colorScheme().secondary
: Theme.of(context).primaryColorLight)),
),
);
}
}
const _startCount = 4;