Skip to content

Commit

Permalink
Made changes according to the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
sujithsojan committed Jun 10, 2024
1 parent 759db4b commit 45883ec
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
50 changes: 31 additions & 19 deletions lib/questions_summary.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';

class QuestionSummary extends StatelessWidget {

const QuestionSummary(this.summaryData, {super.key});

final List<Map<String, Object>> summaryData;
Expand All @@ -12,27 +11,40 @@ class QuestionSummary extends StatelessWidget {
height: 300,
child: SingleChildScrollView(
child: Column(
children:
summaryData.map((data) {
return Row(
children: [
Text(((data['question_index'] as int) +1).toString()),
Expanded(
child: Column(
children: [
Text(data['question'] as String),
const SizedBox(height: 5,),
Text(data['user_answer'] as String),
Text(data['correct_answer'] as String),
],
),
children: summaryData.map((data) {
bool isCorrect = data['user_answer'] == data['correct_answer'];
return Row(
crossAxisAlignment: CrossAxisAlignment.baseline, // Add this
textBaseline: TextBaseline.alphabetic, // Add this
children: [
Container(
width: 30,
height: 30,
decoration: BoxDecoration(
color: isCorrect ? Colors.green : Colors.red,
borderRadius: BorderRadius.circular(15),
),
child: Center(
child: Text(((data['question_index'] as int) + 1).toString()),
),
),
const SizedBox(width: 10,),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(data['question'] as String),
const SizedBox(height: 5,),
Text('Your answer: ${data['user_answer']}'),
Text('Correct answer: ${data['correct_answer']}'),
],
),
],
);
}).toList(),
),
],
);
}).toList(),
),
),
);

}
}
15 changes: 11 additions & 4 deletions lib/results-screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,20 @@ class ResultScreen extends StatelessWidget {
const SizedBox(
height: 20,
),
TextButton(
Center(
child: TextButton(
onPressed: () {},
child: const Text('Restart Quiz!',
style: TextStyle(color: Colors.black)))
child: Row(
children: [
Icon(Icons.replay),
const Text('Restart Quiz!', style: TextStyle(color: Colors.black)),
],
),
),
)
],
),
),
);
}
}
}

0 comments on commit 45883ec

Please sign in to comment.