-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from finkmoritz/develop
Develop
- Loading branch information
Showing
11 changed files
with
140 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart'; | ||
import 'package:amplify_flutter/amplify.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class ConfirmationCodeDialog extends StatefulWidget { | ||
final void Function(BuildContext) onSignIn; | ||
|
||
const ConfirmationCodeDialog({Key? key, required this.onSignIn}) | ||
: super(key: key); | ||
|
||
@override | ||
_ConfirmationCodeDialogState createState() => _ConfirmationCodeDialogState(); | ||
} | ||
|
||
class _ConfirmationCodeDialogState extends State<ConfirmationCodeDialog> { | ||
final TextEditingController _confirmationCodeController = | ||
TextEditingController(); | ||
|
||
@override | ||
void dispose() { | ||
_confirmationCodeController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AlertDialog( | ||
title: const Text('Confirmation Code'), | ||
content: SingleChildScrollView( | ||
child: Column( | ||
children: [ | ||
Text('Please enter the confirmation code we sent you.'), | ||
TextFormField( | ||
controller: _confirmationCodeController, | ||
keyboardType: TextInputType.number, | ||
decoration: InputDecoration( | ||
icon: Icon(Icons.check_outlined), | ||
hintText: 'Enter your confirmation code', | ||
labelText: 'Confirmation code'), | ||
), | ||
], | ||
), | ||
), | ||
actions: [ | ||
TextButton( | ||
onPressed: () { | ||
Navigator.of(context).pop(); | ||
}, | ||
child: const Text('Cancel'), | ||
), | ||
ElevatedButton( | ||
onPressed: () { | ||
_confirm(); | ||
}, | ||
child: const Text('Sign In'), | ||
), | ||
], | ||
); | ||
} | ||
|
||
void _confirm() async { | ||
try { | ||
SignInResult result = await Amplify.Auth.confirmSignIn( | ||
confirmationValue: _confirmationCodeController.text.trim(), | ||
); | ||
if (result.isSignedIn) { | ||
Navigator.of(context).pop(); | ||
widget.onSignIn(context); | ||
} | ||
} on AuthException catch (e) { | ||
ScaffoldMessenger.of(context) | ||
.showSnackBar(SnackBar(content: Text(e.message))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters