Commit 3614c36f authored by RSRGJN Ananda's avatar RSRGJN Ananda

Merge branch 'IT20012724' into 'master'

It20012724

See merge request !6
parents b6b4b9f5 cf2a9e57
This diff is collapsed.
import 'package:Autism/widgets/ButtonXl.dart';
import 'package:flutter/material.dart';
import 'package:Autism/MyStyles.dart' as MyStyles;
class Comp2Page1 extends StatefulWidget {
const Comp2Page1({super.key});
@override
State<Comp2Page1> createState() => _Comp2Page1State();
}
class _Comp2Page1State extends State<Comp2Page1> {
@override
Widget build(BuildContext context) {
void nextPage(String route) {
Navigator.pushNamedAndRemoveUntil(context, route,(r) => false, arguments: {});
}
return Column(
children: [
SizedBox(width: 180,child:
Image.asset('assets/images/Component 2 - img 01.png')
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page2', title: 'ආරම්භ කරන්න', bg: MyStyles.cbtnPrimary),
],
);
}
}
import 'dart:io';
import 'package:Autism/widgets/AudioInput.dart';
import 'package:Autism/widgets/ButtonIcon.dart';
import 'package:Autism/widgets/ImageCard.dart';
import 'package:Autism/widgets/Instructions.dart';
import 'package:flutter/material.dart';
import 'package:Autism/MyStyles.dart' as MyStyles;
import 'package:Autism/Api.dart' as Api;
import 'package:dio/dio.dart';
import 'package:flutter/services.dart';
class Comp2Page3 extends StatefulWidget {
const Comp2Page3({super.key});
@override
State<Comp2Page3> createState() => _Comp2Page3State();
}
class _Comp2Page3State extends State<Comp2Page3> {
File? recordedFile;
String text = '';
String image = '';
String audio = '';
String color = '';
Future sendRequest() async {
try {
Response response;
var dio = Dio();
ByteData assetByteData = await rootBundle.load(audio);
List<int> assetBytes = assetByteData.buffer.asUint8List();
FormData formData = FormData();
formData.files.add(
MapEntry(
'files01',
await MultipartFile.fromBytes(assetBytes, filename: 'audio1.wav'),
),
);
formData.files.add(
MapEntry(
'files02',
await MultipartFile.fromFile(recordedFile!.path,
filename: 'audio2.wav'),
),
);
// FormData formData = FormData.fromMap({
// 'audio': await MultipartFile.fromBytes(assetBytes,
// filename: 'audio1.wav'
// ),
// 'audioa': await MultipartFile.fromFile(recordedFile!.path,
// filename: 'audio2.wav'
// ),
// });
response = await dio.post(
Api.Comp2Api,
data: formData,
// onSendProgress: (int sent, int total) {
// //print((100 * sent) / total);
// print(formData.files.map((e) => print(e.value.filename)));
// },
);
if (response.statusCode == 200) {
if (response.data["pronounce-validation"] == "autism") {
setState(() {
color = "රතු පාට";
});
// var color = "Red";
} else {
// color = "Green";
setState(() {
color = "කොළ පාට";
});
}
print(response.data);
print(response.data["pronounce-validation"]);
print(color);
nextPage('/Results');
}
} catch (e) {
print(e);
}
}
void nextPage(String route) {
Navigator.pushNamed(context, route, arguments: {'color': color});
}
@override
Widget build(BuildContext context) {
final arg = ModalRoute.of(context)!.settings.arguments as Map;
text = arg['text'];
image = arg['image'];
audio = arg['audio'];
return Column(
children: [
ImageCard(image: image),
SizedBox(
height: 10,
),
Instructions(
title: 'උපදෙස්',
body: text,
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
AudioInput(
audio: 'audio',
rtn: (reco) {
setState(() {
recordedFile = reco;
});
print('recorded');
}),
recordedFile != null
? ButtonIcon(
click: () => sendRequest(),
icon: Icons.arrow_forward_ios,
bg: MyStyles.cbtnPrimary,
)
: SizedBox(),
],
)
],
);
}
}
import 'package:Autism/widgets/ButtonXl.dart';
import 'package:flutter/material.dart';
import 'package:Autism/MyStyles.dart' as MyStyles;
class Comp2Page2 extends StatefulWidget {
const Comp2Page2({super.key});
@override
State<Comp2Page2> createState() => _Comp2Page2State();
}
class _Comp2Page2State extends State<Comp2Page2> {
@override
Widget build(BuildContext context) {
void nextPage(String route) {
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: 'පින්තූරය 02', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'අක්කා කෙනෙක් ඉන්නවා', 'audio':'assets/comtwo/child05_02.wav','image':'assets/comtwo/2.jpg'}
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 03', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'මල්ලි කෙනෙක් ඉන්නවා', 'audio':'assets/comtwo/child05_03.wav','image':'assets/comtwo/3.jpg'}
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 04', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'අම්මි එක්ක ආවෙ.', 'audio':'assets/comtwo/child05_04.wav','image':'assets/comtwo/4.jpg'}
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 05', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'තාත්ති එක්ක ආවෙ.', 'audio':'assets/comtwo/child05_05.wav','image':'assets/comtwo/5.png'}
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 06', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'චොකලට් වලට කැමතියි.', 'audio':'assets/comtwo/child05_06.wav','image':'assets/comtwo/6.png'}
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp2Page3', title: 'පින්තූරය 07', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'තඩි බව්වෙක් ඉන්නවා', 'audio':'assets/comtwo/child05_07.wav','image':'assets/comtwo/7.jpg'}
),
SizedBox(height: 30,),
ButtonXL(route: '/Results', title: 'අවසාන ප්‍රතිඵලය', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'', 'audio':'','image':''}
),
SizedBox(height: 30,),
],
);
}
}
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