Commit b6b4b9f5 authored by Nagahawatta S.S's avatar Nagahawatta S.S

Merge branch 'IT20090562' into 'master'

It20090562

See merge request !5
parents 15c30659 bce3060f
This diff is collapsed.
import 'package:Autism/widgets/ButtonXl.dart';
import 'package:flutter/material.dart';
import 'package:Autism/MyStyles.dart' as MyStyles;
class Comp3Page1 extends StatefulWidget {
const Comp3Page1({super.key});
@override
State<Comp3Page1> createState() => _Comp3Page1State();
}
class _Comp3Page1State extends State<Comp3Page1> {
@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 3 - img 01.png')
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp3Page2', title: 'ආරම්භ කරන්න', bg: MyStyles.cbtnPrimary),
],
);
}
}
import 'package:Autism/widgets/ButtonXl.dart';
import 'package:Autism/widgets/Instructions.dart';
import 'package:flutter/material.dart';
import 'package:Autism/MyStyles.dart' as MyStyles;
class Comp3Page2 extends StatefulWidget {
const Comp3Page2({super.key});
@override
State<Comp3Page2> createState() => _Comp3Page2State();
}
class _Comp3Page2State extends State<Comp3Page2> {
@override
Widget build(BuildContext context) {
void nextPage(String route) {
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),
],
);
}
}
import 'package:Autism/widgets/ButtonXl.dart';
import 'package:flutter/material.dart';
import 'package:Autism/MyStyles.dart' as MyStyles;
class Comp3Page3 extends StatefulWidget {
const Comp3Page3({super.key});
@override
State<Comp3Page3> createState() => _Comp3Page3State();
}
class _Comp3Page3State extends State<Comp3Page3> {
@override
Widget build(BuildContext context) {
void nextPage(String route) {
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: 'ප්‍රශ්නය 02', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'මේ පින්තුරයේ ඇති බොලයේ පාට මොකක්ද?', 'audio':'assets/comthree/Answer2.wav','image':'assets/comthree/2.jpg'}
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp3Page4', title: 'ප්‍රශ්නය 03', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'මේ පින්තුරයේ ඇති වාහනය මොකක්ද?', 'audio':'assets/comthree/Answer3.wav','image':'assets/comthree/3.jpg'}
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp3Page4', title: 'ප්‍රශ්නය 04', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'පුතාට මොනවද බොන්න ඕනෙ?', 'audio':'assets/comthree/Answer4.wav','image':'assets/comthree/4.jpg'}
),
SizedBox(height: 30,),
ButtonXL(route: '/Comp3Page4', title: 'ප්‍රශ්නය 05', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'මේ පින්තුරේ ඉන්නෙ කවුද?', 'audio':'assets/comthree/Answer5.wav','image':'assets/comthree/5.png'}
),
SizedBox(height: 30,),
ButtonXL(route: '/Results', title: 'අවසාන ප්‍රතිඵලය', bg: MyStyles.cbtnPrimary,
arguments:{ 'text':'', 'audio':'','image':''}
),
SizedBox(height: 30,),
],
);
}
}
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 Comp3Page4 extends StatefulWidget {
const Comp3Page4({super.key});
@override
State<Comp3Page4> createState() => _Comp3Page4State();
}
class _Comp3Page4State extends State<Comp3Page4> {
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.Comp3Api,
data: formData,
// onSendProgress: (int sent, int total) {
// //print((100 * sent) / total);
// print(formData.files);
// },
);
if (response.statusCode == 200) {
if (response.data["answer-evaluation"] == "autism") {
setState(() {
color = "රතු පාට";
});
// var color = "Red";
} else {
// color = "Green";
setState(() {
color = "කොළ පාට";
});
}
print(response.data);
print(response.data["answer-evaluation"]);
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: [
Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.all(8.0),
child: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
},
),
),
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(),
],
)
],
);
}
}
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