@@ -6,9 +6,10 @@ import 'package:femunity/features/communities/controller/community_controller.da
6
6
import 'package:femunity/features/posts/controller/posts_controller.dart' ;
7
7
import 'package:flutter/material.dart' ;
8
8
import 'package:flutter_riverpod/flutter_riverpod.dart' ;
9
+ import 'package:url_launcher/url_launcher.dart' ;
9
10
10
11
class FeedScreen extends ConsumerWidget {
11
- const FeedScreen ({super . key});
12
+ const FeedScreen ({Key ? key});
12
13
13
14
@override
14
15
Widget build (BuildContext context, WidgetRef ref) {
@@ -17,51 +18,149 @@ class FeedScreen extends ConsumerWidget {
17
18
18
19
if (! isGuest) {
19
20
return ref.watch (userCommunitiesProvider).when (
20
- data: (communities) => ref.watch (userPostsProvider (communities)).when (
21
- data: (data) {
22
- return ListView .builder (
23
- itemCount: data.length,
24
- itemBuilder: (BuildContext context, int index) {
25
- final post = data[index];
26
- return PostCard (post: post);
27
- },
28
- );
29
- },
30
- error: (error, stackTrace) {
31
- return ErrorText (
32
- error: error.toString (),
33
- );
34
- },
35
- loading: () => const Loader (),
36
- ),
21
+ data: (communities) {
22
+ if (communities.isEmpty) {
23
+ return SingleChildScrollView (
24
+ child: Column (
25
+ children: [
26
+ SizedBox (height: 30 ),
27
+ Card (
28
+ margin: const EdgeInsets .symmetric (horizontal: 16 ),
29
+ shape: RoundedRectangleBorder (
30
+ borderRadius: BorderRadius .circular (24 ),
31
+ ),
32
+ elevation: 8 ,
33
+ color: Theme .of (context).brightness == Brightness .dark
34
+ ? Colors .grey[900 ]
35
+ : Color (0xFFffe9ec ),
36
+ child: Column (
37
+ crossAxisAlignment: CrossAxisAlignment .stretch,
38
+ children: [
39
+ Padding (
40
+ padding: const EdgeInsets .symmetric (
41
+ horizontal: 16 , vertical: 16 ),
42
+ child: Text (
43
+ 'How to use this app' ,
44
+ style: TextStyle (
45
+ fontWeight: FontWeight .bold,
46
+ fontSize: 24 ,
47
+ color: Colors .purpleAccent,
48
+ ),
49
+ ),
50
+ ),
51
+ Padding (
52
+ padding:
53
+ const EdgeInsets .symmetric (horizontal: 16 ),
54
+ child: Text (
55
+ 'To use the Femunity app, follow these simple steps:\n ' ,
56
+ style: TextStyle (fontSize: 18 ),
57
+ ),
58
+ ),
59
+ SizedBox (height: 8 ),
60
+ Padding (
61
+ padding:
62
+ const EdgeInsets .symmetric (horizontal: 16 ),
63
+ child: Text (
64
+ '- Tap the search bar above to search and join communities.\n\n - Press the "+" button on the home screen to add posts.\n\n - Go to the community drawer to access your communities.' ,
65
+ style: TextStyle (fontSize: 18 ),
66
+ ),
67
+ ),
68
+ SizedBox (height: 16 ),
69
+ ],
70
+ ),
71
+ ),
72
+ SizedBox (height: 16 ),
73
+ Card (
74
+ margin: const EdgeInsets .symmetric (horizontal: 16 ),
75
+ shape: RoundedRectangleBorder (
76
+ borderRadius: BorderRadius .circular (24 ),
77
+ ),
78
+ elevation: 8 ,
79
+ color: Theme .of (context).brightness == Brightness .dark
80
+ ? Colors .grey[900 ]
81
+ : Color (0xFFffe9ec ),
82
+ child: InkWell (
83
+ onTap: () => launch ('https://youtube.com/' ),
84
+ child: Column (
85
+ crossAxisAlignment: CrossAxisAlignment .stretch,
86
+ children: [
87
+ ClipRRect (
88
+ borderRadius: BorderRadius .vertical (
89
+ top: Radius .circular (24 )),
90
+ child: Image .network (
91
+ 'https://1000logos.net/wp-content/uploads/2017/05/Color-YouTube-logo.jpg' ,
92
+ height: 200 ,
93
+ width: double .infinity,
94
+ fit: BoxFit .cover,
95
+ ),
96
+ ),
97
+ SizedBox (height: 16 ),
98
+ Padding (
99
+ padding:
100
+ const EdgeInsets .symmetric (horizontal: 16 ),
101
+ child: Text (
102
+ 'Watch this video to learn more!' ,
103
+ style: TextStyle (
104
+ fontWeight: FontWeight .bold,
105
+ fontSize: 24 ,
106
+ color: Colors .purpleAccent,
107
+ ),
108
+ ),
109
+ ),
110
+ SizedBox (height: 8 ),
111
+ Padding (
112
+ padding:
113
+ const EdgeInsets .symmetric (horizontal: 16 ),
114
+ ),
115
+ SizedBox (height: 16 ),
116
+ ],
117
+ ),
118
+ ),
119
+ ),
120
+ ],
121
+ ),
122
+ );
123
+ }
124
+ return ref.watch (userPostsProvider (communities)).when (
125
+ data: (data) {
126
+ return ListView .builder (
127
+ itemCount: data.length,
128
+ itemBuilder: (BuildContext context, int index) {
129
+ final post = data[index];
130
+ return PostCard (post: post);
131
+ },
132
+ );
133
+ },
134
+ error: (error, stackTrace) {
135
+ return ErrorText (
136
+ error: error.toString (),
137
+ );
138
+ },
139
+ loading: () => const Loader (),
140
+ );
141
+ },
37
142
error: (error, stackTrace) => ErrorText (
38
143
error: error.toString (),
39
144
),
40
145
loading: () => const Loader (),
41
146
);
42
147
}
43
- return ref.watch (userCommunitiesProvider).when (
44
- data: (communities) => ref.watch (GuestPostsProvider ).when (
45
- data: (data) {
46
- return ListView .builder (
47
- itemCount: data.length,
48
- itemBuilder: (BuildContext context, int index) {
49
- final post = data[index];
50
- return PostCard (post: post);
51
- },
52
- );
53
- },
54
- error: (error, stackTrace) {
55
- return ErrorText (
56
- error: error.toString (),
57
- );
58
- },
59
- loading: () => const Loader (),
60
- ),
61
- error: (error, stackTrace) => ErrorText (
62
- error: error.toString (),
63
- ),
148
+ return ref.watch (GuestPostsProvider ).when (
149
+ data: (data) {
150
+ return ListView .builder (
151
+ itemCount: data.length,
152
+ itemBuilder: (BuildContext context, int index) {
153
+ final post = data[index];
154
+ return PostCard (post: post);
155
+ },
156
+ );
157
+ },
158
+ error: (error, stackTrace) {
159
+ return ErrorText (
160
+ error: error.toString (),
161
+ );
162
+ },
64
163
loading: () => const Loader (),
65
164
);
66
165
}
67
- }
166
+ }
0 commit comments