Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fetching technique of FAQ data changed from Json to firebase #284

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package-lock.json

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

Binary file added scp/assets/tele_manas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 25 additions & 30 deletions scp/lib/faqPage.dart → scp/lib/FAQ/faqPage.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// ignore_for_file: unused_local_variable

import 'package:flutter/material.dart';
import 'package:link_text/link_text.dart';
import 'package:scp/datamodels/faqQuestion.dart';
import 'package:provider/provider.dart';
import 'package:scp/FAQ/models/faq_model.dart';
import 'package:scp/firebase/firebaseDBHandler.dart';
import 'package:scp/utils/urlLauncher.dart';

import 'api/faqQuestions_api.dart';

class FaqPage extends StatefulWidget {
const FaqPage({key}) : super(key: key);

Expand All @@ -13,8 +15,11 @@ class FaqPage extends StatefulWidget {
}

class _FaqPageState extends State<FaqPage> {
final FAQDatabase database = FAQDatabase();
@override
Widget build(BuildContext context) {
final faq = Provider.of<List<faqModels>?>(context);
print('faq: ${faq}');
return Scaffold(
appBar: AppBar(
backgroundColor: Color.fromARGB(255, 49, 68, 76),
Expand All @@ -27,36 +32,26 @@ class _FaqPageState extends State<FaqPage> {
fontWeight: FontWeight.w600),
),
),
body: FutureBuilder<List<FaqQuestion>>(
future: FaqQuestionApi.getFaqQuestionLocally(context),
builder: (context, snapshot) {
final faqQuestion = snapshot.data;
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return Center(
child: CircularProgressIndicator(),
);
default:
if (snapshot.hasError) {
return Center(
child: Text(
"Oops! Something Went Wrong",
style: TextStyle(
fontSize: 18,
fontFamily: 'PfDin',
fontWeight: FontWeight.bold,
),
),
);
} else {
return buildFaqQuestion(faqQuestion!);
}
}
}),
body: StreamBuilder<List<faqModels>>(
stream: FAQDatabase().faqfun,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
} else if (snapshot.hasError) {
return Center(child: Text("Error: ${snapshot.error}"));
} else if (!snapshot.hasData || snapshot.data == null) {
return Center(child: Text("No FAQ data available."));
} else {
final faq = snapshot.data!;
return buildFaqQuestion(context, faq);
}
},
),
);
}

Widget buildFaqQuestion(List<FaqQuestion> faqQuestion) => ListView.builder(
Widget buildFaqQuestion(BuildContext context, List<faqModels> faqQuestion) =>
ListView.builder(
physics: BouncingScrollPhysics(),
itemCount: faqQuestion.length,
itemBuilder: (context, index) {
Expand Down
19 changes: 19 additions & 0 deletions scp/lib/FAQ/models/faq_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class faqModels {
faqModels({
required this.id,
required this.catagory,
required this.question,
required this.answer,
});
final String id;
final String catagory;
final String question;
final String answer;

// factory faqModels.fromJson(Map<String, dynamic> json) => faqModels(
// id: json['id'],
// catagory: json['catagory'],
// question: json['question'],
// answer: json['answer'],
// );
}
220 changes: 134 additions & 86 deletions scp/lib/counselling/counsellingPage.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: unused_field

import 'package:flutter/material.dart';
import 'package:scp/ui/gradients.dart';
import 'package:scp/utils/urlLauncher.dart';
Expand All @@ -11,6 +13,35 @@ class CounsellingPage extends StatefulWidget {

class _CounsellingPageState extends State<CounsellingPage> {
final Color primaryColor = Color.fromARGB(255, 49, 68, 76);
List<Map<String, String>> _CounsellingData = [
{
'title': 'Your Dost:',
'description':
'In collaboration with Your Dost, online counselling services were started in November 2021. Your Dost is a platform for emotional support and counselling that promotes mental wellness . All the students of our institute can access this service by logging in using their Zimbra email address in the link provided below.'
},
{
'title': 'Offline Counselling:',
'description':
'Institute recognizes the importance of one\'s mental health and has appointed a counsellor and a psychiatrist. Dr PK Nanda, is the psychiatrist and Dr Ekta Sanghi, the Counsellor under the Institute Counselling Services. While a Counselor helps people address the cause of their problems, a Psychia-trist prescribes and monitors medications to control symp-toms. Appointments can be made through the ICS app.'
},
{
'title': 'tele MANAS:',
'description':
' A toll free mental health helpline to provide support and assistance to people struggling with mental health issues-ref. from Ministry of Health & Family Welfare-reg.'
}
];
List<Map<String, String>> _CounsellingBanner = [
{
'title': 'Your Dost Counselling',
'link': 'https://www.yourdost.com/',
'image': 'assets/ydd.png'
},
{
'title': 'tele MANAS',
'link': 'https://telemanas.mohfw.gov.in/#/home',
'image': 'assets/tele_manas.png',
}
];

@override
Widget build(BuildContext context) {
Expand All @@ -24,100 +55,116 @@ class _CounsellingPageState extends State<CounsellingPage> {
),
backgroundColor: primaryColor,
),
body: ListView(
physics: BouncingScrollPhysics(),
children: [
Padding(
padding: EdgeInsets.only(
top: width * 0.05,
right: width * 0.05,
left: width * 0.05,
),
child: Text(
"Your Dost:",
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w500,
fontFamily: 'PfDin',
color: Color.fromRGBO(74, 232, 190, 1),
),
body: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
physics: NeverScrollableScrollPhysics(),
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: _CounsellingData.length,
itemBuilder: (context, index) {
return studentcoun_container(
width,
_CounsellingData[index]['title'].toString(),
_CounsellingData[index]['description'].toString(),
);
}),
SizedBox(
height: 50,
),
),
Padding(
padding: EdgeInsets.only(
top: width * 0.024,
right: width * 0.05,
left: width * 0.05,
),
child: Text(
"In collaboration with Your Dost, online counselling services were started in November 2021. Your Dost is a platform for emotional support and counselling that promotes mental wellness . All the students of our institute can access this service by logging in using their Zimbra email address in the link provided below.",
style: TextStyle(
fontSize: 16.4,
fontWeight: FontWeight.w500,
fontFamily: 'PfDin',
color: Color.fromRGBO(25, 39, 45, 1),
),
GridView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 1,
),
itemCount: _CounsellingBanner.length,
itemBuilder: (context, index) {
if (index + 1 == 3) {
return Container(
child: gesture_container(
context,
_CounsellingBanner[index]['link'].toString(),
_CounsellingBanner[index]['title'].toString(),
_CounsellingBanner[index]['image'].toString(),
),
);
} else {
return Container(
padding: EdgeInsets.all(5),
child: gesture_container(
context,
_CounsellingBanner[index]['link'].toString(),
_CounsellingBanner[index]['title'].toString(),
_CounsellingBanner[index]['image'].toString(),
),
);
}
}),
SizedBox(height: 3),
gesture_container(
context,
'https://forms.gle/e8K6ZVvoNZ683ZRp6',
'Offline Coundelling',
'assets/icon-white.png',
),
),
Padding(
padding: EdgeInsets.only(
top: width * 0.05,
right: width * 0.05,
left: width * 0.05,
),
child: Text(
"Offline Counselling:",
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w500,
fontFamily: 'PfDin',
color: Color.fromRGBO(74, 232, 190, 1),
),
SizedBox(
height: 20,
),
],
),
),
);
}

GestureDetector gesture_container(
BuildContext context, String url, String title, String image) {
return GestureDetector(
onTap: () {
launchURL(url);
},
child: counsellingCard(title, image, MediaQuery.of(context).size.width),
);
}

Column studentcoun_container(double width, String title, String description) {
return Column(
children: [
Padding(
padding: EdgeInsets.only(
top: width * 0.05,
right: width * 0.05,
left: width * 0.05,
),
Padding(
padding: EdgeInsets.only(
top: width * 0.024,
right: width * 0.05,
left: width * 0.05,
),
child: Text(
"Institute recognizes the importance of one's mental health and has appointed a counsellor and a psychiatrist. Dr PK Nanda, is the psychiatrist and Dr Ekta Sanghi, the Counsellor under the Institute Counselling Services. While a Counselor helps people address the cause of their problems, a Psychia-trist prescribes and monitors medications to control symp-toms. Appointments can be made through the ICS app.",
style: TextStyle(
fontSize: 16.4,
fontWeight: FontWeight.w500,
fontFamily: 'PfDin',
color: Color.fromRGBO(25, 39, 45, 1),
),
child: Text(
title,
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w500,
fontFamily: 'PfDin',
color: Color.fromRGBO(74, 232, 190, 1),
),
),
SizedBox(
height: 50,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onTap: () {
launchURL("https://www.yourdost.com/");
},
child: counsellingCard("YourDOST Counselling", 'assets/ydd.png',
MediaQuery.of(context).size.width),
),
GestureDetector(
onTap: () {
launchURL("https://forms.gle/e8K6ZVvoNZ683ZRp6");
},
child: counsellingCard("OFFLINE Counselling",
'assets/icon-white.png', MediaQuery.of(context).size.width),
),
],
),
Padding(
padding: EdgeInsets.only(
top: width * 0.024,
right: width * 0.05,
left: width * 0.05,
),
SizedBox(
height: 50,
child: Text(
description,
style: TextStyle(
fontSize: 16.4,
fontWeight: FontWeight.w500,
fontFamily: 'PfDin',
color: Color.fromRGBO(25, 39, 45, 1),
),
),
],
),
),
],
);
}
}
Expand All @@ -128,6 +175,7 @@ Widget counsellingCard(
double width,
) {
return Container(
padding: EdgeInsets.all(3),
clipBehavior: Clip.antiAliasWithSaveLayer,
height: width * 0.4,
width: width * 0.4,
Expand Down
Loading
Loading