File tree Expand file tree Collapse file tree 8 files changed +73
-6
lines changed Expand file tree Collapse file tree 8 files changed +73
-6
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1
1
import 'package:firebase_auth/firebase_auth.dart' ;
2
+ import 'package:flutter_to_do_list/data/firestor.dart' ;
2
3
3
4
abstract class AuthenticationDatasource {
4
5
Future <void > register (String email, String password, String PasswordConfirm );
@@ -16,8 +17,12 @@ class AuthenticationRemote extends AuthenticationDatasource {
16
17
Future <void > register (
17
18
String email, String password, String PasswordConfirm ) async {
18
19
if (PasswordConfirm == password) {
19
- await FirebaseAuth .instance.createUserWithEmailAndPassword (
20
- email: email.trim (), password: password.trim ());
20
+ await FirebaseAuth .instance
21
+ .createUserWithEmailAndPassword (
22
+ email: email.trim (), password: password.trim ())
23
+ .then ((value) {
24
+ Firestore_Datasource ().CreateUser (email);
25
+ });
21
26
}
22
27
}
23
28
}
Original file line number Diff line number Diff line change
1
+ import 'package:cloud_firestore/cloud_firestore.dart' ;
2
+ import 'package:firebase_auth/firebase_auth.dart' ;
3
+ import 'package:uuid/uuid.dart' ;
4
+
5
+ class Firestore_Datasource {
6
+ final FirebaseFirestore _firestore = FirebaseFirestore .instance;
7
+ final FirebaseAuth _auth = FirebaseAuth .instance;
8
+
9
+ Future <bool > CreateUser (String email) async {
10
+ try {
11
+ await _firestore
12
+ .collection ('users' )
13
+ .doc (_auth.currentUser! .uid)
14
+ .set ({"id" : _auth.currentUser! .uid, "email" : email});
15
+ return true ;
16
+ } catch (e) {
17
+ return true ;
18
+ }
19
+ }
20
+
21
+ Future <bool > AddNote (String subtitle, String title, int image) async {
22
+ try {
23
+ var uuid = Uuid ().v4 ();
24
+ DateTime data = new DateTime .now ();
25
+ await _firestore
26
+ .collection ('users' )
27
+ .doc (_auth.currentUser! .uid)
28
+ .collection ('notes' )
29
+ .doc (uuid)
30
+ .set ({
31
+ 'id' : uuid,
32
+ 'subtitle' : subtitle,
33
+ 'isDon' : false ,
34
+ 'image' : image,
35
+ 'time' : data,
36
+ 'title' : title,
37
+ });
38
+ return true ;
39
+ } catch (e) {
40
+ return true ;
41
+ }
42
+ }
43
+ }
Original file line number Diff line number Diff line change 1
1
import 'package:firebase_core/firebase_core.dart' ;
2
2
import 'package:flutter/material.dart' ;
3
- import 'package:flutter_to_do_list/screen/add_note_screen.dart' ;
4
- import 'package:flutter_to_do_list/screen/home.dart' ;
5
- import 'package:flutter_to_do_list/widgets/task_widgets.dart' ;
3
+ import 'package:flutter_to_do_list/auth/main_page.dart' ;
6
4
7
5
void main () async {
8
6
WidgetsFlutterBinding .ensureInitialized ();
@@ -17,7 +15,7 @@ class MyApp extends StatelessWidget {
17
15
Widget build (BuildContext context) {
18
16
return MaterialApp (
19
17
debugShowCheckedModeBanner: false ,
20
- home: Home_Screen (),
18
+ home: Main_Page (),
21
19
);
22
20
}
23
21
}
Original file line number Diff line number Diff line change
1
+ import 'package:firebase_auth/firebase_auth.dart' ;
1
2
import 'package:flutter/material.dart' ;
2
3
import 'package:flutter_to_do_list/const/colors.dart' ;
4
+ import 'package:flutter_to_do_list/data/firestor.dart' ;
3
5
4
6
class Add_creen extends StatefulWidget {
5
7
const Add_creen ({super .key});
@@ -46,6 +48,7 @@ class _Add_creenState extends State<Add_creen> {
46
48
minimumSize: Size (170 , 48 ),
47
49
),
48
50
onPressed: () {
51
+ Firestore_Datasource ().AddNote (subtitle.text, title.text, indexx);
49
52
Navigator .pop (context);
50
53
},
51
54
child: Text ('add task' ),
Original file line number Diff line number Diff line change
1
+ import 'package:firebase_auth/firebase_auth.dart' ;
1
2
import 'package:flutter/material.dart' ;
2
3
import 'package:flutter/rendering.dart' ;
3
4
import 'package:flutter_to_do_list/const/colors.dart' ;
Original file line number Diff line number Diff line change @@ -73,6 +73,14 @@ packages:
73
73
url: "https://pub.dev"
74
74
source: hosted
75
75
version: "1.17.1"
76
+ crypto:
77
+ dependency: transitive
78
+ description:
79
+ name: crypto
80
+ sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
81
+ url: "https://pub.dev"
82
+ source: hosted
83
+ version: "3.0.3"
76
84
cupertino_icons:
77
85
dependency: "direct main"
78
86
description:
@@ -277,6 +285,14 @@ packages:
277
285
url: "https://pub.dev"
278
286
source: hosted
279
287
version: "1.3.2"
288
+ uuid:
289
+ dependency: "direct main"
290
+ description:
291
+ name: uuid
292
+ sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313"
293
+ url: "https://pub.dev"
294
+ source: hosted
295
+ version: "3.0.7"
280
296
vector_math:
281
297
dependency: transitive
282
298
description:
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ dependencies:
33
33
firebase_auth : ^4.3.0
34
34
cloud_firestore : ^4.5.0
35
35
msh_checkbox : ^1.1.1
36
+ uuid : ^3.0.6
36
37
37
38
38
39
# The following adds the Cupertino Icons font to your application.
You can’t perform that action at this time.
0 commit comments