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

@ -107,7 +107,6 @@ class _FloatingSearchButton extends State<FloatingSearchButton>
// });
Future.delayed(const Duration(seconds: 2), () {
requestPermissions();
getUserData();
@ -119,9 +118,8 @@ class _FloatingSearchButton extends State<FloatingSearchButton>
@override
Widget build(BuildContext context) {
projectProvider = Provider.of(context);
return Container(child:
isShow ? getStack()
: Stack(children: <Widget>[Container()]));
return Container(
child: isShow ? getStack() : Stack(children: <Widget>[Container()]));
}
Widget getStack() {
@ -151,7 +149,7 @@ class _FloatingSearchButton extends State<FloatingSearchButton>
onTap: () {
setState(() {
if (this.mounted) {
isShow =false;
isShow = false;
}
});
},
@ -780,14 +778,14 @@ class _FloatingSearchButton extends State<FloatingSearchButton>
speak() async {
var voice = await flutterTts.getVoices;
await flutterTts.setVoice({"name": "es-us-x-sfb-local", "locale": "es-US"});
print(voice);
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']);
} else if (results['ReturnMessage_Ar'] != null) {
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']);
}
// Future.delayed(const Duration(seconds: 10), () {
@ -815,6 +813,6 @@ class _FloatingSearchButton extends State<FloatingSearchButton>
user = AuthenticatedUser.fromJson(
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