From 60092e9e6d37ce48523cef2ea573a7640516075e Mon Sep 17 00:00:00 2001 From: SayedZeeshanHyder Date: Mon, 8 Jul 2024 20:00:53 +0530 Subject: [PATCH] Added guidelines Functionality --- .../guidelines_screen/guidelinesscreen.dart | 154 ++++++++++++++++++ .../guidelines_screen/widgets/FAQCard.dart | 37 +++++ .../railway_screen/railway_screen.dart | 14 +- lib/services/concession_service.dart | 2 +- 4 files changed, 203 insertions(+), 4 deletions(-) create mode 100644 lib/new_ui/screens/guidelines_screen/guidelinesscreen.dart create mode 100644 lib/new_ui/screens/guidelines_screen/widgets/FAQCard.dart diff --git a/lib/new_ui/screens/guidelines_screen/guidelinesscreen.dart b/lib/new_ui/screens/guidelines_screen/guidelinesscreen.dart new file mode 100644 index 00000000..c9b93e66 --- /dev/null +++ b/lib/new_ui/screens/guidelines_screen/guidelinesscreen.dart @@ -0,0 +1,154 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:tsec_app/new_ui/screens/guidelines_screen/widgets/FAQCard.dart'; + +class GuideLinesScreen extends StatefulWidget { + @override + State createState() => _GuideLinesScreenState(); +} + +class _GuideLinesScreenState extends State { + List guideLines = []; + List faqs = []; + + @override + void initState() { + super.initState(); + setGuidelines(); + } + + setGuidelines() { + FirebaseFirestore.instance + .collection("Guidelines") + .doc("Guidelines") + .get() + .then((value) { + setState(() { + faqs = value.data()!['faqs']; + guideLines = value.data()!['guidelines']; + }); + }); + } + + @override + Widget build(BuildContext context) { + Size size = MediaQuery.of(context).size; + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.transparent, + foregroundColor: Colors.white, + ), + body: guideLines.isNotEmpty && faqs.isNotEmpty + ? SingleChildScrollView( + child: Column( + children: [ + SizedBox( + height: size.height * 0.02, + ), + Container( + width: size.width * 0.85, + child: Text( + "Guidelines", + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w700, + fontSize: 25), + ), + ), + SizedBox( + height: size.height * 0.01, + ), + ListView.builder( + padding: EdgeInsets.zero, + itemCount: guideLines.length, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + Map guideline = guideLines[index]; + if (guideline.containsKey("text")) { + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 30, vertical: 10), + child: Text( + "- This would be a point from the Guidelines therefore Tryign to make it long so that it could be checked for overflow", + style: TextStyle(color: Colors.white), + ), + ); + } else { + return Container( + margin: EdgeInsets.symmetric( + horizontal: size.width * 0.1, vertical: 20), + height: size.height * 0.2, + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage(guideline['image']), + fit: BoxFit.fill), + ), + ); + } + }, + ), + SizedBox( + height: size.height * 0.01, + ), + Container( + width: size.width * 0.85, + child: Text( + "FAQ", + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w700, + fontSize: 25), + ), + ), + SizedBox( + height: size.height * 0.01, + ), + ListView.builder( + padding: EdgeInsets.zero, + itemCount: faqs.length, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + Map faq = faqs[index]; + return FAQCard(faqContent: faq["content"],faqTitle: faq["title"],); + }), + SizedBox( + height: size.height * 0.03, + ), + ], + ), + ) + : const Center( + child: CircularProgressIndicator(), + ), + ); + } +} + +class ViewImage extends StatelessWidget { + final int index; + + ViewImage({required this.index}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Hero( + tag: "pic$index", + child: Container( + margin: EdgeInsets.symmetric(horizontal: 5, vertical: 5), + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage( + "https://i.pinimg.com/564x/98/24/71/982471c8a222007297475323a0c4f5f9.jpg"), + fit: BoxFit.fitWidth), + ), + ), + ), + ), + ); + } +} diff --git a/lib/new_ui/screens/guidelines_screen/widgets/FAQCard.dart b/lib/new_ui/screens/guidelines_screen/widgets/FAQCard.dart new file mode 100644 index 00000000..8c200271 --- /dev/null +++ b/lib/new_ui/screens/guidelines_screen/widgets/FAQCard.dart @@ -0,0 +1,37 @@ +import 'package:flutter/material.dart'; + +class FAQCard extends StatelessWidget { + final faqTitle; + final faqContent; + + FAQCard({required this.faqContent,required this.faqTitle}); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.symmetric(horizontal: 10,vertical: 7), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + border: Border.all(color: Colors.white), + ), + child: Theme( + data: ThemeData().copyWith(dividerColor: Colors.transparent), + child: ExpansionTile( + expandedCrossAxisAlignment: CrossAxisAlignment.start, + expandedAlignment: Alignment.centerLeft, + iconColor: Colors.white, + collapsedIconColor: Colors.white, + collapsedTextColor: Colors.white, + textColor: Colors.white, + title: Text(faqTitle), + children: [ + Padding( + padding: const EdgeInsets.all(15.0), + child: Text(faqContent,style: TextStyle(color: Colors.white),), + ), + ], + ), + ), + ); + } +} diff --git a/lib/new_ui/screens/railway_screen/railway_screen.dart b/lib/new_ui/screens/railway_screen/railway_screen.dart index 1b9c3800..af63b379 100644 --- a/lib/new_ui/screens/railway_screen/railway_screen.dart +++ b/lib/new_ui/screens/railway_screen/railway_screen.dart @@ -14,6 +14,7 @@ import 'package:tsec_app/models/concession_details_model/concession_details_mode import 'package:tsec_app/models/concession_request_model/concession_request_model.dart'; // import 'package:tsec_app/models/concession_request_model/concession_request_model.dart'; import 'package:tsec_app/models/student_model/student_model.dart'; +import 'package:tsec_app/new_ui/screens/guidelines_screen/guidelinesscreen.dart'; import 'package:tsec_app/new_ui/screens/railway_screen/railwayform.dart'; import 'package:tsec_app/new_ui/screens/railway_screen/widgets/concession_status_modal.dart'; import 'package:tsec_app/new_ui/screens/railway_screen/widgets/railway_dropdown_search.dart'; @@ -474,7 +475,7 @@ class _RailwayConcessionScreenState return false; } } - print(concessionRequestData); + print("Inside Build = ${concessionRequestData?.toJson()}"); return currState != "" ? Center( child: Column( @@ -645,15 +646,22 @@ class _RailwayConcessionScreenState SizedBox( height: 15, ), - Text( + /*Text( "Pass collected on ${DateFormat('dd/MM/yyyy').format((concessionRequestData.passCollected!['date'] as Timestamp).toDate())}", style: TextStyle(fontSize: 13, color: Colors.grey), - ), + ),*/ ], + ], ), ), + + SizedBox( + height: 15, + ), + InkWell(onTap: ()=> Navigator.push(context, MaterialPageRoute(builder: (context)=> GuideLinesScreen(),),),child: Text("View Guidelines",style: TextStyle(color: Colors.white),),), + ], ), ) diff --git a/lib/services/concession_service.dart b/lib/services/concession_service.dart index 384541a5..419c352d 100644 --- a/lib/services/concession_service.dart +++ b/lib/services/concession_service.dart @@ -82,7 +82,7 @@ class ConcessionService { if (value.exists) { print("Concession Request Present"); var detailsMap = value.data() as Map; - print(detailsMap); + print("Deatils Map = ${detailsMap}"); ConcessionRequestModel concessionRequestData = ConcessionRequestModel.fromJson(detailsMap); print("Concession Request Data Got = ${concessionRequestData.toJson()}");