1
1
import 'package:flutter/foundation.dart' ;
2
+ import 'package:flutter/gestures.dart' ;
2
3
import 'package:flutter/material.dart' ;
3
4
import 'package:supabase_auth_ui/supabase_auth_ui.dart' ;
4
5
5
6
import 'constants.dart' ;
6
7
7
8
class SignUp extends StatelessWidget {
8
9
const SignUp ({Key ? key}) : super (key: key);
9
-
10
10
@override
11
11
Widget build (BuildContext context) {
12
+ void navigateHome (AuthResponse response) {
13
+ Navigator .of (context).pushReplacementNamed ('/home' );
14
+ }
15
+
16
+ final darkModeThemeData = ThemeData .dark ().copyWith (
17
+ colorScheme: const ColorScheme .dark (
18
+ primary: Color .fromARGB (248 , 183 , 183 , 183 ), // text below main button
19
+ ),
20
+ textSelectionTheme: TextSelectionThemeData (
21
+ cursorColor: Colors .blueGrey[300 ], // cursor when typing
22
+ ),
23
+ inputDecorationTheme: InputDecorationTheme (
24
+ fillColor: Colors .grey[800 ], // background of text entry
25
+ filled: true ,
26
+ border: OutlineInputBorder (
27
+ borderRadius: BorderRadius .circular (8 ),
28
+ borderSide: BorderSide .none,
29
+ ),
30
+ labelStyle: const TextStyle (
31
+ color:
32
+ Color .fromARGB (179 , 255 , 255 , 255 )), // text labeling text entry
33
+ ),
34
+ elevatedButtonTheme: ElevatedButtonThemeData (
35
+ style: ElevatedButton .styleFrom (
36
+ backgroundColor:
37
+ const Color .fromARGB (255 , 22 , 135 , 188 ), // main button
38
+ foregroundColor:
39
+ const Color .fromARGB (255 , 255 , 255 , 255 ), // main button text
40
+ shape: RoundedRectangleBorder (
41
+ borderRadius: BorderRadius .circular (8 ),
42
+ ),
43
+ ),
44
+ ),
45
+ );
46
+
12
47
return Scaffold (
13
48
appBar: appBar ('Sign In' ),
14
49
body: ListView (
15
50
padding: const EdgeInsets .all (24.0 ),
16
51
children: [
17
52
SupaEmailAuth (
18
53
redirectTo: kIsWeb ? null : 'io.supabase.flutter://' ,
19
- onSignInComplete: (response) {
20
- Navigator .of (context).pushReplacementNamed ('/home' );
21
- },
22
- onSignUpComplete: (response) {
23
- Navigator .of (context).pushReplacementNamed ('/home' );
24
- },
54
+ onSignInComplete: navigateHome,
55
+ onSignUpComplete: navigateHome,
25
56
metadataFields: [
26
57
MetaDataField (
27
58
prefixIcon: const Icon (Icons .person),
@@ -34,8 +65,97 @@ class SignUp extends StatelessWidget {
34
65
return null ;
35
66
},
36
67
),
68
+ BooleanMetaDataField (
69
+ label: 'Keep me up to date with the latest news and updates.' ,
70
+ key: 'marketing_consent' ,
71
+ checkboxPosition: ListTileControlAffinity .leading,
72
+ ),
73
+ BooleanMetaDataField (
74
+ key: 'terms_agreement' ,
75
+ isRequired: true ,
76
+ checkboxPosition: ListTileControlAffinity .leading,
77
+ richLabelSpans: [
78
+ const TextSpan (text: 'I have read and agree to the ' ),
79
+ TextSpan (
80
+ text: 'Terms and Conditions' ,
81
+ style: const TextStyle (
82
+ color: Colors .blue,
83
+ ),
84
+ recognizer: TapGestureRecognizer ()
85
+ ..onTap = () {
86
+ // Handle tap on Terms and Conditions
87
+ },
88
+ ),
89
+ ],
90
+ ),
37
91
],
38
92
),
93
+
94
+ const Divider (),
95
+ optionText,
96
+ spacer,
97
+
98
+ // Dark theme example
99
+ Card (
100
+ elevation: 10 ,
101
+ color: const Color .fromARGB (255 , 24 , 24 , 24 ),
102
+ child: Padding (
103
+ padding: const EdgeInsets .all (30 ),
104
+ child: Theme (
105
+ data: darkModeThemeData,
106
+ child: SupaEmailAuth (
107
+ redirectTo: kIsWeb ? null : 'io.supabase.flutter://' ,
108
+ onSignInComplete: navigateHome,
109
+ onSignUpComplete: navigateHome,
110
+ prefixIconEmail: null ,
111
+ prefixIconPassword: null ,
112
+ localization: const SupaEmailAuthLocalization (
113
+ enterEmail: "email" ,
114
+ enterPassword: "password" ,
115
+ dontHaveAccount: "sign up" ,
116
+ forgotPassword: "forgot password" ),
117
+ metadataFields: [
118
+ MetaDataField (
119
+ prefixIcon: const Icon (Icons .person),
120
+ label: 'Username' ,
121
+ key: 'username' ,
122
+ validator: (val) {
123
+ if (val == null || val.isEmpty) {
124
+ return 'Please enter something' ;
125
+ }
126
+ return null ;
127
+ },
128
+ ),
129
+ BooleanMetaDataField (
130
+ label:
131
+ 'Keep me up to date with the latest news and updates.' ,
132
+ key: 'marketing_consent' ,
133
+ checkboxPosition: ListTileControlAffinity .leading,
134
+ ),
135
+ BooleanMetaDataField (
136
+ key: 'terms_agreement' ,
137
+ isRequired: true ,
138
+ checkboxPosition: ListTileControlAffinity .leading,
139
+ richLabelSpans: [
140
+ const TextSpan (
141
+ text: 'I have read and agree to the ' ),
142
+ TextSpan (
143
+ text: 'Terms and Conditions.' ,
144
+ style: const TextStyle (
145
+ color: Colors .blue,
146
+ ),
147
+ recognizer: TapGestureRecognizer ()
148
+ ..onTap = () {
149
+ //ignore: avoid_print
150
+ print ('Terms and Conditions' );
151
+ },
152
+ ),
153
+ ],
154
+ ),
155
+ ]),
156
+ ),
157
+ )),
158
+
39
159
const Divider (),
40
160
optionText,
41
161
spacer,
0 commit comments