flutter tts

merge-requests/140/head
Sultan Khan 4 years ago
parent e3e868e47c
commit a3e01ff938

@ -7,7 +7,8 @@ import 'package:diplomaticquarterapp/core/viewModels/appointment_rate_view_model
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart' as list; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'
as list;
import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart'; import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/BranchView.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/BranchView.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
@ -29,6 +30,7 @@ import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/routes.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class MyFamily extends StatefulWidget { class MyFamily extends StatefulWidget {
final bool isAppbarVisible; final bool isAppbarVisible;
MyFamily({this.isAppbarVisible = true}); MyFamily({this.isAppbarVisible = true});
@ -59,14 +61,16 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
bool expandFlag = false; bool expandFlag = false;
Widget build(BuildContext context) { Widget build(BuildContext context) {
imagesInfo.add(ImagesInfo( imagesInfo.add(
ImagesInfo(
imageEn: imageEn:
'https://hmgwebservices.com/Images/MobileApp/images-info-home/family-file/en/0.png', 'https://hmgwebservices.com/Images/MobileApp/images-info-home/family-file/en/0.png',
imageAr: imageAr:
'https://hmgwebservices.com/Images/MobileApp/images-info-home/family-file/ar/0.png'), 'https://hmgwebservices.com/Images/MobileApp/images-info-home/family-file/ar/0.png'),
); );
imagesInfo.add(ImagesInfo( imagesInfo.add(
ImagesInfo(
imageEn: imageEn:
'https://hmgwebservices.com/Images/MobileApp/images-info-home/family-file/en/1.png', 'https://hmgwebservices.com/Images/MobileApp/images-info-home/family-file/en/1.png',
imageAr: imageAr:
@ -76,7 +80,7 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
return AppScaffold( return AppScaffold(
appBarTitle: TranslationBase.of(context).myFamilyFiles, appBarTitle: TranslationBase.of(context).myFamilyFiles,
isShowAppBar: widget.isAppbarVisible, isShowAppBar: widget.isAppbarVisible,
imagesInfo: imagesInfo, // imagesInfo: imagesInfo,
description: TranslationBase.of(context).familyInfo, description: TranslationBase.of(context).familyInfo,
body: Scaffold( body: Scaffold(
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
@ -124,7 +128,6 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
EdgeInsets.only(top: 4.0, left: 35.0, right: 35.0), EdgeInsets.only(top: 4.0, left: 35.0, right: 35.0),
unselectedLabelColor: Colors.grey[800], unselectedLabelColor: Colors.grey[800],
tabs: [ tabs: [
Container( Container(
width: MediaQuery.of(context).size.width * 0.30, width: MediaQuery.of(context).size.width * 0.30,
child: Center( child: Center(
@ -148,23 +151,22 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
body: Column( body: Column(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: (user != null && projectViewModel.isLogin) ? TabBarView( child: (user != null && projectViewModel.isLogin)
? TabBarView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
controller: _tabController, controller: _tabController,
children: [ children: [
myFamilyDetails(context), myFamilyDetails(context),
myFamilyRequest(context) myFamilyRequest(context)
], ],
) : Container(child:AppText('Loading..')), )
: Container(child: AppText('Loading..')),
) )
], ],
), ),
), ),
); );
return AppScaffold( return AppScaffold(
appBarTitle: TranslationBase.of(context).myFamilyFiles, appBarTitle: TranslationBase.of(context).myFamilyFiles,
isShowAppBar: widget.isAppbarVisible, isShowAppBar: widget.isAppbarVisible,
@ -179,11 +181,13 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
controller: _tabController, controller: _tabController,
indicatorColor: Colors.red, indicatorColor: Colors.red,
tabs: [ tabs: [
Tab( // padding: EdgeInsets.all(6), Tab(
// padding: EdgeInsets.all(6),
child: AppText(TranslationBase.of(context).family)), child: AppText(TranslationBase.of(context).family)),
Tab( Tab(
// padding: EdgeInsets.all(6), // padding: EdgeInsets.all(6),
child:AppText(TranslationBase.of(context).request)), child:
AppText(TranslationBase.of(context).request)),
], ],
), ),
TabBarView( TabBarView(
@ -375,13 +379,21 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
// )), // )),
Column(children: [ Column(children: [
Padding( Padding(
padding: EdgeInsets.only(left:10, right:10), child:Row(children: [ padding: EdgeInsets.only(
Expanded(flex: 3, child: AppText('Name')), left: 10, right: 10),
Expanded(flex: 1, child: AppText('Allow')), child: Row(children: [
Expanded(flex: 1, child: AppText('Reject')), Expanded(
flex: 3, child: AppText('Name')),
Expanded(
flex: 1, child: AppText('Allow')),
Expanded(
flex: 1,
child: AppText('Reject')),
])), ])),
Column( Column(
children:familyFileProvider.allSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList children: familyFileProvider
.allSharedRecordsByStatusResponse
.getAllSharedRecordsByStatusList
.map<Widget>((result) { .map<Widget>((result) {
return Padding( return Padding(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
@ -400,7 +412,9 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
), ),
onPressed: () { onPressed: () {
acceptRemoveRequest( acceptRemoveRequest(
result.iD, 3, context); result.iD,
3,
context);
}, },
)), )),
Expanded( Expanded(
@ -412,7 +426,9 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
), ),
onPressed: () { onPressed: () {
acceptRemoveRequest( acceptRemoveRequest(
result.iD,4, context); result.iD,
4,
context);
}, },
)) ))
], ],
@ -462,13 +478,15 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
flex: 3, flex: 3,
child: child: Text(
Text(result.patientName)), result.patientName)),
Expanded( Expanded(
flex: 2, flex: 2,
child: AppText( child: AppText(
result.statusDescription, result.statusDescription,
color: result.status==3 ? Colors.green: Colors.red, color: result.status == 3
? Colors.green
: Colors.red,
)), )),
], ],
)); ));
@ -487,8 +505,8 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
children: <Widget>[ children: <Widget>[
FutureBuilder( FutureBuilder(
future: getUserViewRequest(), // async work future: getUserViewRequest(), // async work
builder: builder: (BuildContext context,
(BuildContext context, AsyncSnapshot<dynamic> snapshot) { AsyncSnapshot<dynamic> snapshot) {
switch (snapshot.connectionState) { switch (snapshot.connectionState) {
case ConnectionState.waiting: case ConnectionState.waiting:
return Padding( return Padding(
@ -527,13 +545,18 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
// )), // )),
Column(children: [ Column(children: [
Padding( Padding(
padding:EdgeInsets.only(left:10, right:10), padding:
EdgeInsets.only(left: 10, right: 10),
child: Row(children: [ child: Row(children: [
Expanded(flex: 3, child: AppText('Name')), Expanded(
Expanded(flex: 1, child: AppText('Delete')), flex: 3, child: AppText('Name')),
Expanded(
flex: 1, child: AppText('Delete')),
])), ])),
Column( Column(
children: familyFileProvider.allSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList children: familyFileProvider
.allSharedRecordsByStatusResponse
.getAllSharedRecordsByStatusList
.map<Widget>((result) { .map<Widget>((result) {
return Padding( return Padding(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
@ -541,7 +564,8 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
flex: 3, flex: 3,
child: AppText(result.patientName)), child: AppText(
result.patientName)),
Expanded( Expanded(
flex: 1, flex: 1,
child: IconButton( child: IconButton(
@ -550,8 +574,8 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
color: Colors.black, color: Colors.black,
), ),
onPressed: () { onPressed: () {
deactivateRequest(result.iD, deactivateRequest(
5, context); result.iD, 5, context);
}, },
)), )),
], ],
@ -687,21 +711,19 @@ class _MyFamily extends State<MyFamily> with TickerProviderStateMixin {
Map<String, dynamic> request = {}; Map<String, dynamic> request = {};
request["ID"] = ID; request["ID"] = ID;
request["Status"] = status; request["Status"] = status;
this.familyFileProvider.deactivateFamily(request).then((value) => { this.familyFileProvider.deactivateFamily(request).then((value) =>
GifLoaderDialogUtils.hideDialog(context), {GifLoaderDialogUtils.hideDialog(context), refreshFamily(context)});
refreshFamily(context)
});
} }
acceptRemoveRequest(ID, status, context) { acceptRemoveRequest(ID, status, context) {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
Map<String, dynamic> request = {}; Map<String, dynamic> request = {};
request["ID"] = ID; request["ID"] = ID;
request["Status"] = status; request["Status"] = status;
this.familyFileProvider.acceptRejectFamily(request).then((value) => { this.familyFileProvider.acceptRejectFamily(request).then((value) =>
GifLoaderDialogUtils.hideDialog(context), {GifLoaderDialogUtils.hideDialog(context), refreshFamily(context)});
refreshFamily(context)
});
} }
checkUserData() async { checkUserData() async {
if (await this.sharedPref.getObject(USER_PROFILE) != null) { if (await this.sharedPref.getObject(USER_PROFILE) != null) {
var data = AuthenticatedUser.fromJson( var data = AuthenticatedUser.fromJson(

@ -107,7 +107,6 @@ class _FloatingSearchButton extends State<FloatingSearchButton>
// }); // });
Future.delayed(const Duration(seconds: 2), () { Future.delayed(const Duration(seconds: 2), () {
requestPermissions(); requestPermissions();
getUserData(); getUserData();
@ -119,9 +118,8 @@ class _FloatingSearchButton extends State<FloatingSearchButton>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
projectProvider = Provider.of(context); projectProvider = Provider.of(context);
return Container(child: return Container(
isShow ? getStack() child: isShow ? getStack() : Stack(children: <Widget>[Container()]));
: Stack(children: <Widget>[Container()]));
} }
Widget getStack() { Widget getStack() {
@ -780,14 +778,14 @@ class _FloatingSearchButton extends State<FloatingSearchButton>
speak() async { speak() async {
var voice = await flutterTts.getVoices; var voice = await flutterTts.getVoices;
await flutterTts.setVoice({"name": "es-us-x-sfb-local", "locale": "es-US"});
print(voice); print(voice);
if (_currentLocaleId == 'en' && results['ReturnMessage'] != null) { if (_currentLocaleId == 'en' && results['ReturnMessage'] != null) {
await flutterTts.setVoice("en-us-x-sfg#male_1-local" ); //await flutterTts.setLanguage("en-US");
await flutterTts.setLanguage("en-US");
await flutterTts.speak(results['ReturnMessage']); await flutterTts.speak(results['ReturnMessage']);
} else if (results['ReturnMessage_Ar'] != null) { } else if (results['ReturnMessage_Ar'] != null) {
await flutterTts.setLanguage("ar-SA"); await flutterTts.setLanguage("ar-SA");
await flutterTts.setVoice("ar-xa-x-arc-local"); // await flutterTts.setVoice("ar-xa-x-arc-local");
await flutterTts.speak(results['ReturnMessage_Ar']); await flutterTts.speak(results['ReturnMessage_Ar']);
} }
// Future.delayed(const Duration(seconds: 10), () { // Future.delayed(const Duration(seconds: 10), () {
@ -815,6 +813,6 @@ class _FloatingSearchButton extends State<FloatingSearchButton>
user = AuthenticatedUser.fromJson( user = AuthenticatedUser.fromJson(
await this.sharedPref.getObject(USER_PROFILE)); await this.sharedPref.getObject(USER_PROFILE));
} }
await flutterTts.setVoice("en-us-x-sfg#male_1-local" ); //await flutterTts.setVoice("en-us-x-sfg#male_1-local");
} }
} }

Loading…
Cancel
Save