livecare changes
parent
66d12f8fdd
commit
5d0a7a4045
@ -0,0 +1,42 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AlternativeService {
|
||||||
|
int serviceID;
|
||||||
|
String serviceName;
|
||||||
|
bool isSelected;
|
||||||
|
|
||||||
|
AlternativeService(
|
||||||
|
{this.serviceID, this.serviceName, this.isSelected = false});
|
||||||
|
|
||||||
|
AlternativeService.fromJson(Map<String, dynamic> json) {
|
||||||
|
serviceID = json['ServicID'];
|
||||||
|
serviceName = json['ServiceName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['ServicID'] = this.serviceID;
|
||||||
|
data['ServiceName'] = this.serviceName;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AlternativeServicesList with ChangeNotifier {
|
||||||
|
List<AlternativeService> _alternativeServicesList;
|
||||||
|
|
||||||
|
getServicesList(){
|
||||||
|
return _alternativeServicesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
setServicesList(List<AlternativeService> alternativeServicesList) {
|
||||||
|
this._alternativeServicesList = alternativeServicesList;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelected(AlternativeService service, bool isSelected) {
|
||||||
|
List<AlternativeService> alternativeService = _alternativeServicesList.where((element) => service.serviceID == element.serviceID).toList();
|
||||||
|
|
||||||
|
alternativeService[0].isSelected = isSelected;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,136 @@
|
|||||||
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||||
|
import 'package:doctor_app_flutter/core/model/live_care/AlternativeServicesList.dart';
|
||||||
|
import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart';
|
||||||
|
import 'package:doctor_app_flutter/screens/base/base_view.dart';
|
||||||
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class TestScreen extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_TestScreenState createState() => _TestScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TestScreenState extends State<TestScreen> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BaseView<LiveCarePatientViewModel>(
|
||||||
|
onModelReady: (model) => model.setDemoData(),
|
||||||
|
builder: (_, model, w) => AppScaffold(
|
||||||
|
baseViewModel: model,
|
||||||
|
appBarTitle: TranslationBase.of(context).patientProfile,
|
||||||
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
isShowAppBar: false,
|
||||||
|
body: Container(
|
||||||
|
child: Center(
|
||||||
|
child: AppButton(
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: Colors.red[600],
|
||||||
|
title: "open dialog", //TranslationBase.of(context).close,
|
||||||
|
onPressed: () {
|
||||||
|
showAlternativesDialog(context, model, () {
|
||||||
|
model.alternativeServicesList.map((e) => () {
|
||||||
|
if (e.isSelected) {
|
||||||
|
print(e.serviceName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
showAlternativesDialog(BuildContext context, LiveCarePatientViewModel model, Function okFunction) {
|
||||||
|
return showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false, // user must tap button!
|
||||||
|
builder: (_) {
|
||||||
|
return Container(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
AlertDialog(
|
||||||
|
title: null,
|
||||||
|
content: Container(
|
||||||
|
height: MediaQuery.of(context).size.height / 2,
|
||||||
|
child: CheckBoxListWidget(model: model,),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
AppButton(
|
||||||
|
onPressed: (){
|
||||||
|
okFunction();
|
||||||
|
},
|
||||||
|
title: TranslationBase.of(context).noteConfirm,
|
||||||
|
fontColor: Colors.white,
|
||||||
|
color: Colors.green[600],
|
||||||
|
),
|
||||||
|
AppButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
title: TranslationBase.of(context).cancel,
|
||||||
|
fontColor: Colors.white,
|
||||||
|
color: Colors.red[600],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CheckBoxListWidget extends StatefulWidget {
|
||||||
|
final LiveCarePatientViewModel model;
|
||||||
|
const CheckBoxListWidget({
|
||||||
|
Key key, this.model,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CheckBoxListState createState() => _CheckBoxListState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CheckBoxListState extends State<CheckBoxListWidget> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
...widget.model
|
||||||
|
.alternativeServicesList
|
||||||
|
.map(
|
||||||
|
(element) => Container(
|
||||||
|
child: CheckboxListTile(
|
||||||
|
title: AppText(
|
||||||
|
element.serviceName,
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
|
fontSize: SizeConfig.textMultiplier * 2.2,
|
||||||
|
),
|
||||||
|
value: element.isSelected,
|
||||||
|
onChanged: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
widget.model.setSelected(
|
||||||
|
element, newValue);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
activeColor: Color(0xFFD02127),
|
||||||
|
controlAffinity:
|
||||||
|
ListTileControlAffinity.leading,
|
||||||
|
contentPadding: EdgeInsets.all(0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue