Skip to content

Commit

Permalink
fix: Quiz Screen display bug
Browse files Browse the repository at this point in the history
Issue - Screen was not able to fetch data from backend
  • Loading branch information
AdarshRawat1 committed Nov 24, 2024
1 parent 304ccc0 commit f1718db
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class RecommendedVideos extends StatelessWidget {
seconds: 2)); // Optional delay for smooth UX
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const QuizPage()),
MaterialPageRoute(builder: (context) => QuizPage()),
);
},
style: ElevatedButton.styleFrom(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/features/home/screens/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class _HomePageState extends State<HomePage> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const QuizPage(),
builder: (context) => QuizPage(),
),
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class QuizQuestionWidget extends StatefulWidget {
final Function(int) onPressed;

const QuizQuestionWidget({
super.key,
Key? key,
required this.questionIndex,
required this.correctAnswerIndex,
required this.question,
required this.onPressed,
});
}) : super(key: key);

@override
_QuizQuestionWidgetState createState() => _QuizQuestionWidgetState();
Expand Down
24 changes: 11 additions & 13 deletions lib/src/features/quiz/screens/quiz_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import 'package:guardiancare/src/constants/colors.dart';
import 'package:guardiancare/src/features/quiz/screens/quiz_questions_page.dart';

class QuizPage extends StatefulWidget {
const QuizPage({super.key});

@override
_QuizPageState createState() => _QuizPageState();
}
Expand All @@ -24,17 +22,17 @@ class _QuizPageState extends State<QuizPage> {
Future<void> getQuizes() async {
QuerySnapshot querySnapshot =
await FirebaseFirestore.instance.collection('quizes').get();
List<Map<String, dynamic>> quizes = [];
List<Map<String, dynamic>> _quizes = [];
for (var doc in querySnapshot.docs) {
if (doc["name"] != null && doc["use"]) {
quizes.add({
_quizes.add({
"name": doc["name"],
"thumbnail": doc["thumbnail"],
});
}
}
setState(() {
quizes = quizes;
quizes = _quizes;
});
}

Expand Down Expand Up @@ -112,14 +110,14 @@ class QuizTile extends StatelessWidget {
fit: BoxFit.cover,
),
Container(
padding: const EdgeInsets.all(8),
child: Text(
capitalizeEach(quiz["name"]),
style: const TextStyle(
fontSize: 25,
color: tPrimaryColor,
fontWeight: FontWeight.w600),
))
padding: EdgeInsets.all(8),
child: Text(
capitalizeEach(quiz["name"]),
style: const TextStyle(
fontSize: 25,
color: tPrimaryColor,
fontWeight: FontWeight.w600),
))
],
),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/features/quiz/screens/quiz_questions_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:guardiancare/src/features/quiz/controllers/quiz_controller.dart'
class QuizQuestionsPage extends StatefulWidget {
final List<Map<String, dynamic>> questions;

const QuizQuestionsPage({super.key, required this.questions});
QuizQuestionsPage({required this.questions});

@override
_QuizQuestionsPageState createState() => _QuizQuestionsPageState();
Expand Down Expand Up @@ -84,7 +84,7 @@ class _QuizQuestionsPageState extends State<QuizQuestionsPage> {
onPressed: isBlocked ? null : _goToPreviousQuestion,
child: const Text(
'Previous',
style: TextStyle(
style: const TextStyle(
color: tPrimaryColor,
),
),
Expand Down

0 comments on commit f1718db

Please sign in to comment.