Commit 866eb4bb authored by Nagahawatta S.S's avatar Nagahawatta S.S

Summary page added

parent b3084e13
import 'package:Autism/pages/Comp1/Comp1Intro.dart';
import 'package:Autism/pages/Comp1/Comp1Welcome.dart';
import 'package:Autism/pages/Comp2/Comp2Summary.dart';
import 'package:Autism/pages/Results.dart';
import 'package:Autism/pages/Comp1/Step1/Comp1Step1First.dart';
import 'package:Autism/pages/Comp1/Step1/Comp1Step1Second.dart';
......@@ -12,6 +13,8 @@ import 'package:Autism/pages/Comp3/Comp3Page1.dart';
import 'package:Autism/pages/Comp3/Comp3Page2.dart';
import 'package:Autism/pages/Comp3/Comp3Page3.dart';
import 'package:Autism/pages/Comp3/Comp3Page4.dart';
import 'package:Autism/pages/Comp3/Summary.dart';
import 'package:Autism/pages/Comp3/Comp3Results.dart';
import 'package:Autism/pages/Home.dart';
import 'package:Autism/pages/Comp1/Comp1Results.dart';
import 'package:Autism/pages/Welcome.dart';
......@@ -86,49 +89,49 @@ class MyApp extends StatelessWidget {
appbar: true,
),
'/Comp2Page1': (context) => MyTemplate(
title: 'දෙවැනි කාර්යය',
title: 'දෙවැනි කාර්යය-උච්චාරණ කුසලතා විශ්ලේෂණය',
child: Comp2Page1(),
bg: MyStyles.cPrimary,
appbar: true,
),
'/Comp2Page2': (context) => MyTemplate(
title: 'දෙවැනි කාර්යය',
title: 'දෙවැනි කාර්යය-උච්චාරණ කුසලතා විශ්ලේෂණය',
child: Comp2Page2(),
bg: MyStyles.cPrimary,
appbar: true,
),
'/Comp2Page3': (context) => MyTemplate(
title: 'දෙවැනි කාර්යය',
title: 'දෙවැනි කාර්යය-උච්චාරණ කුසලතා විශ්ලේෂණය',
child: Comp2Page3(),
bg: MyStyles.cPrimary,
appbar: true,
),
'/Comp3Page1': (context) => MyTemplate(
title: 'තුන්වන කාර්යය',
title: 'තුන්වන කාර්යය-පිළිතුරු වල නිරවද්‍යතාවය ඇගයීම',
child: Comp3Page1(),
bg: MyStyles.cPrimary,
appbar: true,
),
'/Comp3Page2': (context) => MyTemplate(
title: 'තුන්වන කාර්යය',
title: 'තුන්වන කාර්යය-පිළිතුරු වල නිරවද්‍යතාවය ඇගයීම',
child: Comp3Page2(),
bg: MyStyles.cPrimary,
appbar: true,
),
'/Comp3Page3': (context) => MyTemplate(
title: 'තුන්වන කාර්යය',
title: 'තුන්වන කාර්යය-පිළිතුරු වල නිරවද්‍යතාවය ඇගයීම',
child: Comp3Page3(),
bg: MyStyles.cPrimary,
appbar: true,
),
'/Comp3Page4': (context) => MyTemplate(
title: 'තුන්වන කාර්යය',
title: 'තුන්වන කාර්යය-පිළිතුරු වල නිරවද්‍යතාවය ඇගයීම',
child: Comp3Page4(),
bg: MyStyles.cPrimary,
appbar: true,
),
'/Results': (context) => MyTemplate(
title: 'ප්‍රතීඵලය',
title: 'ප්‍රතීඵලය-උච්චාරණ කුසලතා විශ්ලේෂණය',
child: Results(),
bg: MyStyles.cPrimary,
appbar: true,
......@@ -139,6 +142,24 @@ class MyApp extends StatelessWidget {
bg: MyStyles.cPrimary,
appbar: true,
),
'/Summary': (context) => MyTemplate(
title: 'Summary-පිළිතුරු වල නිරවද්‍යතාවය ඇගයීම',
child: Summary(),
bg: MyStyles.cPrimary,
appbar: true,
),
'/Comp3Results': (context) => MyTemplate(
title: 'Summary-පිළිතුරු වල නිරවද්‍යතාවය ඇගයීම',
child: Comp3Results(),
bg: MyStyles.cPrimary,
appbar: true,
),
'/Comp2Summary': (context) => MyTemplate(
title: 'Summary-උච්චාරණ කුසලතා විශ්ලේෂණය',
child: Comp2Summary(),
bg: MyStyles.cPrimary,
appbar: true,
),
});
}
}
......
import 'dart:io';
import 'package:Autism/pages/Comp2/KeyValueComp2.dart';
import 'package:Autism/widgets/AudioInput.dart';
import 'package:Autism/widgets/ButtonIcon.dart';
import 'package:Autism/widgets/ImageCard.dart';
......@@ -8,6 +9,7 @@ import 'package:Autism/MyStyles.dart' as MyStyles;
import 'package:Autism/Api.dart' as Api;
import 'package:dio/dio.dart';
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart';
class Comp2Page3 extends StatefulWidget {
const Comp2Page3({super.key});
......@@ -24,7 +26,42 @@ class _Comp2Page3State extends State<Comp2Page3> {
String audio = '';
String color = '';
Future sendRequest() async {
// Map<String, String> keyValueData = {};
List<KeyValueComp2> keyValueDataComp2 = [];
// void addKeyValuePair(String key, String value) {
// setState(() {
// keyValueData[key] = value;
// });
// }
void addKeyValuePair(String key, String value) {
setState(() {
keyValueDataComp2.add(KeyValueComp2(key, value));
});
}
Future<void> saveDataToLocalStorage(String key, String value) async {
final prefs = await SharedPreferences.getInstance();
final keyValueListComp2 = prefs.getStringList('keyValueDataComp2') ?? [];
// Check if the key already exists in the list
final existingPairIndex = keyValueListComp2.indexWhere((entry) {
final parts = entry.split(':');
return parts[0] == key;
});
if (existingPairIndex != -1) {
// If the key exists, update the value
keyValueListComp2[existingPairIndex] = '$key:$value';
} else {
// If the key doesn't exist, add a new key-value pair
keyValueListComp2.add('$key:$value');
}
await prefs.setStringList('keyValueDataComp2', keyValueListComp2);
}
Future sendRequest(String t) async {
try {
Response response;
var dio = Dio();
......@@ -80,6 +117,7 @@ class _Comp2Page3State extends State<Comp2Page3> {
print(response.data);
print(response.data["pronounce-validation"]);
print(color);
saveDataToLocalStorage(t, color);
nextPage('/Results');
}
} catch (e) {
......@@ -124,7 +162,7 @@ class _Comp2Page3State extends State<Comp2Page3> {
}),
recordedFile != null
? ButtonIcon(
click: () => sendRequest(),
click: () => sendRequest(text),
icon: Icons.arrow_forward_ios,
bg: MyStyles.cbtnPrimary,
)
......
import 'package:Autism/pages/Comp2/KeyValueComp2.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class Comp2Summary extends StatefulWidget {
const Comp2Summary({super.key});
@override
_Comp2SummaryState createState() => _Comp2SummaryState();
}
class _Comp2SummaryState extends State<Comp2Summary> {
List<KeyValueComp2> keyValueDataComp2 = [];
@override
void initState() {
super.initState();
loadDataFromLocalStorage(); // Load data from local storage when the widget initializes
}
// Function to load the data from local storage
Future<void> loadDataFromLocalStorage() async {
final prefs = await SharedPreferences.getInstance();
final keyValueListComp2 = prefs.getStringList('keyValueDataComp2') ?? [];
setState(() {
keyValueDataComp2 = keyValueListComp2.map((entry) {
final parts = entry.split(':');
return KeyValueComp2(parts[0], parts[1]);
}).toList();
});
}
// Function to clear local storage related to this widget
Future<void> clearLocalStorage() async {
final prefs = await SharedPreferences.getInstance();
prefs.remove('keyValueDataComp2'); // Remove the stored key-value pairs
setState(() {
keyValueDataComp2 = []; // Clear the data displayed in the widget
});
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Text(
'සාරාංශය',
style: TextStyle(
fontSize: 24, // You can adjust the font size
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 40),
ListView.builder(
shrinkWrap: true,
itemCount: keyValueDataComp2.length,
itemBuilder: (context, index) {
final key = keyValueDataComp2[index].key;
final value = keyValueDataComp2[index].value;
bool isRed = value == 'රතු පාට';
bool isGreen = value == 'කොළ පාට';
return Row(
children: [
Container(
width: 220, // Set the width to your desired value
child: ListTile(
title: Text(key),
),
),
Expanded(
child: Container(
color: isRed
? Colors.red
: isGreen
? Colors.green
: null,
child: ListTile(
title: Text(value),
),
),
)
],
);
},
),
SizedBox(
height: 50,
),
ElevatedButton(
onPressed: () {
clearLocalStorage();
Navigator.pushNamed(context, '/home');
},
style: ElevatedButton.styleFrom(
primary: Colors.blue, // Background color
onPrimary: Colors.white, // Text color
),
child: Text(
'පළමු පිටුවට',
style: TextStyle(
color: Colors.white, // Text color
),
),
)
],
);
}
}
......@@ -12,45 +12,108 @@ class Comp2Page2 extends StatefulWidget {
class _Comp2Page2State extends State<Comp2Page2> {
@override
Widget build(BuildContext context) {
void nextPage(String route) {
Navigator.pushNamedAndRemoveUntil(context, route,(r) => false, arguments: {});
Navigator.pushNamedAndRemoveUntil(context, route, (r) => false,
arguments: {});
}
return Column(
children: [
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 01', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'අක්කි එක්ක ආවෙ.', 'audio':'assets/comtwo/child05_01.wav','image':'assets/comtwo/1.jpg'}
SizedBox(
height: 30,
),
ButtonXL(
route: '/Comp2Page3',
title: 'පින්තූරය 01',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'අක්කි එක්ක ආවෙ.',
'audio': 'assets/comtwo/child05_01.wav',
'image': 'assets/comtwo/1.jpg'
}),
SizedBox(
height: 30,
),
ButtonXL(
route: '/Comp2Page3',
title: 'පින්තූරය 02',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'අක්කා කෙනෙක් ඉන්නවා',
'audio': 'assets/comtwo/child05_02.wav',
'image': 'assets/comtwo/2.jpg'
}),
SizedBox(
height: 30,
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 02', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'අක්කා කෙනෙක් ඉන්නවා', 'audio':'assets/comtwo/child05_02.wav','image':'assets/comtwo/2.jpg'}
ButtonXL(
route: '/Comp2Page3',
title: 'පින්තූරය 03',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'මල්ලි කෙනෙක් ඉන්නවා',
'audio': 'assets/comtwo/child05_03.wav',
'image': 'assets/comtwo/3.jpg'
}),
SizedBox(
height: 30,
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 03', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'මල්ලි කෙනෙක් ඉන්නවා', 'audio':'assets/comtwo/child05_03.wav','image':'assets/comtwo/3.jpg'}
ButtonXL(
route: '/Comp2Page3',
title: 'පින්තූරය 04',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'අම්මි එක්ක ආවෙ.',
'audio': 'assets/comtwo/child05_04.wav',
'image': 'assets/comtwo/4.jpg'
}),
SizedBox(
height: 30,
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 04', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'අම්මි එක්ක ආවෙ.', 'audio':'assets/comtwo/child05_04.wav','image':'assets/comtwo/4.jpg'}
ButtonXL(
route: '/Comp2Page3',
title: 'පින්තූරය 05',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'තාත්ති එක්ක ආවෙ.',
'audio': 'assets/comtwo/child05_05.wav',
'image': 'assets/comtwo/5.png'
}),
SizedBox(
height: 30,
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 05', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'තාත්ති එක්ක ආවෙ.', 'audio':'assets/comtwo/child05_05.wav','image':'assets/comtwo/5.png'}
ButtonXL(
route: '/Comp2Page3',
title: 'පින්තූරය 06',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'චොකලට් වලට කැමතියි.',
'audio': 'assets/comtwo/child05_06.wav',
'image': 'assets/comtwo/6.png'
}),
SizedBox(
height: 30,
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 06', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'චොකලට් වලට කැමතියි.', 'audio':'assets/comtwo/child05_06.wav','image':'assets/comtwo/6.png'}
ButtonXL(
route: '/Comp2Page3',
title: 'පින්තූරය 07',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'තඩි බව්වෙක් ඉන්නවා',
'audio': 'assets/comtwo/child05_07.wav',
'image': 'assets/comtwo/7.jpg'
}),
SizedBox(
height: 30,
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 07', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'තඩි බව්වෙක් ඉන්නවා', 'audio':'assets/comtwo/child05_07.wav','image':'assets/comtwo/7.jpg'}
ButtonXL(
route: '/Comp2Summary', title: 'අවසාන ප්‍රතිඵලය',
bg: MyStyles.cbtnPrimary,
// arguments:{ 'text':'', 'audio':'','image':''}
),
SizedBox(height: 30,),
ButtonXL(route: '/Results', title: 'අවසාන ප්‍රතිඵලය', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'', 'audio':'','image':''}
SizedBox(
height: 30,
),
SizedBox(height: 30,),
],
);
}
......
class KeyValueComp2 {
final String key;
final String value;
KeyValueComp2(this.key, this.value);
}
......@@ -12,17 +12,23 @@ class Comp3Page1 extends StatefulWidget {
class _Comp3Page1State extends State<Comp3Page1> {
@override
Widget build(BuildContext context) {
void nextPage(String route) {
Navigator.pushNamedAndRemoveUntil(context, route,(r) => false, arguments: {});
Navigator.pushNamedAndRemoveUntil(context, route, (r) => false,
arguments: {});
}
return Column(
children: [
SizedBox(width: 180,child:
Image.asset('assets/images/Component 3 - img 01.png')
SizedBox(
width: 180,
child: Image.asset('assets/images/Component 3 - img 01.png')),
SizedBox(
height: 30,
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp3Page2', title: 'ආරම්භ කරන්න', bg: MyStyles.cbtnPrimary),
ButtonXL(
route: '/Comp3Page2',
title: 'ආරම්භ කරන්න',
bg: MyStyles.cbtnPrimary),
],
);
}
......
......@@ -13,16 +13,28 @@ class Comp3Page2 extends StatefulWidget {
class _Comp3Page2State extends State<Comp3Page2> {
@override
Widget build(BuildContext context) {
void nextPage(String route) {
Navigator.pushNamedAndRemoveUntil(context, route,(r) => false, arguments: {});
Navigator.pushNamedAndRemoveUntil(context, route, (r) => false,
arguments: {});
}
return Column(
children: [
SizedBox(height: 10,),
Instructions(title: 'උපදෙස්',body: 'ඊලග පියවරට බොත්තම එබිමෙන් පසුව දී පින්තුර ඇසුරෙන් ලමයාගෙන් ප්‍රශ්න අසන්න. පිලිතුර පටිගත කිරීමට මයික්‍රෆොනය සලකුන ඔබන්න. පටිගත කිරිම අවසන් වු පසු ඊතල සලකුන ඔබා ප්‍රතිපල පිටුවට පිවිසෙන්න.',),
SizedBox(height: 30,),
ButtonXL(route: '/Comp3Page3', title: 'ඊලග පියවරට', bg: MyStyles.cbtnPrimary),
SizedBox(
height: 10,
),
Instructions(
title: 'උපදෙස්',
body:
'ඊලග පියවරට බොත්තම එබිමෙන් පසුව දී පින්තුර ඇසුරෙන් ලමයාගෙන් ප්‍රශ්න අසන්න. පිලිතුර පටිගත කිරීමට මයික්‍රෆොනය සලකුන ඔබන්න. පටිගත කිරිම අවසන් වු පසු ඊතල සලකුන ඔබා ප්‍රතිපල පිටුවට පිවිසෙන්න.',
),
SizedBox(
height: 30,
),
ButtonXL(
route: '/Comp3Page3',
title: 'ඊලග පියවරට',
bg: MyStyles.cbtnPrimary),
],
);
}
......
......@@ -12,37 +12,85 @@ class Comp3Page3 extends StatefulWidget {
class _Comp3Page3State extends State<Comp3Page3> {
@override
Widget build(BuildContext context) {
void nextPage(String route) {
Navigator.pushNamedAndRemoveUntil(context, route,(r) => false, arguments: {});
Navigator.pushNamedAndRemoveUntil(context, route, (r) => false,
arguments: {});
}
return Column(
children: [
SizedBox(height: 30,),
ButtonXL(route: '/Comp3Page4', title: 'ප්‍රශ්නය 01', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'පුතා කවුරු එක්කද ආවේ?', 'audio':'assets/comthree/Answer1.wav','image':'assets/comthree/1.png'}
SizedBox(
height: 30,
),
ButtonXL(
route: '/Comp3Page4',
title: 'ප්‍රශ්නය 01',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'පුතා කවුරු එක්කද ආවේ?',
'audio': 'assets/comthree/Answer1.wav',
'image': 'assets/comthree/1.png'
}),
SizedBox(
height: 30,
),
ButtonXL(
route: '/Comp3Page4',
title: 'ප්‍රශ්නය 02',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'මේ පින්තුරයේ ඇති බොලයේ පාට මොකක්ද?',
'audio': 'assets/comthree/Answer2.wav',
'image': 'assets/comthree/2.jpg'
}),
SizedBox(
height: 30,
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp3Page4', title: 'ප්‍රශ්නය 02', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'මේ පින්තුරයේ ඇති බොලයේ පාට මොකක්ද?', 'audio':'assets/comthree/Answer2.wav','image':'assets/comthree/2.jpg'}
ButtonXL(
route: '/Comp3Page4',
title: 'ප්‍රශ්නය 03',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'මේ පින්තුරයේ ඇති වාහනය මොකක්ද?',
'audio': 'assets/comthree/Answer3.wav',
'image': 'assets/comthree/3.jpg'
}),
SizedBox(
height: 30,
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp3Page4', title: 'ප්‍රශ්නය 03', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'මේ පින්තුරයේ ඇති වාහනය මොකක්ද?', 'audio':'assets/comthree/Answer3.wav','image':'assets/comthree/3.jpg'}
ButtonXL(
route: '/Comp3Page4',
title: 'ප්‍රශ්නය 04',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'පුතාට මොනවද බොන්න ඕනෙ?',
'audio': 'assets/comthree/Answer4.wav',
'image': 'assets/comthree/4.jpg'
}),
SizedBox(
height: 30,
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp3Page4', title: 'ප්‍රශ්නය 04', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'පුතාට මොනවද බොන්න ඕනෙ?', 'audio':'assets/comthree/Answer4.wav','image':'assets/comthree/4.jpg'}
ButtonXL(
route: '/Comp3Page4',
title: 'ප්‍රශ්නය 05',
bg: MyStyles.cbtnPrimary,
arguments: {
'text': 'මේ පින්තුරේ ඉන්නෙ කවුද?',
'audio': 'assets/comthree/Answer5.wav',
'image': 'assets/comthree/5.png'
}),
SizedBox(
height: 30,
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp3Page4', title: 'ප්‍රශ්නය 05', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'මේ පින්තුරේ ඉන්නෙ කවුද?', 'audio':'assets/comthree/Answer5.wav','image':'assets/comthree/5.png'}
ButtonXL(
route: '/Summary',
title: 'අවසාන ප්‍රතිඵලය',
bg: MyStyles.cbtnPrimary,
// arguments: {'text': '', 'audio': '', 'image': ''}
),
SizedBox(height: 30,),
ButtonXL(route: '/Results', title: 'අවසාන ප්‍රතිඵලය', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'', 'audio':'','image':''}
SizedBox(
height: 30,
),
SizedBox(height: 30,),
],
);
}
......
import 'dart:io';
import 'package:Autism/pages/Comp3/KeyValue.dart';
import 'package:Autism/widgets/AudioInput.dart';
import 'package:Autism/widgets/ButtonIcon.dart';
import 'package:Autism/widgets/ImageCard.dart';
......@@ -8,6 +9,7 @@ import 'package:Autism/MyStyles.dart' as MyStyles;
import 'package:Autism/Api.dart' as Api;
import 'package:dio/dio.dart';
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart';
class Comp3Page4 extends StatefulWidget {
const Comp3Page4({super.key});
......@@ -23,8 +25,44 @@ class _Comp3Page4State extends State<Comp3Page4> {
String image = '';
String audio = '';
String color = '';
bool isLoading = false;
Future sendRequest() async {
// Map<String, String> keyValueData = {};
List<KeyValue> keyValueData = [];
// void addKeyValuePair(String key, String value) {
// setState(() {
// keyValueData[key] = value;
// });
// }
void addKeyValuePair(String key, String value) {
setState(() {
keyValueData.add(KeyValue(key, value));
});
}
Future<void> saveDataToLocalStorage(String key, String value) async {
final prefs = await SharedPreferences.getInstance();
final keyValueList = prefs.getStringList('keyValueData') ?? [];
// Check if the key already exists in the list
final existingPairIndex = keyValueList.indexWhere((entry) {
final parts = entry.split(':');
return parts[0] == key;
});
if (existingPairIndex != -1) {
// If the key exists, update the value
keyValueList[existingPairIndex] = '$key:$value';
} else {
// If the key doesn't exist, add a new key-value pair
keyValueList.add('$key:$value');
}
await prefs.setStringList('keyValueData', keyValueList);
}
Future sendRequest(String t) async {
try {
Response response;
var dio = Dio();
......@@ -55,6 +93,9 @@ class _Comp3Page4State extends State<Comp3Page4> {
// filename: 'audio2.wav'
// ),
// });
setState(() {
isLoading = true;
});
response = await dio.post(
Api.Comp3Api,
......@@ -66,12 +107,15 @@ class _Comp3Page4State extends State<Comp3Page4> {
);
if (response.statusCode == 200) {
isLoading = false;
if (response.data["answer-evaluation"] == "autism") {
setState(() {
isLoading = false;
color = "රතු පාට";
});
// var color = "Red";
} else {
isLoading = false;
// color = "Green";
setState(() {
color = "කොළ පාට";
......@@ -80,7 +124,10 @@ class _Comp3Page4State extends State<Comp3Page4> {
print(response.data);
print(response.data["answer-evaluation"]);
print(color);
nextPage('/Results');
addKeyValuePair(t, response.data["answer-evaluation"]);
print(keyValueData);
saveDataToLocalStorage(t, color);
nextPage('/Comp3Results');
}
} catch (e) {
// print(e);
......@@ -98,18 +145,17 @@ class _Comp3Page4State extends State<Comp3Page4> {
image = arg['image'];
audio = arg['audio'];
return Column(
return isLoading
? Center(
child: Column(
children: [
Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.all(8.0),
child: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
},
),
CircularProgressIndicator(
semanticsLabel: "Result is generating...",
),
],
))
: Column(
children: [
ImageCard(image: image),
SizedBox(
height: 10,
......@@ -134,7 +180,7 @@ class _Comp3Page4State extends State<Comp3Page4> {
}),
recordedFile != null
? ButtonIcon(
click: () => sendRequest(),
click: () => sendRequest(text),
icon: Icons.arrow_forward_ios,
bg: MyStyles.cbtnPrimary,
)
......
import 'package:Autism/widgets/ButtonXl.dart';
import 'package:flutter/material.dart';
import 'package:Autism/MyStyles.dart' as MyStyles;
class Comp3Results extends StatefulWidget {
const Comp3Results({super.key});
@override
State<Comp3Results> createState() => _ResultsState();
}
class _ResultsState extends State<Comp3Results> {
String color = '';
@override
Widget build(BuildContext context) {
final arg = ModalRoute.of(context)!.settings.arguments as Map;
color = arg['color'];
return Column(
children: [
SizedBox(
height: 20,
),
SizedBox(
width: 300,
child: Container(
decoration: BoxDecoration(
border: Border.all(color: MyStyles.cBgHeading, width: 2),
borderRadius: BorderRadius.all(Radius.circular(15.0)),
color: MyStyles.cBgHeading,
),
child: Column(
children: [
Padding(
padding: EdgeInsets.all(25),
child: Center(
child: Text(
'ඔබගේ ප්‍රතීඵලයට අදාළ වර්ණය වන්නේ',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: MyStyles.cHeading),
)),
),
Container(
decoration: BoxDecoration(
border: Border.all(color: MyStyles.cBgHeading, width: 2),
borderRadius: BorderRadius.all(Radius.circular(15.0)),
color: color == 'රතු පාට'
? MyStyles.cbtnError
: color == 'කොළ පාට'
? MyStyles.cbtnSuccess
: MyStyles.cWhite,
),
child: Padding(
padding: EdgeInsets.all(40),
child: Center(
child: Text(
color,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18, color: MyStyles.cbtnText),
)),
),
)
],
),
),
),
SizedBox(
height:
20), // Add some spacing between the container and the text box
Text(
'⚠️ රතු ව‍ර්ණයෙන් ඔටිසම් රෝගී තත්වය සම්බන්ද කථන ආබාධයක් පැවතීමට වැඩි සම්භාවිතාවක් පැවතීමට හැකියාව ඇතිබව පෙන්නුම් කරයි. ප්‍රතිඵලය ලෙස රතු වර්ණය දිස්වුවහොත් වෛද්‍යවරයෙක් ලවා පරීක්ෂා කරවා ගැනීම සුදුසු වේ. කොළ වර්ණයෙන් රෝගී තත්වයක් නොමැති බවත් පෙන්නුම් කරයි.⚠️ යම් නිගමනයකට එලඹීමට පෙර අවම තුන්වතාවක්වත් නැවත නැවතත් ක්‍රියාකාරකමේ නියලී ලැබෙන ප්‍රතිඵලය එකම දැයි පරීක්ෂා කර බලන්න.',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: MyStyles.cautiontext,
),
),
SizedBox(
height: 50,
),
ButtonXL(
route: '/Comp3Page3',
title: 'ප්‍රශ්න පිටුවට',
bg: MyStyles.cbtnPrimary),
],
);
}
}
class KeyValue {
final String key;
final String value;
KeyValue(this.key, this.value);
}
import 'package:Autism/pages/Comp3/KeyValue.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class Summary extends StatefulWidget {
const Summary({super.key});
@override
_SummaryState createState() => _SummaryState();
}
class _SummaryState extends State<Summary> {
List<KeyValue> keyValueData = [];
@override
void initState() {
super.initState();
loadDataFromLocalStorage(); // Load data from local storage when the widget initializes
}
// Function to load the data from local storage
Future<void> loadDataFromLocalStorage() async {
final prefs = await SharedPreferences.getInstance();
final keyValueList = prefs.getStringList('keyValueData') ?? [];
setState(() {
keyValueData = keyValueList.map((entry) {
final parts = entry.split(':');
return KeyValue(parts[0], parts[1]);
}).toList();
});
}
// Function to clear local storage related to this widget
Future<void> clearLocalStorage() async {
final prefs = await SharedPreferences.getInstance();
prefs.remove('keyValueData'); // Remove the stored key-value pairs
setState(() {
keyValueData = []; // Clear the data displayed in the widget
});
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Text(
'සාරාංශය',
style: TextStyle(
fontSize: 24, // You can adjust the font size
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 40),
ListView.builder(
shrinkWrap: true,
itemCount: keyValueData.length,
itemBuilder: (context, index) {
final key = keyValueData[index].key;
final value = keyValueData[index].value;
bool isRed = value == 'රතු පාට';
bool isGreen = value == 'කොළ පාට';
return Row(
children: [
Container(
width: 220, // Set the width to your desired value
child: ListTile(
title: Text(key),
),
),
Expanded(
child: Container(
color: isRed
? Colors.red
: isGreen
? Colors.green
: null,
child: ListTile(
title: Text(value),
),
),
)
],
);
},
),
SizedBox(
height: 50,
),
ElevatedButton(
onPressed: () {
clearLocalStorage();
Navigator.pushNamed(context, '/home');
},
style: ElevatedButton.styleFrom(
primary: Colors.blue, // Background color
onPrimary: Colors.white, // Text color
),
child: Text(
'පළමු පිටුවට',
style: TextStyle(
color: Colors.white, // Text color
),
),
)
],
);
}
}
......@@ -10,7 +10,6 @@ class Results extends StatefulWidget {
}
class _ResultsState extends State<Results> {
String color = '';
@override
......@@ -20,51 +19,93 @@ class _ResultsState extends State<Results> {
return Column(
children: [
SizedBox(height: 20,),
SizedBox(
height: 20,
),
SizedBox(
width: 300,
child: Container(
decoration: BoxDecoration(
border: Border.all(color:MyStyles.cBgHeading,width: 2),
borderRadius: BorderRadius.all(Radius.circular(15.0) ),
color:MyStyles.cBgHeading,
border: Border.all(color: MyStyles.cBgHeading, width: 2),
borderRadius: BorderRadius.all(Radius.circular(15.0)),
color: MyStyles.cBgHeading,
),
child: Column(
children: [
Padding(
padding: EdgeInsets.all(25),
child: Center(
child: Text('ඔබගේ ප්‍රතීඵලයට අදාළ වර්ණය වන්නේ',textAlign: TextAlign.center,style: TextStyle(fontWeight: FontWeight.bold,fontSize: 18,color: MyStyles.cHeading),)
),
child: Text(
'ඔබගේ ප්‍රතීඵලයට අදාළ වර්ණය වන්නේ',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: MyStyles.cHeading),
)),
),
Container(
decoration: BoxDecoration(
border: Border.all(color:MyStyles.cBgHeading,width: 2),
borderRadius: BorderRadius.all(Radius.circular(15.0) ),
color:
color=='රතු පාට' ? MyStyles.cbtnError
:color=='කොළ පාට' ? MyStyles.cbtnSuccess
: MyStyles.cWhite
,
border: Border.all(color: MyStyles.cBgHeading, width: 2),
borderRadius: BorderRadius.all(Radius.circular(15.0)),
color: color == 'රතු පාට'
? MyStyles.cbtnError
: color == 'කොළ පාට'
? MyStyles.cbtnSuccess
: MyStyles.cWhite,
),
child: Padding(
padding: EdgeInsets.all(40),
child: Center(
child: Text(color,textAlign: TextAlign.center,style: TextStyle(fontSize: 18,color: MyStyles.cbtnText),)
),
child: Text(
color,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18, color: MyStyles.cbtnText),
)),
),
)
],
),
),
),
SizedBox(height: 50,),
ButtonXL(route: '/home', title: 'පළමු පිටුවට', bg: MyStyles.cbtnPrimary),
SizedBox(
height:
20), // Add some spacing between the container and the text box
Text(
'⚠️ රතු ව‍ර්ණයෙන් ඔටිසම් රෝගී තත්වය සම්බන්ද කථන ආබාධයක් පැවතීමට වැඩි සම්භාවිතාවක් පැවතීමට හැකියාව ඇතිබව පෙන්නුම් කරයි. ප්‍රතිඵලය ලෙස රතු වර්ණය දිස්වුවහොත් වෛද්‍යවරයෙක් ලවා පරීක්ෂා කරවා ගැනීම සුදුසු වේ. කොළ වර්ණයෙන් රෝගී තත්වයක් නොමැති බවත් පෙන්නුම් කරයි.',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: MyStyles.cautiontext,
),
),
SizedBox(
height:
20), // Add some spacing between the container and the text box
Text(
'⚠️ යම් නිගමනයකට එලඹීමට පෙර අවම තුන්වතාවක්වත් නැවත නැවතත් ක්‍රියාකාරකමේ නියලී ලැබෙන ප්‍රතිඵලය එකම දැයි පරීක්ෂා කර බලන්න.',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: MyStyles.cautiontext,
),
),
SizedBox(
height:
20), // Add some spacing between the container and the text box
Text(
'⚠️ වෛද්‍යවරයෙක්ගේ පරීක්ෂණයකින් තොරව මෙහි ලැබෙන ප්‍රතිඵලය මත පමණක් එලඹී නිගමනවලට එලඹීමෙන් වලකින්න.',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: MyStyles.cautiontext,
),
),
SizedBox(
height: 20,
),
ButtonXL(
route: '/home', title: 'ආරම්භක පිටුවට', bg: MyStyles.cbtnPrimary),
],
);
}
......
......@@ -93,10 +93,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev"
source: hosted
version: "1.17.1"
version: "1.17.2"
crypto:
dependency: transitive
description:
......@@ -204,18 +204,18 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.15"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "0.5.0"
meta:
dependency: transitive
description:
......@@ -344,6 +344,62 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.1"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
url: "https://pub.dev"
source: hosted
version: "2.2.2"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: "7bf53a9f2d007329ee6f3df7268fd498f8373602f943c975598bbb34649b62a7"
url: "https://pub.dev"
source: hosted
version: "2.3.4"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
sha256: d4ec5fc9ebb2f2e056c617112aa75dcf92fc2e4faaf2ae999caa297473f75d8a
url: "https://pub.dev"
source: hosted
version: "2.3.1"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
sha256: d762709c2bbe80626ecc819143013cc820fa49ca5e363620ee20a8b15a3e3daf
url: "https://pub.dev"
source: hosted
version: "2.2.1"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
sky_engine:
dependency: transitive
description: flutter
......@@ -353,10 +409,10 @@ packages:
dependency: transitive
description:
name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
stack_trace:
dependency: transitive
description:
......@@ -401,10 +457,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "0.6.0"
typed_data:
dependency: transitive
description:
......@@ -429,6 +485,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
win32:
dependency: transitive
description:
......@@ -446,5 +510,5 @@ packages:
source: hosted
version: "1.0.3"
sdks:
dart: ">=3.0.5 <4.0.0"
dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=3.7.0"
......@@ -39,6 +39,7 @@ dependencies:
audioplayers: ^4.1.0
record: ^4.4.4
path_provider: ^2.0.2
shared_preferences: ^2.0.6
dev_dependencies:
flutter_test:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment