Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
9.5 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:pointycastle/api.dart';
  3. class Signup extends StatelessWidget {
  4. const Signup({Key? key}) : super(key: key);
  5. static const String _title = 'Envelope';
  6. @override
  7. Widget build(BuildContext context) {
  8. return MaterialApp(
  9. title: _title,
  10. home: Scaffold(
  11. backgroundColor: Colors.cyan,
  12. appBar: AppBar(
  13. title: null,
  14. automaticallyImplyLeading: true,
  15. //`true` if you want Flutter to automatically add Back Button when needed,
  16. //or `false` if you want to force your own back button every where
  17. leading: IconButton(icon: const Icon(Icons.arrow_back),
  18. //onPressed:() => Navigator.pop(context, false),
  19. onPressed:() => {
  20. Navigator.pop(context)
  21. }
  22. )
  23. ),
  24. body: const SafeArea(
  25. child: SignupWidget(),
  26. )
  27. ),
  28. theme: ThemeData(
  29. appBarTheme: const AppBarTheme(
  30. backgroundColor: Colors.cyan,
  31. elevation: 0,
  32. ),
  33. inputDecorationTheme: const InputDecorationTheme(
  34. border: OutlineInputBorder(),
  35. focusedBorder: OutlineInputBorder(),
  36. labelStyle: TextStyle(
  37. color: Colors.white,
  38. fontSize: 30,
  39. ),
  40. filled: true,
  41. fillColor: Colors.white,
  42. ),
  43. ),
  44. );
  45. }
  46. }
  47. class SignupWidget extends StatefulWidget {
  48. const SignupWidget({Key? key}) : super(key: key);
  49. @override
  50. State<SignupWidget> createState() => _SignupWidgetState();
  51. }
  52. class _SignupWidgetState extends State<SignupWidget> {
  53. final _formKey = GlobalKey<FormState>();
  54. TextEditingController usernameController = TextEditingController();
  55. TextEditingController passwordController = TextEditingController();
  56. TextEditingController passwordConfirmController = TextEditingController();
  57. @override
  58. Widget build(BuildContext context) {
  59. const TextStyle _inputTextStyle = TextStyle(fontSize: 18, color: Colors.black);
  60. final ButtonStyle _buttonStyle = ElevatedButton.styleFrom(
  61. primary: Colors.white,
  62. onPrimary: Colors.cyan,
  63. minimumSize: const Size.fromHeight(50),
  64. padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
  65. textStyle: const TextStyle(
  66. fontSize: 20,
  67. fontWeight: FontWeight.bold,
  68. color: Colors.red,
  69. ),
  70. );
  71. return Center(
  72. child: Form(
  73. key: _formKey,
  74. child: Center(
  75. child: Padding(
  76. padding: const EdgeInsets.all(15),
  77. child: Column(
  78. mainAxisAlignment: MainAxisAlignment.center,
  79. crossAxisAlignment: CrossAxisAlignment.center,
  80. children: [
  81. const Text('Sign Up', style: TextStyle(fontSize: 35, color: Colors.white),),
  82. const SizedBox(height: 30),
  83. TextFormField(
  84. controller: usernameController,
  85. decoration: const InputDecoration(
  86. hintText: 'Username',
  87. ),
  88. style: _inputTextStyle,
  89. // The validator receives the text that the user has entered.
  90. validator: (value) {
  91. if (value == null || value.isEmpty) {
  92. return 'Create a username';
  93. }
  94. return null;
  95. },
  96. ),
  97. const SizedBox(height: 5),
  98. TextFormField(
  99. controller: passwordController,
  100. obscureText: true,
  101. enableSuggestions: false,
  102. autocorrect: false,
  103. decoration: const InputDecoration(
  104. hintText: 'Password',
  105. ),
  106. style: _inputTextStyle,
  107. // The validator receives the text that the user has entered.
  108. validator: (value) {
  109. if (value == null || value.isEmpty) {
  110. return 'Enter a password';
  111. }
  112. return null;
  113. },
  114. ),
  115. const SizedBox(height: 5),
  116. TextFormField(
  117. controller: passwordConfirmController,
  118. obscureText: true,
  119. enableSuggestions: false,
  120. autocorrect: false,
  121. decoration: const InputDecoration(
  122. hintText: 'Password',
  123. ),
  124. style: _inputTextStyle,
  125. // The validator receives the text that the user has entered.
  126. validator: (value) {
  127. if (value == null || value.isEmpty) {
  128. return 'Confirm your password';
  129. }
  130. if (value != passwordController.text) {
  131. return 'Passwords do not match';
  132. }
  133. return null;
  134. },
  135. ),
  136. const SizedBox(height: 5),
  137. ElevatedButton(
  138. style: _buttonStyle,
  139. onPressed: () {
  140. if (_formKey.currentState!.validate()) {
  141. ScaffoldMessenger.of(context).showSnackBar(
  142. const SnackBar(content: Text('Processing Data')),
  143. );
  144. signup(context);
  145. }
  146. },
  147. child: const Text('Submit'),
  148. ),
  149. ],
  150. )
  151. )
  152. )
  153. )
  154. );
  155. }
  156. }
  157. void signup(context) {
  158. }