-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.dart
241 lines (228 loc) · 7.38 KB
/
main.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
// import 'package:flutter/material.dart';
// import 'package:katana_auth/katana_auth.dart';
// void main() {
// runApp(const MyApp());
// }
// class MyApp extends StatelessWidget {
// const MyApp({super.key});
// @override
// Widget build(BuildContext context) {
// return AuthAdapterScope(
// adapter: const RuntimeAuthAdapter(),
// child: MaterialApp(
// home: const AuthPage(),
// title: "Flutter Demo",
// theme: ThemeData(
// primarySwatch: Colors.blue,
// ),
// ),
// );
// }
// }
// class AuthPage extends StatefulWidget {
// const AuthPage({super.key});
// @override
// State<StatefulWidget> createState() => AuthPageState();
// }
// class AuthPageState extends State<AuthPage> {
// final auth = Authentication();
// @override
// void initState() {
// super.initState();
// auth.addListener(_handledOnUpdate);
// }
// void _handledOnUpdate() {
// setState(() {});
// }
// @override
// void dispose() {
// super.dispose();
// auth.removeListener(_handledOnUpdate);
// auth.dispose();
// }
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(title: const Text("App Demo")),
// body: ListView(
// children: [
// ListTile(
// title: Text("SignedIn: ${auth.isSignedIn}"),
// ),
// ListTile(
// title: Text("Anonymously: ${auth.isAnonymously}"),
// ),
// ListTile(
// title: Text("ID: ${auth.userId}"),
// ),
// ListTile(
// title: Text("Email: ${auth.userEmail}"),
// ),
// ListTile(
// title: Text("Phone: ${auth.userPhoneNumber}"),
// ),
// ListTile(
// title: Text("Providers: ${auth.activeProviderIds.join("\n")}"),
// ),
// ],
// ),
// floatingActionButton: FloatingActionButton(
// onPressed: () {
// Navigator.of(context).push(MaterialPageRoute(
// builder: (_) {
// return AuthControlPage(auth: auth);
// },
// ));
// },
// child: const Icon(Icons.person),
// ),
// );
// }
// }
// class AuthControlPage extends StatelessWidget {
// const AuthControlPage({
// required this.auth,
// super.key,
// });
// final Authentication auth;
// @override
// Widget build(BuildContext context) {
// final navigator = Navigator.of(context);
// return Scaffold(
// appBar: AppBar(
// title: const Text("Auth Control"),
// ),
// body: ListView(
// children: [
// if (!auth.isSignedIn) ...[
// if (!auth.isWaitingConfirmation) ...[
// ListTile(
// title: const Text("SignIn anonymously"),
// onTap: () async {
// await auth.signIn(AnonymouslyAuthQuery.signIn());
// navigator.pop();
// },
// ),
// ListTile(
// title: const Text("Register with email and password"),
// onTap: () async {
// await auth.register(
// EmailAndPasswordAuthQuery.register(
// email: "test@email.com",
// password: "12345678",
// ),
// );
// navigator.pop();
// },
// ),
// ListTile(
// title: const Text("SignIn with email and password"),
// onTap: () async {
// await auth.signIn(
// EmailAndPasswordAuthQuery.signIn(
// email: "test@email.com",
// password: "12345678",
// ),
// );
// navigator.pop();
// },
// ),
// ListTile(
// title: const Text("SignIn with email link"),
// onTap: () async {
// await auth.signIn(
// EmailLinkAuthQuery.signIn(
// email: "test@email.com",
// url: "https://test.com",
// ),
// );
// navigator.pop();
// },
// ),
// ListTile(
// title: const Text("SignIn with sms"),
// onTap: () async {
// await auth.signIn(
// SmsAuthQuery.signIn(
// phoneNumber: "01234567890",
// ),
// );
// navigator.pop();
// },
// ),
// ] else ...[
// ListTile(
// title: const Text("Confirm signIn with email link"),
// onTap: () async {
// await auth.confirmSignIn(
// EmailLinkAuthQuery.confirmSignIn(
// url: "https://test.com",
// ),
// );
// navigator.pop();
// },
// ),
// ListTile(
// title: const Text("Confirm signIn with sms"),
// onTap: () async {
// await auth.confirmSignIn(
// SmsAuthQuery.confirmSignIn(
// body: "012345",
// ),
// );
// navigator.pop();
// },
// ),
// ],
// ] else ...[
// if (!auth.isWaitingConfirmation) ...[
// ListTile(
// title: const Text("Change email"),
// onTap: () async {
// await auth.change(EmailAndPasswordAuthQuery.changeEmail(
// email: "changed@email.com"));
// navigator.pop();
// },
// ),
// ListTile(
// title: const Text("Change password"),
// onTap: () async {
// await auth.change(
// EmailAndPasswordAuthQuery.changePassword(password: ""));
// navigator.pop();
// },
// ),
// ListTile(
// title: const Text("Change phoneNumber"),
// onTap: () async {
// await auth.change(SmsAuthQuery.changePhoneNumber(
// phoneNumber: "1234567890"));
// navigator.pop();
// },
// ),
// ListTile(
// title: const Text("SignOut"),
// onTap: () async {
// await auth.signOut();
// navigator.pop();
// },
// ),
// ] else ...[
// ListTile(
// title: const Text("Confirm changing Phone number with sms"),
// onTap: () async {
// await auth.confirmChange(
// SmsAuthQuery.confirmChangePhoneNumber(
// body: "012345",
// ),
// );
// navigator.pop();
// },
// ),
// ],
// ],
// ],
// ),
// );
// }
// }