Skip to content

Commit fbf975c

Browse files
committed
fixes
1 parent a4d44a7 commit fbf975c

File tree

3 files changed

+52
-43
lines changed

3 files changed

+52
-43
lines changed

lib/screens/fav_anime_screen.dart

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:provider/provider.dart';
3+
import 'package:firebase_auth/firebase_auth.dart';
34

45
import '../models/fav_anime_provider.dart';
56

@@ -33,50 +34,56 @@ class _FavAnimeScreenState extends State<FavAnimeScreen> {
3334
centerTitle: true,
3435
elevation: 0,
3536
),
36-
body: ListView.separated(
37-
itemCount: fav.length,
38-
itemBuilder: (context, i) {
39-
return InkWell(
40-
onTap: () {},
41-
child: Padding(
42-
padding: const EdgeInsets.all(8.0),
43-
child: Column(
44-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
45-
children: [
46-
Row(
47-
mainAxisAlignment: MainAxisAlignment.spaceAround,
48-
children: [
49-
CircleAvatar(
50-
radius: 35,
51-
backgroundImage: NetworkImage(fav[i]['imgUrl']),
52-
backgroundColor: Colors.black.withOpacity(0.04),
53-
),
54-
Expanded(
55-
child: Container(
56-
margin: const EdgeInsets.only(left: 10),
57-
child: Text(
58-
fav[i]['title'],
59-
style: const TextStyle(
60-
fontWeight: FontWeight.w500,
61-
fontSize: 16,
37+
body: FirebaseAuth.instance.currentUser == null
38+
? Container(
39+
child: const Center(
40+
child: Text('Not Logged In'),
41+
),
42+
)
43+
: ListView.separated(
44+
itemCount: fav.length,
45+
itemBuilder: (context, i) {
46+
return InkWell(
47+
onTap: () {},
48+
child: Padding(
49+
padding: const EdgeInsets.all(8.0),
50+
child: Column(
51+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
52+
children: [
53+
Row(
54+
mainAxisAlignment: MainAxisAlignment.spaceAround,
55+
children: [
56+
CircleAvatar(
57+
radius: 35,
58+
backgroundImage: NetworkImage(fav[i]['imgUrl']),
59+
backgroundColor: Colors.black.withOpacity(0.04),
60+
),
61+
Expanded(
62+
child: Container(
63+
margin: const EdgeInsets.only(left: 10),
64+
child: Text(
65+
fav[i]['title'],
66+
style: const TextStyle(
67+
fontWeight: FontWeight.w500,
68+
fontSize: 16,
69+
),
70+
overflow: TextOverflow.ellipsis,
71+
),
72+
),
6273
),
63-
overflow: TextOverflow.ellipsis,
64-
),
74+
],
6575
),
66-
),
67-
],
76+
],
77+
),
6878
),
69-
],
70-
),
79+
);
80+
},
81+
separatorBuilder: (context, i) {
82+
return const Divider(
83+
height: 1,
84+
);
85+
},
7186
),
72-
);
73-
},
74-
separatorBuilder: (context, i) {
75-
return const Divider(
76-
height: 1,
77-
);
78-
},
79-
),
8087
);
8188
}
8289
}

lib/services/db_service.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ class DBService {
77
.collection('users')
88
.doc(uid)
99
.collection('fav')
10-
.add(data);
10+
.add(data)
11+
.then((value) => print('Added'))
12+
.catchError((e) => print('Failed $e'));
1113
}
1214

1315
getFavAnime() async {

lib/widgets/InfoBar.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class _InfoBarState extends State<InfoBar> {
4646
IconButton(
4747
onPressed: () async {
4848
if (FirebaseAuth.instance.currentUser != null) {
49-
await DBService().addFav(widget.data,
50-
Provider.of<AppStateProvider>(context, listen: false).userID);
49+
await DBService()
50+
.addFav(widget.data, FirebaseAuth.instance.currentUser!.uid);
5151
} else {
5252
CoolAlert.show(
5353
context: context,

0 commit comments

Comments
 (0)