Skip to content

Commit f648d94

Browse files
Merge branch 'dev' of github.com:SWEProject25/cross-platform into dev
2 parents eb24ba9 + 28102db commit f648d94

25 files changed

Lines changed: 3025 additions & 773 deletions

lam7a/lib/features/Explore/ui/view/explore_and_trending/for_you_view.dart

Lines changed: 122 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -11,141 +11,146 @@ class ForYouView extends StatelessWidget {
1111
final List<TrendingHashtag> trendingHashtags;
1212
final List<UserModel> suggestedUsers;
1313
final Map<String, List<TweetModel>> forYouTweetsMap;
14+
final RefreshCallback onRefresh;
1415

1516
const ForYouView({
1617
super.key,
1718
required this.trendingHashtags,
1819
required this.suggestedUsers,
1920
required this.forYouTweetsMap,
21+
required this.onRefresh,
2022
});
2123

2224
@override
2325
Widget build(BuildContext context) {
2426
final theme = Theme.of(context);
2527

26-
return ListView(
27-
padding: const EdgeInsets.all(0),
28-
children: [
29-
// ----- Trending Hashtags Section -----
30-
ListView.builder(
31-
shrinkWrap: true,
32-
physics: const NeverScrollableScrollPhysics(),
33-
itemCount: trendingHashtags.length,
34-
itemBuilder: (context, index) {
35-
final hashtag = trendingHashtags[index];
36-
return Padding(
37-
padding: const EdgeInsets.only(bottom: 16),
38-
child: HashtagItem(hashtag: hashtag, showOrder: false),
39-
);
40-
},
41-
),
42-
43-
const SizedBox(height: 16),
44-
45-
// Divider after trending hashtags
46-
Divider(
47-
height: 2,
48-
thickness: 0.2,
49-
color: theme.brightness == Brightness.light
50-
? const Color.fromARGB(120, 83, 99, 110)
51-
: const Color(0xFF8B98A5),
52-
),
53-
54-
const SizedBox(height: 16),
55-
56-
// ----- Who to follow Section -----
57-
Padding(
58-
padding: const EdgeInsets.symmetric(horizontal: 16),
59-
child: Text(
60-
"Who to follow",
61-
style: TextStyle(
62-
color: theme.brightness == Brightness.light
63-
? const Color(0xFF0D0D0D)
64-
: const Color(0xFFFFFFFF),
65-
fontSize: 19,
66-
fontWeight: FontWeight.w600,
67-
),
28+
return RefreshIndicator(
29+
onRefresh: onRefresh,
30+
child: ListView(
31+
padding: const EdgeInsets.all(0),
32+
children: [
33+
// ----- Trending Hashtags Section -----
34+
ListView.builder(
35+
shrinkWrap: true,
36+
physics: const NeverScrollableScrollPhysics(),
37+
itemCount: trendingHashtags.length,
38+
itemBuilder: (context, index) {
39+
final hashtag = trendingHashtags[index];
40+
return Padding(
41+
padding: const EdgeInsets.only(bottom: 16),
42+
child: HashtagItem(hashtag: hashtag, showOrder: false),
43+
);
44+
},
6845
),
69-
),
70-
71-
const SizedBox(height: 10),
72-
73-
// ----- Suggested Users List -----
74-
ListView.builder(
75-
shrinkWrap: true,
76-
physics: const NeverScrollableScrollPhysics(),
77-
itemCount: suggestedUsers.length,
78-
itemBuilder: (context, index) {
79-
final user = suggestedUsers[index];
80-
return Padding(
81-
padding: const EdgeInsets.only(bottom: 8, left: 8, right: 4),
82-
child: UserTile(user: user),
83-
);
84-
},
85-
),
86-
87-
const SizedBox(height: 12),
88-
89-
// Show more button
90-
Padding(
91-
padding: const EdgeInsets.symmetric(horizontal: 16),
92-
child: Align(
93-
alignment: Alignment.centerLeft,
94-
child: TextButton(
95-
onPressed: () {
96-
Navigator.push(
97-
context,
98-
MaterialPageRoute(builder: (_) => const ConnectView()),
99-
);
100-
},
101-
style: TextButton.styleFrom(
102-
padding: EdgeInsets.zero,
103-
minimumSize: const Size(0, 0),
104-
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
46+
47+
const SizedBox(height: 16),
48+
49+
// Divider after trending hashtags
50+
Divider(
51+
height: 2,
52+
thickness: 0.2,
53+
color: theme.brightness == Brightness.light
54+
? const Color.fromARGB(120, 83, 99, 110)
55+
: const Color(0xFF8B98A5),
56+
),
57+
58+
const SizedBox(height: 16),
59+
60+
// ----- Who to follow Section -----
61+
Padding(
62+
padding: const EdgeInsets.symmetric(horizontal: 16),
63+
child: Text(
64+
"Who to follow",
65+
style: TextStyle(
66+
color: theme.brightness == Brightness.light
67+
? const Color(0xFF0D0D0D)
68+
: const Color(0xFFFFFFFF),
69+
fontSize: 19,
70+
fontWeight: FontWeight.w600,
10571
),
106-
child: const Text(
107-
"Show more",
108-
style: TextStyle(
109-
color: Color(0xFF1D9BF0),
110-
fontSize: 15,
111-
fontWeight: FontWeight.w400,
72+
),
73+
),
74+
75+
const SizedBox(height: 10),
76+
77+
// ----- Suggested Users List -----
78+
ListView.builder(
79+
shrinkWrap: true,
80+
physics: const NeverScrollableScrollPhysics(),
81+
itemCount: suggestedUsers.length,
82+
itemBuilder: (context, index) {
83+
final user = suggestedUsers[index];
84+
return Padding(
85+
padding: const EdgeInsets.only(bottom: 8, left: 8, right: 4),
86+
child: UserTile(user: user),
87+
);
88+
},
89+
),
90+
91+
const SizedBox(height: 12),
92+
93+
// Show more button
94+
Padding(
95+
padding: const EdgeInsets.symmetric(horizontal: 16),
96+
child: Align(
97+
alignment: Alignment.centerLeft,
98+
child: TextButton(
99+
onPressed: () {
100+
Navigator.push(
101+
context,
102+
MaterialPageRoute(builder: (_) => const ConnectView()),
103+
);
104+
},
105+
style: TextButton.styleFrom(
106+
padding: EdgeInsets.zero,
107+
minimumSize: const Size(0, 0),
108+
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
109+
),
110+
child: const Text(
111+
"Show more",
112+
style: TextStyle(
113+
color: Color(0xFF1D9BF0),
114+
fontSize: 15,
115+
fontWeight: FontWeight.w400,
116+
),
112117
),
113118
),
114119
),
115120
),
116-
),
117-
118-
const SizedBox(height: 16),
119-
120-
// Divider after who to follow section
121-
Divider(
122-
height: 2,
123-
thickness: 0.2,
124-
color: theme.brightness == Brightness.light
125-
? const Color.fromARGB(120, 83, 99, 110)
126-
: const Color(0xFF8B98A5),
127-
),
128-
129-
// ----- For You Tweets Sections -----
130-
// Map through each interest and its tweets
131-
...forYouTweetsMap.entries.map((entry) {
132-
final interest = entry.key;
133-
final tweets = entry.value;
134-
135-
// Skip if no tweets for this interest
136-
if (tweets.isEmpty) return const SizedBox.shrink();
137-
138-
return Column(
139-
children: [
140-
StaticTweetsListView(
141-
interest: interest,
142-
tweets: tweets,
143-
selfScrolling: false,
144-
),
145-
],
146-
);
147-
}),
148-
],
121+
122+
const SizedBox(height: 16),
123+
124+
// Divider after who to follow section
125+
Divider(
126+
height: 2,
127+
thickness: 0.2,
128+
color: theme.brightness == Brightness.light
129+
? const Color.fromARGB(120, 83, 99, 110)
130+
: const Color(0xFF8B98A5),
131+
),
132+
133+
// ----- For You Tweets Sections -----
134+
// Map through each interest and its tweets
135+
...forYouTweetsMap.entries.map((entry) {
136+
final interest = entry.key;
137+
final tweets = entry.value;
138+
139+
// Skip if no tweets for this interest
140+
if (tweets.isEmpty) return const SizedBox.shrink();
141+
142+
return Column(
143+
children: [
144+
StaticTweetsListView(
145+
interest: interest,
146+
tweets: tweets,
147+
selfScrolling: false,
148+
),
149+
],
150+
);
151+
}),
152+
],
153+
),
149154
);
150155
}
151156
}

0 commit comments

Comments
 (0)