Skip to content

Commit

Permalink
Merge pull request DevCom-IITB#51 from VIBR0X/lostandfound
Browse files Browse the repository at this point in the history
Lostandfound
  • Loading branch information
VIBR0X authored Dec 9, 2023
2 parents 5d3c480 + 08f56e6 commit 9c8b980
Show file tree
Hide file tree
Showing 11 changed files with 957 additions and 35 deletions.
49 changes: 29 additions & 20 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
import 'dart:async';
import 'dart:async';

import 'package:InstiApp/src/bloc_provider.dart';
import 'package:InstiApp/src/blocs/ia_bloc.dart';
import 'package:InstiApp/src/routes/aboutpage.dart';
import 'package:InstiApp/src/routes/achievement_form.dart';
import 'package:InstiApp/src/routes/alumniLoginPage.dart';
import 'package:InstiApp/src/routes/alumni_OTP_Page.dart';
import 'package:InstiApp/src/routes/bodypage.dart';
import 'package:InstiApp/src/routes/buynsell_categories.dart';
import 'package:InstiApp/src/routes/buynsell_createpost.dart';
import 'package:InstiApp/src/routes/buynsell_info.dart';
import 'package:InstiApp/src/routes/buynsell_page.dart';
import 'package:InstiApp/src/routes/calendarpage.dart';
import 'package:InstiApp/src/routes/chatbot.dart';
import 'package:InstiApp/src/routes/communitydetails.dart';
import 'package:InstiApp/src/routes/communitypage.dart';
import 'package:InstiApp/src/routes/communitypostpage.dart';
import 'package:InstiApp/src/routes/createpost_form.dart';
import 'package:InstiApp/src/routes/event_form.dart';
// import 'package:InstiApp/src/routes/complaintpage.dart';
// import 'package:InstiApp/src/routes/complaintspage.dart';
import 'package:InstiApp/src/routes/eventpage.dart';
import 'package:InstiApp/src/routes/explorepage.dart';
import 'package:InstiApp/src/routes/externalblogpage.dart';
import 'package:InstiApp/src/routes/feedpage.dart';
import 'package:InstiApp/src/routes/loginpage.dart';
import 'package:InstiApp/src/routes/lostandfoundfeedpage.dart';
import 'package:InstiApp/src/routes/lostandfoundinfo.dart';
import 'package:InstiApp/src/routes/mappage.dart';
import 'package:InstiApp/src/routes/messcalendarpage.dart';
import 'package:InstiApp/src/routes/messpage.dart';
// import 'package:InstiApp/src/routes/newcomplaintpage.dart';
import 'package:InstiApp/src/routes/newspage.dart';
import 'package:InstiApp/src/routes/chatbot.dart';
import 'package:InstiApp/src/routes/communitypage.dart';
import 'package:InstiApp/src/routes/notificationspage.dart';
import 'package:InstiApp/src/routes/placementblogpage.dart';
import 'package:InstiApp/src/routes/putentitypage.dart';
import 'package:InstiApp/src/routes/createpost_form.dart';
import 'package:InstiApp/src/routes/qrpage.dart';
import 'package:InstiApp/src/routes/queryaddpage.dart';
import 'package:InstiApp/src/routes/querypage.dart';
import 'package:InstiApp/src/routes/quicklinkspage.dart';
import 'package:InstiApp/src/routes/settingspage.dart';
import 'package:InstiApp/src/routes/trainingblogpage.dart';
import 'package:InstiApp/src/routes/userpage.dart';
import 'package:InstiApp/src/routes/achievement_form.dart';
import 'package:InstiApp/src/routes/your_achievements.dart';
import 'package:InstiApp/src/utils/app_brightness.dart';
import 'package:InstiApp/src/utils/notif_settings.dart';
import 'package:awesome_notifications/awesome_notifications.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
// import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:InstiApp/src/bloc_provider.dart';
import 'package:InstiApp/src/blocs/ia_bloc.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:InstiApp/src/routes/messpage.dart';
import 'package:InstiApp/src/routes/loginpage.dart';
import 'package:InstiApp/src/routes/alumniLoginPage.dart';
import 'package:InstiApp/src/routes/alumni_OTP_Page.dart';
import 'package:InstiApp/src/routes/placementblogpage.dart';
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:uni_links/uni_links.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:awesome_notifications/awesome_notifications.dart';

void main() async {
GlobalKey<MyAppState> key = GlobalKey();
Expand Down Expand Up @@ -280,15 +282,20 @@ class MyAppState extends State<MyApp> with WidgetsBindingObserver {
cookie: widget.bloc.getSessionIdHeader()));
} else if (temp.startsWith("/map/")) {
return _buildRoute(
settings,
MapPage(
location:temp.split("/map/")[1]));
}else if (temp.startsWith("/buyandsell/info")) {
settings, MapPage(location: temp.split("/map/")[1]));
} else if (temp.startsWith("/buyandsell/info")) {
return _buildRoute(
settings,
BuyAndSellInfoPage(
post: widget.bloc.buynSellPostBloc
.getBuynSellPost(temp.split("/buyandsell/info")[1])));
} else if (temp.startsWith("/lostandfound/info")) {
return _buildRoute(
settings,
LostAndFoundInfoPage(
item: widget.bloc.lostAndFoundPostBloc
.getLostAndFoundPost(
temp.split("/lostandfound/info")[1])));
} else {
switch (settings.name) {
case "/":
Expand Down Expand Up @@ -364,6 +371,8 @@ class MyAppState extends State<MyApp> with WidgetsBindingObserver {
return _buildRoute(settings, ExternalBlogPage());
case "/query":
return _buildRoute(settings, QueryPage());
case "/lostandfound":
return _buildRoute(settings, LostPage());
case "/query/add":
return _buildRoute(settings, QueryAddPage());
case "/messcalendar":
Expand Down
22 changes: 17 additions & 5 deletions lib/src/api/apiclient.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import 'package:InstiApp/src/api/model/buynsellPost.dart';
import 'package:InstiApp/src/api/model/community.dart';
import 'package:InstiApp/src/api/model/communityPost.dart';
import 'package:InstiApp/src/api/model/event.dart';
import 'package:InstiApp/src/api/model/lostandfoundPost.dart';
import 'package:InstiApp/src/api/model/mess.dart';
import 'package:InstiApp/src/api/model/messCalEvent.dart';
import 'package:InstiApp/src/api/model/notification.dart';
import 'package:InstiApp/src/api/model/offeredAchievements.dart';
import 'package:InstiApp/src/api/model/post.dart';
import 'package:InstiApp/src/api/model/user.dart';
import 'package:InstiApp/src/api/model/venter.dart';
import 'package:InstiApp/src/api/model/venue.dart';
import 'package:InstiApp/src/api/request/ach_verify_request.dart';
Expand All @@ -34,18 +38,17 @@ import 'package:InstiApp/src/api/response/getencr_response.dart';
import 'package:InstiApp/src/api/response/image_upload_response.dart';
import 'package:InstiApp/src/api/response/news_feed_response.dart';
import 'package:InstiApp/src/api/response/secret_response.dart';
import 'package:InstiApp/src/api/model/mess.dart';
import 'package:InstiApp/src/api/model/post.dart';
import 'package:InstiApp/src/api/model/user.dart';
import 'package:InstiApp/src/api/response/user_tags_reach_response.dart';
import 'package:retrofit/retrofit.dart' as rt;
import 'package:dio/dio.dart';
import 'package:retrofit/retrofit.dart' as rt;

import 'model/offersecret.dart';

part 'apiclient.g.dart';

//@rt.RestApi(baseUrl: "http://192.168.1.103:8000/api")
// @rt.RestApi(baseUrl: "http://10.105.177.150/api")
@rt.RestApi(baseUrl: "https://gymkhana.iitb.ac.in/instiapp/api")
@rt.RestApi(baseUrl: "https://2ba5-103-21-127-77.ngrok-free.app/api")
// @rt.RestApi(baseUrl: "https://272c-2405-201-5004-3c2f-d836-b028-6ac-ad9.ngrok-free.app/api")
abstract class InstiAppApi {
factory InstiAppApi(Dio dio, {String baseUrl}) = _InstiAppApi;
Expand Down Expand Up @@ -404,4 +407,13 @@ abstract class InstiAppApi {
@rt.POST("/buy/products")
Future<BuynSellPost> createBuynSellPost(
@rt.Header("Cookie") String sessionId, @rt.Body() BuynSellPost post);

//Lost & Found
@rt.GET('/lnf/products')
Future<List<LostAndFoundPost>> getLostAndFoundPosts(
@rt.Header("Cookie") String sessionId);

@rt.GET('/lnf/products/{id}')
Future<LostAndFoundPost> getLostAndFoundPost(
@rt.Header("Cookie") String sessionId, @rt.Path() String id);
}
39 changes: 38 additions & 1 deletion lib/src/api/apiclient.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions lib/src/api/model/lostandfoundPost.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import 'package:InstiApp/src/api/model/user.dart';
import 'package:json_annotation/json_annotation.dart';

part 'lostandfoundPost.g.dart';

@JsonSerializable()
class LostAndFoundPost {
@JsonKey(name: "id")
String? id;

@JsonKey(name: "name")
String? name;

@JsonKey(name: "description")
String? description;

@JsonKey(name: "product_image")
List<String>? imageUrl;

@JsonKey(name: "category")
String? category;

@JsonKey(name: "found_at")
String? foundAt;

@JsonKey(name: "claimed")
bool? claimed;

@JsonKey(name: "contact_details")
String? contactDetails;

@JsonKey(name: "time_of_creation")
String? timeOfCreation;

@JsonKey(name: "claimed_by")
User? claimedBy;

@JsonKey(ignore: true)
int? postedMinutes;

@JsonKey(ignore: true)
String? timeBefore;

@override
String toString() {
return 'BuySellPost{id:$id, content:$name}';
}

LostAndFoundPost({
this.id,
this.name,
this.description,
this.imageUrl,
this.foundAt,
this.claimed,
this.claimedBy,
this.contactDetails,
this.timeOfCreation,
this.timeBefore,
}) {
if (timeOfCreation != null) {
postedMinutes =
DateTime.now().difference(DateTime.parse(timeOfCreation!)).inMinutes;
if (postedMinutes! > 1440) {
timeBefore = "${postedMinutes! ~/ 1440} Days Ago";
} else if (postedMinutes! > 60) {
timeBefore = "${postedMinutes! ~/ 60} Hours Ago";
} else {
timeBefore = "${postedMinutes!} Minutes Ago";
}
}
}

factory LostAndFoundPost.fromJson(Map<String, dynamic> json) =>
_$LostAndFoundPostFromJson(json);

Map<String, dynamic> toJson() => _$LostAndFoundPostToJson(this);

getLostAndFoundPost(String s) {}
}
38 changes: 38 additions & 0 deletions lib/src/api/model/lostandfoundPost.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9c8b980

Please sign in to comment.