Skip to content

Commit f11b4e2

Browse files
authored
feat: Integrate other tabs with profile.
2 parents cf7956f + 1b0117d commit f11b4e2

35 files changed

Lines changed: 539 additions & 411 deletions

lib/data/constants/colors.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
22

33
class AppColors {
44
static const Color white = Colors.white;
5-
static const Color white1 = Color(0xFFE5E5E5);
65
static const Color grey1 = Color(0xFF979797);
76
static const Color grey2 = Color(0xFFC5CEE0);
87
static const Color grey3 = Color(0xFF242424);

lib/data/services/local/image_service.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ImageService {
3131
compressQuality: 100,
3232
maxHeight: 1000,
3333
maxWidth: 1000,
34+
cropStyle: CropStyle.circle,
3435
compressFormat: ImageCompressFormat.png,
3536
);
3637
return croppedImage;

lib/data/services/local/storage_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class StorageService {
8181
static List<User>? get recentSearches {
8282
try {
8383
return List<User>.from(json
84-
.decode(_get<String>(AppStrings.recentSearchKey)!)
84+
.decode(_get<String>(AppStrings.recentSearchKey) ?? '')
8585
.map((e) => User.fromJson(e)));
8686
} on Exception catch (_) {
8787
return null;

lib/presentation/contests/contests_screen.dart

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,41 @@ class ContestsScreen extends StatelessWidget {
1414

1515
@override
1616
Widget build(BuildContext context) {
17-
return BlocProvider<ContestsBloc>(
18-
create: (_) => ContestsBloc()..init(),
19-
child: Scaffold(
20-
appBar: const PreferredSize(
21-
preferredSize: Size.fromHeight(kToolbarHeight),
22-
child: ContestHeader(),
23-
),
24-
body: BlocBuilder<ContestsBloc, ContestsState>(
25-
builder: (context, state) {
26-
if (state.status is Loading || state.status is Error) {
27-
return const LoadingState();
28-
}
29-
if (state.contests.isEmpty) {
30-
return const EmptyState(
31-
description: 'No contests found, please adjust your filters!',
32-
);
33-
}
34-
return ListView.builder(
35-
itemCount: state.contests.length,
36-
itemBuilder: (context, index) {
37-
final isReminderSet = context
38-
.read<ContestsBloc>()
39-
.reminderSet(state.contests[index].name);
40-
if (state.contests[index] is Ongoing) {
41-
return ContestCard(
42-
isReminderSet: isReminderSet,
43-
ongoing: state.contests[index],
44-
);
45-
}
46-
17+
return Scaffold(
18+
appBar: const PreferredSize(
19+
preferredSize: Size.fromHeight(kToolbarHeight),
20+
child: ContestHeader(),
21+
),
22+
body: BlocBuilder<ContestsBloc, ContestsState>(
23+
builder: (context, state) {
24+
if (state.status is Loading || state.status is Error) {
25+
return const LoadingState();
26+
}
27+
if (state.contests.isEmpty) {
28+
return const EmptyState(
29+
description: 'No contests found, please adjust your filters!',
30+
);
31+
}
32+
return ListView.builder(
33+
itemCount: state.contests.length,
34+
itemBuilder: (context, index) {
35+
final isReminderSet = context
36+
.read<ContestsBloc>()
37+
.reminderSet(state.contests[index].name);
38+
if (state.contests[index] is Ongoing) {
4739
return ContestCard(
4840
isReminderSet: isReminderSet,
49-
upcoming: state.contests[index],
41+
ongoing: state.contests[index],
5042
);
51-
},
52-
);
53-
},
54-
),
43+
}
44+
45+
return ContestCard(
46+
isReminderSet: isReminderSet,
47+
upcoming: state.contests[index],
48+
);
49+
},
50+
);
51+
},
5552
),
5653
);
5754
}

lib/presentation/contests/widgets/contest_card.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ContestCard extends StatelessWidget {
4444
},
4545
child: Padding(
4646
padding: EdgeInsets.symmetric(
47-
vertical: 10.h,
47+
vertical: 10.r,
4848
),
4949
child: Row(
5050
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -69,7 +69,7 @@ class ContestCard extends StatelessWidget {
6969
style: AppStyles.h6,
7070
),
7171
Padding(
72-
padding: EdgeInsets.symmetric(vertical: 6.h),
72+
padding: EdgeInsets.symmetric(vertical: 6.r),
7373
child: Text(
7474
upcoming != null ? upcoming!.name : ongoing!.name,
7575
style: AppStyles.h4.copyWith(
@@ -82,7 +82,7 @@ class ContestCard extends StatelessWidget {
8282
SvgPicture.asset(
8383
AppAssets.clock,
8484
),
85-
SizedBox(width: 4.w),
85+
SizedBox(width: 4.r),
8686
Text(
8787
upcoming != null ? upcoming!.time : ongoing!.time,
8888
style: AppStyles.h6,
@@ -110,7 +110,7 @@ class ContestCard extends StatelessWidget {
110110
),
111111
),
112112
title: Container(
113-
padding: EdgeInsets.symmetric(vertical: 10.h),
113+
padding: EdgeInsets.symmetric(vertical: 10.r),
114114
decoration: BoxDecoration(
115115
color: AppColors.grey7,
116116
borderRadius: BorderRadius.vertical(
@@ -135,13 +135,13 @@ class ContestCard extends StatelessWidget {
135135
),
136136
),
137137
child: SizedBox(
138-
height: 120.h,
138+
height: 120.r,
139139
child: Column(
140140
children: [
141141
Padding(
142142
padding: EdgeInsets.symmetric(
143-
horizontal: 30.w,
144-
vertical: 10.h,
143+
horizontal: 30.r,
144+
vertical: 10.r,
145145
),
146146
child: Text(
147147
'You will be reminded before the contest starts. Set the timer',
@@ -159,8 +159,8 @@ class ContestCard extends StatelessWidget {
159159
valueListenable: _remindNotifer,
160160
builder: (context, value, _) {
161161
return SizedBox(
162-
height: 60.h,
163-
width: 30.w,
162+
height: 60.r,
163+
width: 30.r,
164164
child: ListWheelScrollView(
165165
controller:
166166
FixedExtentScrollController(
@@ -190,7 +190,7 @@ class ContestCard extends StatelessWidget {
190190
);
191191
},
192192
),
193-
SizedBox(width: 4.w),
193+
SizedBox(width: 4.r),
194194
Text(
195195
'minutes',
196196
style: AppStyles.h6.copyWith(
@@ -218,8 +218,8 @@ class ContestCard extends StatelessWidget {
218218
},
219219
child: Container(
220220
padding: EdgeInsets.symmetric(
221-
horizontal: 40.w,
222-
vertical: 10.h,
221+
horizontal: 40.r,
222+
vertical: 10.r,
223223
),
224224
color: AppColors.grey10,
225225
child: Text(
@@ -255,8 +255,8 @@ class ContestCard extends StatelessWidget {
255255
},
256256
child: Container(
257257
padding: EdgeInsets.symmetric(
258-
horizontal: 40.w,
259-
vertical: 10.h,
258+
horizontal: 40.r,
259+
vertical: 10.r,
260260
),
261261
color: AppColors.primary,
262262
child: Text(

lib/presentation/contests/widgets/filter_sheet.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class FilterSheet extends StatelessWidget {
2525

2626
Widget _buildPlatfromIcon(String icon, VoidCallback callback, bool isActive) {
2727
return Padding(
28-
padding: EdgeInsets.only(left: 16.w, top: 10.h, bottom: 20.h),
28+
padding: EdgeInsets.only(left: 16.r, top: 10.r, bottom: 20.r),
2929
child: InkWell(
3030
onTap: callback,
3131
child: AnimatedOpacity(
@@ -87,7 +87,7 @@ class FilterSheet extends StatelessWidget {
8787
),
8888
),
8989
Padding(
90-
padding: EdgeInsets.only(left: 16.w, top: 10.h),
90+
padding: EdgeInsets.only(left: 16.r, top: 10.r),
9191
child: Text(
9292
'Platforms',
9393
style: AppStyles.h6.copyWith(
@@ -122,7 +122,7 @@ class FilterSheet extends StatelessWidget {
122122
),
123123
),
124124
Padding(
125-
padding: EdgeInsets.only(left: 16.w),
125+
padding: EdgeInsets.only(left: 16.r),
126126
child: Text(
127127
'Max. Duration',
128128
style: AppStyles.h6.copyWith(
@@ -155,7 +155,7 @@ class FilterSheet extends StatelessWidget {
155155
},
156156
),
157157
Padding(
158-
padding: EdgeInsets.only(left: 16.w),
158+
padding: EdgeInsets.only(left: 16.r),
159159
child: Text(
160160
'Start Date',
161161
style: AppStyles.h6.copyWith(

lib/presentation/contests/widgets/loading_state.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class LoadingState extends StatelessWidget {
2828
children: <Widget>[
2929
Container(
3030
margin: const EdgeInsets.fromLTRB(0, 15, 0, 10),
31-
width: 150.w,
31+
width: 150.r,
3232
decoration: BoxDecoration(
3333
borderRadius: BorderRadius.circular(2),
3434
color: const Color(0xFFE5E5E5),
@@ -37,7 +37,7 @@ class LoadingState extends StatelessWidget {
3737
),
3838
Container(
3939
margin: const EdgeInsets.fromLTRB(0, 0, 0, 10),
40-
width: 250.w,
40+
width: 250.r,
4141
height: 20,
4242
decoration: BoxDecoration(
4343
borderRadius: BorderRadius.circular(2),
@@ -46,7 +46,7 @@ class LoadingState extends StatelessWidget {
4646
),
4747
Container(
4848
margin: const EdgeInsets.fromLTRB(0, 0, 0, 15),
49-
width: 250.w,
49+
width: 250.r,
5050
height: 20,
5151
decoration: BoxDecoration(
5252
borderRadius: BorderRadius.circular(2),

lib/presentation/core/router.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_bloc/flutter_bloc.dart';
32
import 'package:get/get.dart';
43

54
import '../../data/constants/routes.dart';
@@ -8,7 +7,6 @@ import '../login/login_screen.dart';
87
import '../onboarding/onboarding_screen.dart';
98
import '../signup/signup_screen.dart';
109
import '../signup/verify_screen.dart';
11-
import '../update_profile/bloc/update_profile_bloc.dart';
1210
import '../update_profile/update_profile.dart';
1311

1412
/// Wrapper for a single method to be passed to [GetMaterialApp.onGenerateRoute].
@@ -47,10 +45,7 @@ class AppRouter {
4745
);
4846
case AppRoutes.updateProfile:
4947
return GetPageRoute(
50-
page: () => BlocProvider(
51-
create: (context) => UpdateProfileBloc()..add(const Initialize()),
52-
child: const UpdateProfile(),
53-
),
48+
page: () => const UpdateProfile(),
5449
routeName: settings.name,
5550
settings: settings,
5651
);

lib/presentation/feed/widgets/feed_card.dart

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:core';
22

33
import 'package:flutter/material.dart';
4+
import 'package:flutter_bloc/flutter_bloc.dart';
45
import 'package:flutter_screenutil/flutter_screenutil.dart';
56
import 'package:flutter_svg/flutter_svg.dart';
67
import 'package:flutter_web_browser/flutter_web_browser.dart';
@@ -11,6 +12,8 @@ import '../../../data/constants/colors.dart';
1112
import '../../../domain/models/grouped_feed.dart';
1213
import '../../../utils/feed_util.dart';
1314
import '../../../utils/platform_util.dart';
15+
import '../../home/bloc/home_bloc.dart';
16+
import '../../profile/bloc/profile_bloc.dart';
1417

1518
class FeedCard extends StatelessWidget {
1619
FeedCard({
@@ -33,10 +36,16 @@ class FeedCard extends StatelessWidget {
3336
children: <Widget>[
3437
GestureDetector(
3538
onTap: () {
36-
// TODO(aman-singh7): Integrate to profile
39+
context
40+
.read<ProfileBloc>()
41+
.add(FetchDetails(userId: feed.userId));
42+
43+
context
44+
.read<HomeBloc>()
45+
.add(const BottomNavItemPressed(index: 3));
3746
},
3847
child: Padding(
39-
padding: EdgeInsets.only(right: 10.w),
48+
padding: EdgeInsets.only(right: 10.r),
4049
child: feed.picture?.isEmpty ?? true
4150
? Container(
4251
decoration: BoxDecoration(
@@ -82,7 +91,7 @@ class FeedCard extends StatelessWidget {
8291
],
8392
),
8493
Padding(
85-
padding: EdgeInsets.symmetric(vertical: 5.h),
94+
padding: EdgeInsets.symmetric(vertical: 5.r),
8695
child: Text(
8796
'${feed.name}',
8897
style: Theme.of(context)
@@ -114,7 +123,7 @@ class FeedCard extends StatelessWidget {
114123
radius: 10.r,
115124
),
116125
SizedBox(
117-
width: 150.w,
126+
width: 150.r,
118127
child: Text(
119128
_makeNonBreaking(
120129
' ${PlatformUtil.getName(PlatformUtil.getNamefromUrl(feed.url))} |'
@@ -153,8 +162,8 @@ class FeedCard extends StatelessWidget {
153162
Container(
154163
color: AppColors.grey9,
155164
padding: EdgeInsets.symmetric(
156-
horizontal: 15.w,
157-
vertical: 10.h,
165+
horizontal: 15.r,
166+
vertical: 10.r,
158167
),
159168
child: Column(
160169
children: _buildSubmissions(feed.submissions!),
@@ -193,21 +202,21 @@ class FeedCard extends StatelessWidget {
193202
Column(
194203
children: <Widget>[
195204
Container(
196-
height: 9.h,
197-
width: 2.w,
205+
height: 9.r,
206+
width: 2.r,
198207
color: isFirst ? AppColors.white : AppColors.grey10,
199208
),
200209
Container(
201-
height: 8.h,
202-
width: 8.w,
210+
height: 8.r,
211+
width: 8.r,
203212
decoration: BoxDecoration(
204213
color: response['color'],
205214
shape: BoxShape.circle,
206215
),
207216
),
208217
Container(
209-
height: 9.h,
210-
width: 2.w,
218+
height: 9.r,
219+
width: 2.r,
211220
color: isLast ? AppColors.white : AppColors.grey10,
212221
)
213222
],

0 commit comments

Comments
 (0)