-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathquestion16.dart
More file actions
128 lines (111 loc) · 3.69 KB
/
question16.dart
File metadata and controls
128 lines (111 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import 'dart:convert';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:remar_flutter_app/question_screens/global.dart';
import 'package:url_launcher/url_launcher.dart';
class QuestionAnswer16Page extends StatefulWidget {
const QuestionAnswer16Page({
Key? key
}) : super(key: key);
@override
_QuestionAnswer16Page createState() => _QuestionAnswer16Page();
}
class _QuestionAnswer16Page extends State<QuestionAnswer16Page> {
late String description = '';
String selectedAnswer = '';
late String choiceOneText = '';
late String choiceTwoText = '';
late String choiceThreeText = '';
@override
void initState() {
super.initState();
loadQuestionData();
}
void loadQuestionData() async {
enableForwardNavigation = false;
// Load JSON data from asset file
String jsonString = await DefaultAssetBundle.of(context)
.loadString('assets/raw_eng/questions2Modified.json');
// Parse JSON data
List<dynamic> jsonData = jsonDecode(jsonString);
// Extract question data for Question16
Map<String, dynamic> questionData = jsonData[15];
// Assign values to variables
setState(() {
description = questionData['description'];
choiceOneText = questionData['choiceOneText'];
choiceTwoText = questionData['choiceTwoText'];
choiceThreeText = questionData['choiceThreeText'];
// enableForwardNavigation = true;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 30),
buildButton(choiceOneText, selectedAnswer == choiceOneText),
const SizedBox(height: 10),
buildButton(choiceTwoText, selectedAnswer == choiceTwoText),
const SizedBox(height: 10),
buildButton(choiceThreeText, selectedAnswer == choiceThreeText),
const SizedBox(height: 30),
RichText(
textAlign: TextAlign.center,
text: TextSpan(
text:
'If you want to contact REMAR, find out about ways to engage more with this research, ask or suggest something, please send a message to ',
style: const TextStyle(
fontSize: 16,
color: Colors.black,
),
children: [
TextSpan(
text: 'remar.quest@gmail.com',
style: const TextStyle(
color: Color.fromARGB(255, 14, 172, 51),
),
recognizer: TapGestureRecognizer()
..onTap = () {
launch(
'mailto:remar.quest@gmail.com?subject=Question for REMAR');
},
),
],
),
),
],
),
),
);
}
Widget buildButton(String title, bool selected) {
return SizedBox(
width: double.infinity,
height: 48.0,
child: ElevatedButton(
onPressed: () {
setState(() {
selectedAnswer = title;
});
},
style: ElevatedButton.styleFrom(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
backgroundColor: Colors.green, // Button color remains green
),
child: Text(
title,
style: TextStyle(
color: Colors.black, // Text color remains black
fontWeight: selected ? FontWeight.bold : FontWeight.normal,
),
),
),
);
}
}