Skip to content

Commit bf1f96f

Browse files
committed
finish
1 parent 5f2266b commit bf1f96f

File tree

3 files changed

+35
-42
lines changed

3 files changed

+35
-42
lines changed

lib/data/firestor.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ class Firestore_Datasource {
6565
}
6666
}
6767

68-
Stream<QuerySnapshot> stream() {
68+
Stream<QuerySnapshot> stream(bool isDone) {
6969
return _firestore
7070
.collection('users')
7171
.doc(_auth.currentUser!.uid)
7272
.collection('notes')
73+
.where('isDon', isEqualTo: isDone)
7374
.snapshots();
7475
}
7576

lib/screen/home.dart

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import 'package:cloud_firestore/cloud_firestore.dart';
2-
import 'package:firebase_auth/firebase_auth.dart';
31
import 'package:flutter/material.dart';
42
import 'package:flutter/rendering.dart';
53
import 'package:flutter_to_do_list/const/colors.dart';
6-
import 'package:flutter_to_do_list/data/firestor.dart';
74
import 'package:flutter_to_do_list/screen/add_note_screen.dart';
8-
import 'package:flutter_to_do_list/widgets/task_widgets.dart';
5+
import 'package:flutter_to_do_list/widgets/stream_note.dart';
96

107
class Home_Screen extends StatefulWidget {
118
const Home_Screen({super.key});
@@ -34,41 +31,35 @@ class _Home_ScreenState extends State<Home_Screen> {
3431
),
3532
),
3633
body: SafeArea(
37-
child: NotificationListener<UserScrollNotification>(
38-
onNotification: (notification) {
39-
if (notification.direction == ScrollDirection.forward) {
40-
setState(() {
41-
show = true;
42-
});
43-
}
44-
if (notification.direction == ScrollDirection.reverse) {
45-
setState(() {
46-
show = false;
47-
});
48-
}
49-
return true;
50-
},
51-
child: StreamBuilder<QuerySnapshot>(
52-
stream: Firestore_Datasource().stream(),
53-
builder: (context, snapshot) {
54-
if (!snapshot.hasData) {
55-
return CircularProgressIndicator();
56-
}
57-
final noteslist = Firestore_Datasource().getNotes(snapshot);
58-
return ListView.builder(
59-
itemBuilder: (context, index) {
60-
final note = noteslist[index];
61-
return Dismissible(
62-
key: UniqueKey(),
63-
onDismissed: (direction) {
64-
Firestore_Datasource().delet_note(note.id);
65-
},
66-
child: Task_Widget(note));
67-
},
68-
itemCount: noteslist.length,
69-
);
70-
}),
71-
)),
34+
child: NotificationListener<UserScrollNotification>(
35+
onNotification: (notification) {
36+
if (notification.direction == ScrollDirection.forward) {
37+
setState(() {
38+
show = true;
39+
});
40+
}
41+
if (notification.direction == ScrollDirection.reverse) {
42+
setState(() {
43+
show = false;
44+
});
45+
}
46+
return true;
47+
},
48+
child: Column(
49+
children: [
50+
Stream_note(false),
51+
Text(
52+
'isDone',
53+
style: TextStyle(
54+
fontSize: 16,
55+
color: Colors.grey.shade500,
56+
fontWeight: FontWeight.bold),
57+
),
58+
Stream_note(true),
59+
],
60+
),
61+
),
62+
),
7263
);
7364
}
7465
}

lib/widgets/stream_note.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import 'package:flutter_to_do_list/widgets/task_widgets.dart';
55
import '../data/firestor.dart';
66

77
class Stream_note extends StatelessWidget {
8-
const Stream_note({super.key});
8+
bool done;
9+
Stream_note(this.done, {super.key});
910

1011
@override
1112
Widget build(BuildContext context) {
1213
return StreamBuilder<QuerySnapshot>(
13-
stream: Firestore_Datasource().stream(),
14+
stream: Firestore_Datasource().stream(done),
1415
builder: (context, snapshot) {
1516
if (!snapshot.hasData) {
1617
return CircularProgressIndicator();

0 commit comments

Comments
 (0)