Skip to content

Commit 2752e0c

Browse files
author
himanshu goyal
committed
image selection and bottom navigation bar
1 parent cfb03c1 commit 2752e0c

40 files changed

+1190
-398
lines changed

.env.example

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/config/router/router.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ class AppRouter extends _$AppRouter {
2525
AutoRoute(
2626
page: VerificationScreenRoute.page,
2727
),
28+
2829
];
2930
}

lib/core/queries/auth.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class AuthQueries {
77
_id
88
name
99
email
10+
imageUrl
1011
}
1112
}
1213
''';
@@ -85,6 +86,7 @@ class AuthQueries {
8586
email
8687
name
8788
isVerified
89+
imageUrl
8890
groups{
8991
_id
9092
}

lib/core/queries/beacon.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ deleteBeacon(id: "$id")
247247
lat
248248
lon
249249
}
250+
imageUrl
250251
}
251252
landmarks{
252253
_id
@@ -258,6 +259,7 @@ deleteBeacon(id: "$id")
258259
createdBy{
259260
_id
260261
name
262+
imageUrl
261263
}
262264
}
263265
location{
@@ -414,6 +416,7 @@ deleteBeacon(id: "$id")
414416
createdBy{
415417
_id
416418
name
419+
imageUrl
417420
}
418421
}
419422
}
@@ -448,6 +451,7 @@ deleteBeacon(id: "$id")
448451
updatedUser{
449452
_id
450453
name
454+
imageUrl
451455
location{
452456
lat
453457
lon
@@ -465,10 +469,24 @@ deleteBeacon(id: "$id")
465469
_id
466470
name
467471
email
472+
imageUrl
468473
}
469474
}
470475
471476
}
472477
}
473478
''');
479+
480+
String updateUserImage(String? imageUrl) {
481+
return '''
482+
mutation{
483+
updateUserImage(imageUrl: "$imageUrl"){
484+
_id
485+
name
486+
email
487+
imageUrl
488+
}
489+
}
490+
''';
491+
}
474492
}

lib/core/queries/group.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class GroupQueries {
1717
members{
1818
_id
1919
name
20+
imageUrl
2021
}
2122
shortcode
2223
__typename
@@ -122,10 +123,12 @@ class GroupQueries {
122123
leader {
123124
_id
124125
name
126+
imageUrl
125127
}
126128
members {
127129
_id
128130
name
131+
imageUrl
129132
}
130133
beacons
131134
{
@@ -146,6 +149,7 @@ query{
146149
leader {
147150
_id
148151
name
152+
imageUrl
149153
}
150154
location{
151155
lat
@@ -154,6 +158,7 @@ query{
154158
followers {
155159
_id
156160
name
161+
imageUrl
157162
}
158163
group{
159164
_id
@@ -178,10 +183,12 @@ query{
178183
leader{
179184
_id
180185
name
186+
imageUrl
181187
}
182188
members{
183189
_id
184190
name
191+
imageUrl
185192
}
186193
shortcode
187194
__typename
@@ -200,6 +207,7 @@ query{
200207
_id
201208
name
202209
email
210+
imageUrl
203211
}
204212
205213
newBeacon{
@@ -209,10 +217,12 @@ query{
209217
_id
210218
name
211219
email
220+
imageUrl
212221
}
213222
followers {
214223
_id
215224
name
225+
imageUrl
216226
}
217227
group{
218228
_id
@@ -257,10 +267,12 @@ query{
257267
_id
258268
name
259269
email
270+
imageUrl
260271
}
261272
followers {
262273
_id
263274
name
275+
imageUrl
264276
}
265277
group{
266278
_id
@@ -300,4 +312,18 @@ query{
300312
}
301313
}
302314
''');
315+
316+
String updateUserImage(String userId, String? imageUrl) {
317+
return '''
318+
mutation{
319+
updateUserImage(userId: "${userId}", imageUrl: "$imageUrl")
320+
{
321+
_id
322+
name
323+
email
324+
imageUrl
325+
}
326+
}
327+
''';
328+
}
303329
}

lib/data/datasource/remote/remote_hike_api.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class RemoteHikeApi {
3333
final result = await _authClient.mutate(MutationOptions(
3434
document: gql(beaconQueries.fetchBeaconDetail(beaconId))));
3535

36+
print("Result fetch beacon queries: ${result.data}");
37+
3638
if (result.isConcrete && result.data != null) {
3739
final beaconJson = result.data!['beacon'];
3840

@@ -92,6 +94,8 @@ class RemoteHikeApi {
9294
final result = await _authClient.mutate(MutationOptions(
9395
document: gql(beaconQueries.createLandmark(id, lat, lon, title))));
9496

97+
print("Result: ${result.data}");
98+
9599
if (result.isConcrete &&
96100
result.data != null &&
97101
result.data!['createLandmark'] != null) {

lib/data/datasource/remote/remote_home_api.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,20 @@ class RemoteHomeApi {
204204
return exception.graphqlErrors[0].message.toString();
205205
}
206206
}
207+
208+
Future<DataState<bool>> updateUserImage(
209+
String userId, String? imageUrl) async {
210+
bool isConnected = await utils.checkInternetConnectivity();
211+
if (!isConnected) {
212+
return DataFailed('No internet connection');
213+
}
214+
215+
final result = await _authClient.mutate(MutationOptions(
216+
document: gql(_groupQueries.updateUserImage(userId, imageUrl))));
217+
218+
if (result.isConcrete && result.data != null) {
219+
return DataSuccess(true);
220+
}
221+
return DataFailed(encounteredExceptionOrError(result.exception!));
222+
}
207223
}

lib/data/models/user/user_model.dart

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,21 @@ class UserModel implements UserEntity {
3838
@HiveField(8)
3939
bool? isVerified;
4040

41-
UserModel(
42-
{this.authToken,
43-
this.beacons,
44-
this.email,
45-
this.groups,
46-
this.id,
47-
this.isGuest,
48-
this.location,
49-
this.name,
50-
this.isVerified});
41+
@HiveField(9) // New field number (must be unique)
42+
String? imageUrl; // Add this line
43+
44+
UserModel({
45+
this.authToken,
46+
this.beacons,
47+
this.email,
48+
this.groups,
49+
this.id,
50+
this.isGuest,
51+
this.location,
52+
this.name,
53+
this.isVerified,
54+
this.imageUrl, // Add this line
55+
});
5156

5257
@override
5358
$UserEntityCopyWith<UserEntity> get copyWith => throw UnimplementedError();
@@ -67,16 +72,19 @@ class UserModel implements UserEntity {
6772
List<GroupModel?>? groups,
6873
List<BeaconModel?>? beacons,
6974
LocationModel? location,
75+
String? imageUrl, // Add this line
7076
}) {
7177
return UserModel(
72-
id: id ?? this.id,
73-
name: name ?? this.name,
74-
authToken: authToken ?? this.authToken,
75-
email: email ?? this.email,
76-
isGuest: isGuest ?? this.isGuest,
77-
groups: groups ?? this.groups,
78-
beacons: beacons ?? this.beacons,
79-
location: location ?? this.location,
80-
isVerified: isVerified ?? this.isVerified);
78+
id: id ?? this.id,
79+
name: name ?? this.name,
80+
authToken: authToken ?? this.authToken,
81+
email: email ?? this.email,
82+
isGuest: isGuest ?? this.isGuest,
83+
groups: groups ?? this.groups,
84+
beacons: beacons ?? this.beacons,
85+
location: location ?? this.location,
86+
isVerified: isVerified ?? this.isVerified,
87+
imageUrl: imageUrl ?? this.imageUrl, // Add this line
88+
);
8189
}
8290
}

lib/data/models/user/user_model.g.dart

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/data/repositories/home_repository_implementation.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@ class HomeRepostitoryImplementation implements HomeRepository {
4040
Future<DataState<GroupEntity>> changeShortcode(String groupId) {
4141
return remoteHomeApi.changeShortCode(groupId);
4242
}
43+
44+
@override
45+
Future<DataState<bool>> updateUserImage(String userId, String? imageUrl) {
46+
return remoteHomeApi.updateUserImage(userId, imageUrl);
47+
}
4348
}

0 commit comments

Comments
 (0)