Merge branch 'sultan' into 'development'
Sultan See merge request Cloud_Solution/doctor_app_flutter!562merge-requests/564/merge
commit
d14659d2b7
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 132 KiB |
@ -0,0 +1,25 @@
|
||||
import 'dart:async';
|
||||
|
||||
class RobotProvider {
|
||||
static final RobotProvider _singleton = RobotProvider._internal();
|
||||
var value;
|
||||
StreamController<Map> controller = StreamController<Map>.broadcast();
|
||||
|
||||
getData() {
|
||||
// return data;
|
||||
}
|
||||
intStream() {
|
||||
controller.add({});
|
||||
}
|
||||
|
||||
setValue(Map data) {
|
||||
value = data;
|
||||
controller.add(value);
|
||||
}
|
||||
|
||||
factory RobotProvider() {
|
||||
return _singleton;
|
||||
}
|
||||
|
||||
RobotProvider._internal();
|
||||
}
|
||||
@ -0,0 +1,145 @@
|
||||
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||
import 'package:doctor_app_flutter/core/provider/robot_provider.dart';
|
||||
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
|
||||
class SpeechToText {
|
||||
final BuildContext context;
|
||||
static var dialog;
|
||||
SpeechToText({
|
||||
@required this.context,
|
||||
});
|
||||
|
||||
showAlertDialog(BuildContext context) {
|
||||
//AlertDialog alert = AlertDialog
|
||||
// AlertDialog alert = AlertDialog(content: MyStatefulBuilder(dispose: () {
|
||||
// print('dispose!!!!!!!!!!!!');
|
||||
// })
|
||||
// isClosed = true;
|
||||
// streamSubscription.cancel();
|
||||
// }, builder: (BuildContext context, StateSetter setState) {
|
||||
// //print(streamSubscription);
|
||||
// }),
|
||||
// );
|
||||
|
||||
// show the dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
dialog = context;
|
||||
return MyStatefulBuilder(
|
||||
dispose: () {},
|
||||
);
|
||||
},
|
||||
);
|
||||
print(dialog);
|
||||
}
|
||||
|
||||
static closeAlertDialog(BuildContext context) {
|
||||
Navigator.of(dialog).pop();
|
||||
}
|
||||
}
|
||||
|
||||
typedef Disposer = void Function();
|
||||
|
||||
class MyStatefulBuilder extends StatefulWidget {
|
||||
const MyStatefulBuilder({
|
||||
// @required this.builder,
|
||||
@required this.dispose,
|
||||
});
|
||||
|
||||
//final StatefulWidgetBuilder builder;
|
||||
final Disposer dispose;
|
||||
|
||||
@override
|
||||
_MyStatefulBuilderState createState() => _MyStatefulBuilderState();
|
||||
}
|
||||
|
||||
class _MyStatefulBuilderState extends State<MyStatefulBuilder> {
|
||||
var event = RobotProvider();
|
||||
var searchText;
|
||||
static StreamSubscription<dynamic> streamSubscription;
|
||||
static var isClosed = false;
|
||||
@override
|
||||
void initState() {
|
||||
streamSubscription = event.controller.stream.listen((p) {
|
||||
if ((p['searchText'] != 'null' &&
|
||||
p['searchText'] != null &&
|
||||
p['searchText'] != "" &&
|
||||
isClosed == false) &&
|
||||
mounted) {
|
||||
setState(() {
|
||||
searchText = p['searchText'];
|
||||
});
|
||||
}
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => AlertDialog(
|
||||
content: Container(
|
||||
color: Colors.white,
|
||||
height: SizeConfig.realScreenHeight * 0.5,
|
||||
width: SizeConfig.realScreenWidth * 0.8,
|
||||
child: Container(
|
||||
child: Column(children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
'assets/images/habib-logo.png',
|
||||
height: 75,
|
||||
width: 75,
|
||||
))),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Center(
|
||||
child: Container(
|
||||
margin: EdgeInsets.all(20),
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
border: Border.all(width: 2, color: Colors.red)),
|
||||
child: Icon(
|
||||
Icons.mic,
|
||||
color: Colors.blue,
|
||||
size: 48,
|
||||
),
|
||||
))),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
'assets/images/soundWaveAnimation.gif',
|
||||
height: 75,
|
||||
))),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Center(
|
||||
child: AppText(searchText != null && searchText != 'null'
|
||||
? searchText
|
||||
: TranslationBase.of(context).trySaying))),
|
||||
searchText == 'null'
|
||||
? Center(
|
||||
child: RaisedButton(
|
||||
child: AppText('Retry'),
|
||||
onPressed: () {
|
||||
SpeechToText.closeAlertDialog(context);
|
||||
event.setValue({'startPopUp': 'true'});
|
||||
},
|
||||
))
|
||||
: SizedBox()
|
||||
]),
|
||||
)));
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
widget.dispose();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue