From 613deb6ba53631592d40a08e8284c248fa83b601 Mon Sep 17 00:00:00 2001 From: HariRags Date: Tue, 28 Nov 2023 18:34:05 +0530 Subject: [PATCH 1/6] made UI of lst and found --- lib/main.dart | 6 + lib/src/api/model/lostandfound.dart | 109 ++++++ lib/src/blocs/ia_bloc.dart | 2 + lib/src/blocs/lost_and_found_bloc.dart | 45 +++ lib/src/drawer.dart | 10 + lib/src/routes/lostandfoundfeedpage.dart | 372 ++++++++++++++++++++ lib/src/routes/lostandfoundinfo.dart | 428 +++++++++++++++++++++++ pubspec.yaml | 2 +- 8 files changed, 973 insertions(+), 1 deletion(-) create mode 100644 lib/src/api/model/lostandfound.dart create mode 100644 lib/src/blocs/lost_and_found_bloc.dart create mode 100644 lib/src/routes/lostandfoundfeedpage.dart create mode 100644 lib/src/routes/lostandfoundinfo.dart diff --git a/lib/main.dart b/lib/main.dart index d9df0718..5ab68a90 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,6 +12,8 @@ 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/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/newcomplaintpage.dart'; @@ -334,6 +336,10 @@ class MyAppState extends State with WidgetsBindingObserver { return _buildRoute(settings, ExternalBlogPage()); case "/query": return _buildRoute(settings, QueryPage()); + case "/lostandfound": + return _buildRoute(settings, LostPage()); + case "/lostandfoundinfo": + return _buildRoute(settings, LostAndFoundInfoPage()); case "/query/add": return _buildRoute(settings, QueryAddPage()); case "/messcalendar": diff --git a/lib/src/api/model/lostandfound.dart b/lib/src/api/model/lostandfound.dart new file mode 100644 index 00000000..9e45facd --- /dev/null +++ b/lib/src/api/model/lostandfound.dart @@ -0,0 +1,109 @@ +import 'package:InstiApp/src/api/model/user.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'lostandfound.g.dart'; + +@JsonSerializable() +class LostAndFoundPost { + @JsonKey(name: "id") + String? id; + + @JsonKey(name: "str_id") + String? lostAndFoundPostStrId; + + @JsonKey(name: "name") + String? name; + + @JsonKey(name: "description") + String? description; + + @JsonKey(name: "product_image") + List? imageUrl; + + @JsonKey(name: "brand") + String? foundAt; + + // @JsonKey(name: "warranty") + // bool? warranty; + // + // @JsonKey(name: "packaging") + // bool? packaging; + + @JsonKey(name: "condition") + String? whenFound; + + @JsonKey(name: "action") + String? action; + + @JsonKey(name: "status") + bool? status; + + @JsonKey(name: "deleted") + bool? deleted; + + @JsonKey(name: "price") + bool? ifClaimed; + + // @JsonKey(name: "negotiable") + // bool? negotiable; + + @JsonKey(name: "contact_details") + String? contactDetails; + + @JsonKey(name: "time_of_creation") + String? timeOfCreation; + + @JsonKey(name: "category") + String? category; + + @JsonKey(name: "user") + User? user; + + @JsonKey(ignore: true) + int? postedMinutes; + + @JsonKey(ignore: true) + String? timeBefore; + + @override + String toString() { + return 'BuySellPost{id:$id, content:$name}'; + } + + LostAndFoundPost({ + this.id, + this.lostAndFoundPostStrId, + this.name, + this.description, + this.imageUrl, + this.foundAt, + // this.warranty, + // this.packaging, + this.whenFound, + this.action, + this.status, + this.deleted, + this.ifClaimed, + 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 json) => + _$LostAndFoundFromJson(json); + + Map toJson() => _$BuynSellPostToJson(this); + + getBuynSellPost(String s) {} +} diff --git a/lib/src/blocs/ia_bloc.dart b/lib/src/blocs/ia_bloc.dart index bbfc42f5..0ac337ef 100644 --- a/lib/src/blocs/ia_bloc.dart +++ b/lib/src/blocs/ia_bloc.dart @@ -130,6 +130,7 @@ class InstiAppBloc { late VerifyBloc bodyAchBloc; late CommunityBloc communityBloc; late CommunityPostBloc communityPostBloc; + late BuynSellPostBloc buynSellPostBloc; // actual current state Session? currSession; var _hostels = []; @@ -274,6 +275,7 @@ class InstiAppBloc { messCalendarBloc = MessCalendarBloc(this); communityBloc = CommunityBloc(this); communityPostBloc = CommunityPostBloc(this); + lostAndFoundBloc = LostAndFoundBloc(this); _initNotificationBatch(); } diff --git a/lib/src/blocs/lost_and_found_bloc.dart b/lib/src/blocs/lost_and_found_bloc.dart new file mode 100644 index 00000000..2f37bf19 --- /dev/null +++ b/lib/src/blocs/lost_and_found_bloc.dart @@ -0,0 +1,45 @@ +import 'package:InstiApp/src/api/model/buynsellPost.dart'; +import 'package:InstiApp/src/blocs/ia_bloc.dart'; +import 'package:rxdart/rxdart.dart'; + +enum BnSType { All } + +class BuynSellPostBloc { + final String storageID = "BuynSellPost"; + + InstiAppBloc bloc; + + List _buynsellPosts = []; + + ValueStream> get buynsellposts => _buynsellSubject.stream; + final _buynsellSubject = BehaviorSubject>(); + + String query = ""; + + BuynSellPostBloc(this.bloc); + + get buynsellpost => null; + + Future getBuynSellPost(String id) async { + return await bloc.client.getBuynSellPost(bloc.getSessionIdHeader(), id); + } + + Future deleteBuynSellPost(String id) async { + return await bloc.client.deleteBuynSellPost(bloc.getSessionIdHeader(), id); + } + + Future updateBuynSellPost(BuynSellPost post) async { + await bloc.client + .updateBuynSellPost(bloc.getSessionIdHeader(), post.id!, post); + } + + Future refresh({BnSType type = BnSType.All}) async { + _buynsellPosts = + (await bloc.client.getBuynSellPosts(bloc.getSessionIdHeader())); + _buynsellSubject.add(_buynsellPosts); + } + + Future createBuynSellPost(BuynSellPost post) async { + await bloc.client.createBuynSellPost(bloc.getSessionIdHeader(), post); + } +} diff --git a/lib/src/drawer.dart b/lib/src/drawer.dart index 1068eb53..05c05201 100644 --- a/lib/src/drawer.dart +++ b/lib/src/drawer.dart @@ -182,6 +182,16 @@ class _NavDrawerState extends State { highlight: indexSnapshot.data == 9, selected: indexSnapshot.data == 9, ), + 18: NavListTile( + icon: Icons.verified_outlined, + title: "Lost And Found", + onTap: () { + changeSelection(9, drawerState!); + navigateNamed('/lostandfound'); + }, + highlight: indexSnapshot.data == 18, + selected: indexSnapshot.data == 18, + ), 8: NavExpansionTile( title: "Utilities", initiallyExpanded: indexSnapshot.data == 8 || diff --git a/lib/src/routes/lostandfoundfeedpage.dart b/lib/src/routes/lostandfoundfeedpage.dart new file mode 100644 index 00000000..7b260e5e --- /dev/null +++ b/lib/src/routes/lostandfoundfeedpage.dart @@ -0,0 +1,372 @@ +// import 'package:InstiApp/src/api/model/buynsellPost.dart'; +import 'dart:ui'; + +import 'package:InstiApp/src/bloc_provider.dart'; +// import 'package:InstiApp/src/blocs/buynsell_post_bloc.dart'; +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/material.dart'; +import 'package:InstiApp/src/drawer.dart'; +import 'package:InstiApp/src/utils/common_widgets.dart'; + +import '../api/model/user.dart'; +import '../utils/title_with_backbutton.dart'; + +class LostNFoundPage extends StatefulWidget { + LostNFoundPage({Key? key}) : super(key: key); + //final GlobalKey _scaffoldKey = GlobalKey(); + + @override + State createState() => _LostNFoundPageState(); +} + +class _LostNFoundPageState extends State { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: LostPage(), + ); + } +} + +class LostPage extends StatefulWidget { + const LostPage({Key? key}) : super(key: key); + + @override + State createState() => _LostpageState(); +} + +class _LostpageState extends State { + final GlobalKey _scaffoldKey = GlobalKey(); + + // BnSType bnstype = BnSType.All; + bool firstBuild = true; + + // bool MyPosts = false; + + @override + void initState() { + super.initState(); + } + + Widget build(BuildContext context) { + // BuynSellPostBloc buynSellPostBloc = + // BlocProvider.of(context)!.bloc.buynSellPostBloc; + + User? profile = BlocProvider + .of(context)! + .bloc + .currSession + ?.profile; + // if (firstBuild) { + // buynSellPostBloc.refresh(); + // } + + double screen_wr = MediaQuery + .of(context) + .size + .width; + double screen_hr = MediaQuery + .of(context) + .size + .height; + double x, y; + var bloc = BlocProvider.of(context)!.bloc; + var theme = Theme.of(context); + bool isLoggedIn = bloc.currSession != null; + + screen_hr >= screen_wr ? x = 0.35 : x = 0.80; + if (1 >= screen_hr / screen_wr && screen_hr / screen_wr >= 0.5) { + x = 0.35; + } + screen_hr >= screen_wr ? y = 0.9 : y = 0.5; + double screen_w = screen_wr * y; + double screen_h = screen_hr * x; + + double myfont = ((18 / 274.4) * screen_h); + return Scaffold( + key: _scaffoldKey, + drawer: NavDrawer(), + bottomNavigationBar: MyBottomAppBar( + shape: RoundedNotchedRectangle(), + notchMargin: 4.0, + child: new Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + icon: Icon( + Icons.menu_outlined, + semanticLabel: "Show navigation drawer", + ), + onPressed: () { + _scaffoldKey.currentState?.openDrawer(); + }, + ), + ], + ), + ), + body: SafeArea( + child: !isLoggedIn + ? Container( + alignment: Alignment.center, + padding: EdgeInsets.all(50), + child: Column( + children: [ + Icon( + Icons.cloud, + size: 200, + color: Colors.grey[600], + ), + Text( + "Login To View Lost and Found Posts", + style: theme.textTheme.headline5, + textAlign: TextAlign.center, + ) + ], + crossAxisAlignment: CrossAxisAlignment.center, + ), + ) + : SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TitleWithBackButton( + child: Text( + "Lost & Found (Beta)", + style: theme.textTheme.headline4, + ), + ), + Center( + child: Container( + child: _buildContent(screen_h, screen_w, + myfont, context,) + ) + ), + ], + )), + + )); + } + + Widget _buildContent(double screen_h, double screen_w, + double myfont, BuildContext context,) { + // List posts = snapshot.data!; + var theme = Theme.of(context); + var bloc = BlocProvider.of(context)!.bloc; + User? profile = bloc.currSession?.profile; + // if (MyPosts) { + // posts = posts + // .where((post) => + // post.user?.userID == profile?.userID && post.deleted != true) + // .toList(); + // } else { + // posts = snapshot.data; + // posts = posts.where((post) => post.deleted != true).toList(); + // } + + return Center( + child: (SizedBox( + height: screen_h * 0.7, + width: screen_w * 1.2, + child: Card( + color: theme.cardColor, + margin: EdgeInsets.symmetric(horizontal: 25, vertical: 10), + child: InkWell( + onTap: () { + // Navigator.of(context) + // .pushNamed("/buyandsell/info" + (posts[index].id ?? "")); + Navigator.of(context).pushNamed('/lostandfoundinfo'); + }, + child: SizedBox( + child: Stack( + children: [ + ClipRRect( + borderRadius: BorderRadius.only( + topRight: Radius.circular(10), + topLeft: Radius.circular(10)), + child: Row( + children: [ + Center( + child: Container( + padding: EdgeInsets.fromLTRB(0, 0, 5, 0), + height: screen_h, + width: screen_h * 0.20 / 0.43, + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topRight: Radius.circular(10), + bottomLeft: Radius.circular(10)), + ), + child: ClipRRect( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(10), + topLeft: Radius.circular(10)), + child: Image( + image: AssetImage( + 'assets/buynsell/DevcomLogo.png') + ) + // child: CachedNetworkImage( + // imageUrl: posts[index].imageUrl?[0] ?? '', + // placeholder: (context, url) => Image.asset( + // 'assets/buynsell/DevcomLogo.png', + // fit: BoxFit.fill, + // ), + // errorWidget: (context, url, error) => + // new Image.asset( + // 'assets/buynsell/DevcomLogo.png', + // fit: BoxFit.fill, + // ), + // fit: BoxFit.cover, + // ), + ), + ), + ), + ], + ), + ), + Container( + padding: EdgeInsets.fromLTRB(0, 0, 10, 0), + margin: + EdgeInsets.fromLTRB(screen_h * 0.20 / 0.43, 11, 0, 50), + child: Text( + 'thsi is the title' + // posts[index].name ?? "", + // style: theme.textTheme.headline6, + // //style: TextStyle( + // // fontSize: (myfont.toInt()).toDouble(), + // // fontWeight: FontWeight.w600), + // overflow: TextOverflow.ellipsis, + // maxLines: 1, + ), + ), + Container( + margin: + EdgeInsets.fromLTRB(screen_h * 0.20 / 0.43, 105, 10, 0), + child: Text('found at ' + // (posts[index].brand ?? "").length <= 10 + // ? posts[index].brand ?? "" + // : (posts[index].brand ?? "").substring(0, 10) + '...', + // style: theme.textTheme.bodyText2, + // maxLines: 1, + ), + ), + Container( + margin: EdgeInsets.fromLTRB( + screen_w * 0.7, 110, screen_h * 0.04 / 1.5, 1), + // child: MyPosts + // ? ClipRRect( + // borderRadius: BorderRadius.circular(5), + // child: ElevatedButton( + // style: ElevatedButton.styleFrom( + // primary: Colors.red, + // ), + // onPressed: () { + // showDialog( + // context: context, + // builder: (ctx) => AlertDialog( + // title: const Text("Delete Item"), + // content: const Text( + // "Are you sure you want to delete this item?"), + // actions: [ + // TextButton( + // onPressed: () { + // posts[index].deleted = true; + // bloc.buynSellPostBloc + // .updateBuynSellPost(posts[index]); + // Navigator.of(ctx).pop(); + // bloc.buynSellPostBloc.refresh(); + // }, + // child: Text("Delete", + // maxLines: 1, + // style: TextStyle( + // fontSize: + // 12.5 / 338 * screen_w)), + // ), + // ], + // ), + // ); + // }, + // child: Text("Delete", + // maxLines: 1, + // style: TextStyle( + // fontSize: 12.5 / 338 * screen_w)), + // )) + child: Row( + children: [ + Spacer(), + Text('not claimed', + // (posts[index].action == 'giveaway' + // ? "GiveAway" + // : "₹" + + // (posts[index].price ?? 0).toString()), + // style: theme.textTheme.bodyText1, + + style: + TextStyle(fontSize: 20, fontWeight: FontWeight.w800), + ) + ], + )), + Container( + // child: MyPosts + // ? Container() + child: Row( + children: [ + Icon( + Icons.access_time, + size: ((myfont / 18 * 12).toInt()).toDouble(), + ), + Text('time' + // Text(' ' + (posts[index].timeBefore ?? ""), + // style: theme.textTheme.bodyText1!.copyWith( + // fontWeight: FontWeight.bold, + ) + //theme.textTheme.labelSmall + // style: TextStyle( + // fontWeight: FontWeight.w600, + // fontSize: ((myfont / 19 * 12).toInt()).toDouble()), + ]), + + margin: + EdgeInsets.fromLTRB(screen_h * 0.20 / 0.43, 135, 0, 0), + ), + Container( + child: Text('when found'), + // "Condition: " + (posts[index].condition ?? "") + "/10", + // style: //TextStyle( + // theme.textTheme.bodyText2, + // // fontSize: ((myfont / 18 * 12).toInt()).toDouble()), + // ), + margin: + EdgeInsets.fromLTRB(screen_h * 0.20 / 0.43, 35, 0, 0)), + Container( + padding: EdgeInsets.fromLTRB(0, 13, 10, 0), + child: Text('description' + // (posts[index].description ?? ""), maxLines: 2, + // + // overflow: TextOverflow.ellipsis, + // style: theme.textTheme.bodyText2, + // style: TextStyle( + // fontWeight: FontWeight.w500, + // fontSize: ((myfont / 16 * 12).toInt()).toDouble()), + ), + margin: + EdgeInsets.fromLTRB(screen_h * 0.20 / 0.43, 43, 0, 0)), + Row( + children: [ + Spacer(), + Container(), + ], + ) + ], + )), + ), + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + side: BorderSide(color: Colors.blue), + ), + ), + )), + ); + } +} \ No newline at end of file diff --git a/lib/src/routes/lostandfoundinfo.dart b/lib/src/routes/lostandfoundinfo.dart new file mode 100644 index 00000000..380e5816 --- /dev/null +++ b/lib/src/routes/lostandfoundinfo.dart @@ -0,0 +1,428 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:InstiApp/src/utils/common_widgets.dart'; +// import '../api/model/buynsellPost.dart'; + +class LostAndFoundInfoPage extends StatefulWidget { + // final Future post; + + LostAndFoundInfoPage(); + + // static void navigateWith( + // BuildContext context, BuynSellPost bloc, BuynSellPost post) { + // Navigator.push( + // context, + // MaterialPageRoute( + // settings: RouteSettings( + // name: "/${post.id ?? ""}", + // ), + // builder: (context) => BuyAndSellInfoPage( + // post: bloc.getBuynSellPost(post.id ?? ""), + // ), + // ), + // ); + // } + + @override + State createState() => _LostAndFoundInfoPageState(); +} + +class _LostAndFoundInfoPageState extends State { + final GlobalKey _scaffoldKey = GlobalKey(); + + // BuynSellPost? bnsPost; + + @override + void initState() { + super.initState(); + // widget.post.then((bnsPost) { + // if (this.mounted) { + // setState(() { + // this.bnsPost = bnsPost; + // }); + // } + // }); + } + + @override + Widget build(BuildContext context) { + // List? imageList = bnsPost?.imageUrl; + double screen_wr = MediaQuery.of(context).size.width; + double screen_hr = MediaQuery.of(context).size.height; + double x, y; + + var theme = Theme.of(context); + + screen_hr >= screen_wr ? x = 0.35 : x = 1; + screen_hr >= screen_wr ? y = 0.9 : y = 0.8; + var screen_w = screen_wr * y; + var screen_h = screen_hr * x; + + return Scaffold( + bottomNavigationBar: MyBottomAppBar( + shape: RoundedNotchedRectangle(), + child: new Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + icon: Icon( + Icons.menu_outlined, + color: Colors.blue.withOpacity(0), + semanticLabel: "Show navigation drawer", + ), + onPressed: () { + _scaffoldKey.currentState?.openDrawer(); + }, + ), + ], + ), + ), + body: SingleChildScrollView( + child: Column(children: [ + Container( + padding: EdgeInsets.only(top: 32, left: 16), + alignment: Alignment.topLeft, + child: Container( + padding: EdgeInsets.only(top: 32, left: 16), + alignment: Alignment.topLeft, + child: DecoratedBox( + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: Colors.blueAccent, + width: 2.0, + ), + ), + child: IconButton( + icon: Icon(Icons.arrow_back_ios_outlined, + color: Colors.blueAccent), + onPressed: () { + Navigator.pop(context); + }, + ), + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.fromLTRB(screen_w * 0.1, 15, 0, 0), + child: SizedBox( + height: screen_h / 1.2, + width: screen_w / 1, + // child: ImageCarousel(imageList), + ), + ), + Spacer(), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.fromLTRB(screen_w * 0.1, 11, 0, 0), + child: Container( + width: screen_w, + child: Text('found at ', + // bnsPost?.brand ?? "", + maxLines: 3, + overflow: TextOverflow.ellipsis, + style: theme.textTheme.headline6?.copyWith( + fontWeight: FontWeight.w100, fontSize: 20)), + ), + // style: TextStyle( + // fontSize: myfont / 1.3, fontWeight: FontWeight.w100), + ), + + ]), + // Row( + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // Container( + // margin: EdgeInsets.fromLTRB(screen_w * 0.1, 3, 0, 0), + // child: Text( + // '${bnsPost?.user?.userName ?? ""} (${bnsPost?.user?.userLDAPId ?? ""})', + // ), + // ), + // ], + // ), + + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + width: screen_w * 0.9, + margin: EdgeInsets.fromLTRB(screen_w * 0.1, 3, 0, 0), + child: Text('naefwefssssssswefme', + // bnsPost?.name ?? "", + maxLines: 3, + overflow: TextOverflow.ellipsis, + style: theme.textTheme.headline5?.copyWith( + fontWeight: FontWeight.bold, + // fontSize: 30, + fontSize: 30, + ) + // style: TextStyle( + // fontSize: myfont * 1.5, fontWeight: FontWeight.w700), + )), + ], + ), + // Row(mainAxisAlignment: MainAxisAlignment.start, children: [ + // Container( + // margin: EdgeInsets.fromLTRB(screen_w * 0.1, 5, 0, 0), + // child: Text("Condition - " + (bnsPost?.condition ?? '0') + '/10', + // style: theme.textTheme.headline6 + // ?.copyWith(fontSize: 15, fontWeight: FontWeight.w500) + // // style: TextStyle(fontSize: myfont, fontWeight: FontWeight.w100), + // ), + // ) + // ]), + Column(children: [ + Container( + width: screen_w * 0.9, + height: screen_h * 0.5, + margin: EdgeInsets.fromLTRB(0, 8, 0, 0), + child: Text('description', + // bnsPost?.description ?? "", + maxLines: 10, + overflow: TextOverflow.ellipsis, + softWrap: false, + style: theme.textTheme.bodySmall?.copyWith(fontSize: 13) + // style: TextStyle( + // fontSize: myfont * 0.75, fontWeight: FontWeight.w100), + ), + ), + SizedBox( + height: screen_h * 0.07, + ), + // SizedBox( + // width: screen_w, + // child: Text( + // "Negotiable - " + + // ((bnsPost?.negotiable ?? false) ? "Yes" : "No"), + // style: theme.textTheme.bodyLarge + // ?.copyWith(fontSize: 18, fontWeight: FontWeight.w400), + // textAlign: TextAlign.end, + // + // // style: TextStyle( + // // fontSize: myfont, fontWeight: FontWeight.w500), + // ), + // ), + SizedBox( + height: 0.09 * screen_h, + ), + SizedBox( + width: screen_w, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + + Row( + children: [ + Text( + 'Phone number', + style: theme.textTheme.headline6?.copyWith( + fontWeight: FontWeight.bold, fontSize: 17), + ), + ], + ), + Container( + margin: EdgeInsets.fromLTRB(0, 5, 0, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Icons.phone_outlined), + Text('contact details', + // bnsPost?.contactDetails ?? "", + style: theme.textTheme.headline1?.copyWith( + fontWeight: FontWeight.w100, + fontSize: 17, + ), + ), + ], + ), + ), + Container( + margin: EdgeInsets.fromLTRB(0, screen_h * 0.06, 0, 0), + child: Text( + 'claimed or not claimed', + style: theme.textTheme.headline4 + ?.copyWith(fontSize: 25, fontWeight: FontWeight.w600), + textAlign: TextAlign.left, + ), + ) + ], + ), + ), + + ], + ), + ), + ]), + + // Add more widgets below the image card + ]), + ), + ); + } +} + +class ImageCarousel extends StatefulWidget { + final List? imageList; + + ImageCarousel(this.imageList); + + @override + _ImageCarouselState createState() => _ImageCarouselState(); +} + +class _ImageCarouselState extends State { + int _currentIndex = 0; + + @override + Widget build(BuildContext context) { + double screen_wr = MediaQuery.of(context).size.width; + double screen_hr = MediaQuery.of(context).size.height; + double x, y; + + screen_hr >= screen_wr ? x = 0.35 : x = 1; + if (0.5 <= screen_hr / screen_wr && screen_hr / screen_wr <= 1) { + x = 0.8; + } + screen_hr >= screen_wr ? y = 0.9 : y = 0.8; + var screen_w = screen_wr * y; + var screen_h = screen_hr * x; + + if (widget.imageList == null || widget.imageList!.isEmpty) { + return Container( + child: Center(child: Image.asset('assets/buynsell/DevcomLogo.png')), + ); + } + + return Row( + children: [ + Expanded( + flex: 3, + child: Row( + children: [ + Container( + child: SizedBox( + height: screen_h * 0.7, + width: screen_w * 0.6, + child: PageView.builder( + itemCount: widget.imageList?.length, + onPageChanged: (index) { + setState(() { + _currentIndex = index; + }); + }, + itemBuilder: (context, index) { + return GestureDetector( + onTap: () { + setState(() { + _currentIndex = index; + }); + }, + child: ClipRRect( + borderRadius: BorderRadius.circular(15.0), + child: CachedNetworkImage( + imageUrl: widget.imageList?[index] ?? "", + fit: BoxFit.fitHeight, + ), + ), + ); + }, + ), + ), + ), + SizedBox(height: 10), + SizedBox(height: 10), + ], + ), + ), + Expanded( + child: ListView.builder( + itemCount: widget.imageList?.length, + itemBuilder: (context, index) { + return GestureDetector( + onTap: () { + setState(() { + _currentIndex = index; + }); + }, + child: Container( + margin: EdgeInsets.fromLTRB(0, 10, 10, screen_h * 0.005), + child: Container( + margin: EdgeInsets.symmetric(vertical: 5), + decoration: BoxDecoration( + border: Border.all( + color: _currentIndex == index + ? Colors.blue + : Colors.transparent, + width: 1.75, + style: BorderStyle.solid, + ), + borderRadius: BorderRadius.circular(10), + ), + child: SizedBox( + height: screen_h * 0.25, + width: screen_w * 0.1, + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: CachedNetworkImage( + imageUrl: widget.imageList?[index] ?? "", + width: 80, + height: 80, + fit: BoxFit.cover, + ), + ), + ), + ), + ), + ); + }, + ), + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: _buildDotIndicator(), + ), + ], + ); + } + + List _buildDotIndicator() { + List dots = []; + for (int i = 0; i < (widget.imageList?.length ?? 0); i++) { + dots.add( + Padding( + padding: const EdgeInsets.all(5.0), + child: GestureDetector( + onTap: () { + setState(() { + _currentIndex = i; + }); + }, + child: Container( + width: 6, + height: 6, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: _currentIndex == i ? Colors.blueGrey : Colors.grey, + ), + ), + ), + ), + ); + } + return dots; + } +} diff --git a/pubspec.yaml b/pubspec.yaml index ac61e339..9e929cd4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,7 +47,7 @@ dependencies: flutter_dynamic_icon: ^2.0.0 device_calendar: ^4.2.0 dropdown_search: ^2.0.1 - multi_select_flutter: ^4.0.0 + multi_select_flutter: 4.0.0 retrofit: ^3.0.0 logger: any dio: ^4.0.4 From b563345aa077d4bb3566b69593ee26e22f43bc13 Mon Sep 17 00:00:00 2001 From: HariRags Date: Wed, 29 Nov 2023 13:32:30 +0530 Subject: [PATCH 2/6] made json files for lost and found --- lib/src/api/apiclient.g.dart | 1 - lib/src/api/model/lostandfound.dart | 6 ++-- lib/src/api/model/lostandfound.g.dart | 49 ++++++++++++++++++++++++++ lib/src/blocs/ia_bloc.dart | 5 ++- lib/src/blocs/lost_and_found_bloc.dart | 16 ++++----- 5 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 lib/src/api/model/lostandfound.g.dart diff --git a/lib/src/api/apiclient.g.dart b/lib/src/api/apiclient.g.dart index ba05b785..3bbae3ef 100644 --- a/lib/src/api/apiclient.g.dart +++ b/lib/src/api/apiclient.g.dart @@ -8,7 +8,6 @@ part of 'apiclient.dart'; class _InstiAppApi implements InstiAppApi { _InstiAppApi(this._dio, {this.baseUrl}) { - // baseUrl ??= 'http://192.168.230.89:8000/api'; baseUrl ??= 'https://gymkhana.iitb.ac.in/instiapp/api'; } diff --git a/lib/src/api/model/lostandfound.dart b/lib/src/api/model/lostandfound.dart index 9e45facd..3d5ec028 100644 --- a/lib/src/api/model/lostandfound.dart +++ b/lib/src/api/model/lostandfound.dart @@ -101,9 +101,9 @@ class LostAndFoundPost { } factory LostAndFoundPost.fromJson(Map json) => - _$LostAndFoundFromJson(json); + _$LostAndFoundPostFromJson(json); - Map toJson() => _$BuynSellPostToJson(this); + Map toJson() => _$LostAndFoundPostToJson(this); - getBuynSellPost(String s) {} + getLostAndFoundPost(String s) {} } diff --git a/lib/src/api/model/lostandfound.g.dart b/lib/src/api/model/lostandfound.g.dart new file mode 100644 index 00000000..dc744bd6 --- /dev/null +++ b/lib/src/api/model/lostandfound.g.dart @@ -0,0 +1,49 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'lostandfound.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +LostAndFoundPost _$LostAndFoundPostFromJson(Map json) => + LostAndFoundPost( + id: json['id'] as String?, + lostAndFoundPostStrId: json['str_id'] as String?, + name: json['name'] as String?, + description: json['description'] as String?, + imageUrl: (json['product_image'] as List?) + ?.map((e) => e as String) + .toList(), + foundAt: json['brand'] as String?, + whenFound: json['condition'] as String?, + action: json['action'] as String?, + status: json['status'] as bool?, + deleted: json['deleted'] as bool?, + ifClaimed: json['price'] as bool?, + timeOfCreation: json['time_of_creation'] as String?, + ) + ..contactDetails = json['contact_details'] as String? + ..category = json['category'] as String? + ..user = json['user'] == null + ? null + : User.fromJson(json['user'] as Map); + +Map _$LostAndFoundPostToJson(LostAndFoundPost instance) => + { + 'id': instance.id, + 'str_id': instance.lostAndFoundPostStrId, + 'name': instance.name, + 'description': instance.description, + 'product_image': instance.imageUrl, + 'brand': instance.foundAt, + 'condition': instance.whenFound, + 'action': instance.action, + 'status': instance.status, + 'deleted': instance.deleted, + 'price': instance.ifClaimed, + 'contact_details': instance.contactDetails, + 'time_of_creation': instance.timeOfCreation, + 'category': instance.category, + 'user': instance.user, + }; diff --git a/lib/src/blocs/ia_bloc.dart b/lib/src/blocs/ia_bloc.dart index 0ac337ef..d0496191 100644 --- a/lib/src/blocs/ia_bloc.dart +++ b/lib/src/blocs/ia_bloc.dart @@ -7,6 +7,7 @@ import 'package:InstiApp/src/api/model/achievements.dart'; import 'package:InstiApp/src/api/model/body.dart'; import 'package:InstiApp/src/api/model/community.dart'; import 'package:InstiApp/src/api/model/event.dart'; +import 'package:InstiApp/src/api/model/lostandfound.dart'; import 'package:InstiApp/src/api/model/role.dart'; import 'package:InstiApp/src/api/model/venter.dart'; import 'package:InstiApp/src/api/request/achievement_hidden_patch_request.dart'; @@ -43,6 +44,8 @@ import 'package:rxdart/rxdart.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:InstiApp/src/api/model/notification.dart' as ntf; import 'package:dio/dio.dart'; +import 'package:InstiApp/src/blocs/lost_and_found_bloc.dart'; + enum AddToCalendar { AlwaysAsk, Yes, No } @@ -130,7 +133,7 @@ class InstiAppBloc { late VerifyBloc bodyAchBloc; late CommunityBloc communityBloc; late CommunityPostBloc communityPostBloc; - late BuynSellPostBloc buynSellPostBloc; + late LostAndFoundPostBloc lostAndFoundPostBloc; // actual current state Session? currSession; var _hostels = []; diff --git a/lib/src/blocs/lost_and_found_bloc.dart b/lib/src/blocs/lost_and_found_bloc.dart index 2f37bf19..7e068770 100644 --- a/lib/src/blocs/lost_and_found_bloc.dart +++ b/lib/src/blocs/lost_and_found_bloc.dart @@ -1,27 +1,27 @@ -import 'package:InstiApp/src/api/model/buynsellPost.dart'; +import 'package:InstiApp/src/api/model/lostandfound.dart'; import 'package:InstiApp/src/blocs/ia_bloc.dart'; import 'package:rxdart/rxdart.dart'; -enum BnSType { All } +enum lostAndFoundType { All } -class BuynSellPostBloc { - final String storageID = "BuynSellPost"; +class LostAndFoundPostBloc { + final String storageID = "LostandFoundPost"; InstiAppBloc bloc; - List _buynsellPosts = []; + List _lostAndFoundPosts = []; - ValueStream> get buynsellposts => _buynsellSubject.stream; + ValueStream> get lostAndFoundPosts => _buynsellSubject.stream; final _buynsellSubject = BehaviorSubject>(); String query = ""; - BuynSellPostBloc(this.bloc); + LostAndFoundPostBloc(this.bloc); get buynsellpost => null; Future getBuynSellPost(String id) async { - return await bloc.client.getBuynSellPost(bloc.getSessionIdHeader(), id); + return await bloc.client.getLostAndFoundPost(bloc.getSessionIdHeader(), id); } Future deleteBuynSellPost(String id) async { From 011ab0893e3344d0caef8f4d9e777937e3252767 Mon Sep 17 00:00:00 2001 From: VIBR0X <44766005+vedant-github@users.noreply.github.com> Date: Sun, 3 Dec 2023 19:54:32 +0530 Subject: [PATCH 3/6] fix apis --- lib/main.dart | 7 ++-- lib/src/routes/lostandfoundfeedpage.dart | 2 +- lib/src/routes/lostandfoundinfo.dart | 52 ++++++++++++------------ 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 2cc193ef..c83d4c7f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -291,9 +291,10 @@ class MyAppState extends State with WidgetsBindingObserver { } else if (temp.startsWith("/lostandfound/info")) { return _buildRoute( settings, - BuyAndSellInfoPage( - post: widget.bloc.buynSellPostBloc.getBuynSellPost( - temp.split("/lostandfound/info")[1]))); + LostNFoundPage( + item: widget.bloc.lostAndFoundPostBloc + .getLostAndFoundPost( + temp.split("/lostandfound/info")[1]))); } else { switch (settings.name) { case "/": diff --git a/lib/src/routes/lostandfoundfeedpage.dart b/lib/src/routes/lostandfoundfeedpage.dart index 2a7cbde1..26694c14 100644 --- a/lib/src/routes/lostandfoundfeedpage.dart +++ b/lib/src/routes/lostandfoundfeedpage.dart @@ -11,7 +11,7 @@ import '../utils/title_with_backbutton.dart'; class LostNFoundPage extends StatefulWidget { - LostNFoundPage({Key? key}) : super(key: key); + LostNFoundPage({Key? key, Future item}) : super(key: key); //final GlobalKey _scaffoldKey = GlobalKey(); @override diff --git a/lib/src/routes/lostandfoundinfo.dart b/lib/src/routes/lostandfoundinfo.dart index 869ca278..9c3897e6 100644 --- a/lib/src/routes/lostandfoundinfo.dart +++ b/lib/src/routes/lostandfoundinfo.dart @@ -1,27 +1,29 @@ +import 'package:InstiApp/src/api/model/lostandfoundPost.dart'; import 'package:InstiApp/src/utils/common_widgets.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; -// import '../api/model/buynsellPost.dart'; + +import '../api/model/lostandfoundPost.dart'; class LostAndFoundInfoPage extends StatefulWidget { - // final Future post; + final Future item; - LostAndFoundInfoPage(); + LostAndFoundInfoPage({required this.item}); - // static void navigateWith( - // BuildContext context, BuynSellPost bloc, BuynSellPost post) { - // Navigator.push( - // context, - // MaterialPageRoute( - // settings: RouteSettings( - // name: "/${post.id ?? ""}", - // ), - // builder: (context) => BuyAndSellInfoPage( - // post: bloc.getBuynSellPost(post.id ?? ""), - // ), - // ), - // ); - // } + static void navigateWith( + BuildContext context, LostAndFoundPost bloc, LostAndFoundPost item) { + Navigator.push( + context, + MaterialPageRoute( + settings: RouteSettings( + name: "/${item.id ?? ""}", + ), + builder: (context) => LostAndFoundInfoPage( + item: bloc.getLostAndFoundPost(item.id ?? ""), + ), + ), + ); + } @override State createState() => _LostAndFoundInfoPageState(); @@ -30,18 +32,18 @@ class LostAndFoundInfoPage extends StatefulWidget { class _LostAndFoundInfoPageState extends State { final GlobalKey _scaffoldKey = GlobalKey(); - // BuynSellPost? bnsPost; + LostAndFoundPost? lnfPost; @override void initState() { super.initState(); - // widget.post.then((bnsPost) { - // if (this.mounted) { - // setState(() { - // this.bnsPost = bnsPost; - // }); - // } - // }); + widget.item.then((lnfPost) { + if (this.mounted) { + setState(() { + this.lnfPost = lnfPost; + }); + } + }); } @override From b5d314fa8b637cc86108740e48cdab95936cb221 Mon Sep 17 00:00:00 2001 From: VIBR0X <44766005+vedant-github@users.noreply.github.com> Date: Sun, 3 Dec 2023 19:57:43 +0530 Subject: [PATCH 4/6] fix apis --- lib/main.dart | 3 ++- lib/src/routes/lostandfoundfeedpage.dart | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index c83d4c7f..60973a7f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -26,6 +26,7 @@ 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'; @@ -291,7 +292,7 @@ class MyAppState extends State with WidgetsBindingObserver { } else if (temp.startsWith("/lostandfound/info")) { return _buildRoute( settings, - LostNFoundPage( + LostAndFoundInfoPage( item: widget.bloc.lostAndFoundPostBloc .getLostAndFoundPost( temp.split("/lostandfound/info")[1]))); diff --git a/lib/src/routes/lostandfoundfeedpage.dart b/lib/src/routes/lostandfoundfeedpage.dart index 26694c14..2a7cbde1 100644 --- a/lib/src/routes/lostandfoundfeedpage.dart +++ b/lib/src/routes/lostandfoundfeedpage.dart @@ -11,7 +11,7 @@ import '../utils/title_with_backbutton.dart'; class LostNFoundPage extends StatefulWidget { - LostNFoundPage({Key? key, Future item}) : super(key: key); + LostNFoundPage({Key? key}) : super(key: key); //final GlobalKey _scaffoldKey = GlobalKey(); @override From 21c7aadb4e889dc0de237ab2f59dd6e68828b693 Mon Sep 17 00:00:00 2001 From: HariRags Date: Sun, 3 Dec 2023 22:43:21 +0530 Subject: [PATCH 5/6] api integration in the UI complete --- assets/login/login.html | 2 +- lib/src/api/apiclient.dart | 2 +- lib/src/api/apiclient.g.dart | 2 +- lib/src/api/model/lostandfoundPost.g.dart | 33 +- lib/src/drawer.dart | 2 +- lib/src/routes/buynsell_info.dart | 1 - lib/src/routes/lostandfoundfeedpage.dart | 425 ++++++++++------------ lib/src/routes/lostandfoundinfo.dart | 80 ++-- 8 files changed, 226 insertions(+), 321 deletions(-) diff --git a/assets/login/login.html b/assets/login/login.html index 9d4e2b0a..52d2c2e8 100644 --- a/assets/login/login.html +++ b/assets/login/login.html @@ -123,7 +123,7 @@