Skip to content

Instantly share code, notes, and snippets.

@tiagolpadua
Created August 14, 2021 23:13
Show Gist options
  • Save tiagolpadua/bca9ad56bf549558f609a7eb25d2653c to your computer and use it in GitHub Desktop.
Save tiagolpadua/bca9ad56bf549558f609a7eb25d2653c to your computer and use it in GitHub Desktop.
Credit Card Details
Widget build(BuildContext context) {
final creditCartDetailsViewModel = context.select(
(CreditCartDetailsViewModel model) => model,
);
return Scaffold(
appBar: AppBar(
title: const Text('Pagamento da fatura'),
),
body: Padding(
padding: const EdgeInsets.all(10.0),
child: Form(
key: _formKey,
child: SingleChildScrollView(
child: Column(
children: [
Text("Número do Cartão",
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
TextFormField(
controller: _numberController,
maxLength: 16,
decoration: InputDecoration(border: OutlineInputBorder()),
keyboardType: TextInputType.number,
validator: _notEmpty,
),
Text("Nome do titular do cartão",
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
TextFormField(
controller: _nameController,
decoration: InputDecoration(
border: OutlineInputBorder(),
),
validator: _notEmpty,
),
Row(
children: [
Column(
children: [
Text(
"Validade",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 16),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.4,
child: TextFormField(
controller: _expirationController,
maxLength: 4,
keyboardType: TextInputType.number,
decoration: InputDecoration(
border: OutlineInputBorder(),
),
validator: _notEmpty,
),
),
],
),
Spacer(),
Column(
children: [
Text(
"CVV",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 16),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.4,
child: TextFormField(
controller: _cvvController,
maxLength: 3,
keyboardType: TextInputType.number,
decoration: InputDecoration(
border: OutlineInputBorder(),
),
validator: _notEmpty,
),
),
],
),
],
),
Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Essa transação é 100% segura e com certificados de segurança que garantem a integridade dos seus dados.",
style: TextStyle(color: Colors.grey, fontSize: 16),
),
),
),
Row(
children: [
OutlinedButton(
onPressed: () {
Navigator.pop(context);
},
child: Text("Voltar")),
Spacer(),
Text("2 de 3"),
Spacer(),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
creditCartDetailsViewModel.userCreditCard =
CreditCard(
_nameController.text,
_nameController.text,
_expirationController.text,
_cvvController.text);
Navigator.push(context,
MaterialPageRoute(builder: (context) {
return ConfirmationScreen();
}));
}
},
child: Text("Continuar"))
],
)
],
),
),
),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment