123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- import 'dart:convert';
- import 'package:flutter/material.dart';
- import 'package:flutter/widgets.dart';
- import 'package:get_it/get_it.dart';
- import 'package:sprintf/sprintf.dart';
- import 'package:http/http.dart' as http;
- import 'Services/ConsultationService.dart';
- class ConsultationList extends StatefulWidget {
- ConsultationList({Key? key, required this.token, required this.consultations})
- : super();
- final String token;
- final List<Consultation> consultations;
- @override
- _ConsultationListState createState() => _ConsultationListState();
- }
- class _ConsultationListState extends State<ConsultationList> {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Container(
- height: 600,
- child: Row(
- children: [
- Container(
- height: 500,
- width: 400,
- child: ListView(
- restorationId: 'list_demo_list_view',
- padding: const EdgeInsets.symmetric(vertical: 0),
- children: [
- for (int index = 0;
- index < widget.consultations.length;
- index++)
- Row(
- children: [
- Expanded(
- child: Container(
- child: ListTile(
- leading: ExcludeSemantics(
- child: Icon(Icons.person),
- ),
- title: Text(widget.consultations[index].id +
- " - " +
- widget.consultations[index].expertName),
- subtitle:
- Text(widget.consultations[index].patientName),
- onTap: (() =>
- onTabPatient(widget.consultations[index].id)),
- ),
- )),
- Container(
- alignment: Alignment.topRight,
- child: Container(
- child: Column(
- children: [
- ClipRRect(
- borderRadius: BorderRadius.circular(2),
- child: Container(
- color: Colors.amber[50],
- child: Row(children: [
- Icon(
- Icons.star,
- color: Colors.amber[500],
- size: 12,
- ),
- Text(
- "5.0",
- style: TextStyle(
- color: Colors.amber[900],
- fontSize: 9),
- ),
- ]))),
- Container(
- child: TextButton(
- child: Text("Start"),
- onPressed: (() =>
- OnStartLiveConsultation(widget
- .consultations[index].id))))
- ],
- ),
- )),
- Container(
- alignment: Alignment.topRight,
- child: Container(
- child: Column(
- children: [
- ClipRRect(
- borderRadius: BorderRadius.circular(2),
- child: Container(
- color: Colors.amber[50],
- child: Row(children: [
- Icon(
- Icons.phone_callback,
- color: Colors.amber[500],
- size: 12,
- ),
- ]))),
- Container(
- child: TextButton(
- child: Text("Accept"),
- onPressed: (() =>
- OnAcceptLiveConsultation(widget
- .consultations[index].id))))
- ],
- ),
- )),
- Container(
- alignment: Alignment.topRight,
- child: Container(
- child: Column(
- children: [
- ClipRRect(
- borderRadius: BorderRadius.circular(2),
- child: Container(
- color: Colors.amber[50],
- child: Row(children: [
- Icon(
- Icons.phone_callback_outlined,
- color:
- Color.fromARGB(255, 255, 0, 0),
- size: 12,
- ),
- ]))),
- Container(
- child: TextButton(
- child: Text("Reject"),
- onPressed: (() =>
- OnRejectLiveConsultation(widget
- .consultations[index].id))))
- ],
- ),
- )),
- ],
- ),
- ],
- ),
- ),
- ],
- ),
- ));
- }
- void onTabPatient(String id) async {}
- void OnStartLiveConsultation(id) async {
- try {
- var service = GetIt.instance.get<ConsultationService>();
- var result = await service.InitiateLiveConsultationAsync(id);
- print("InitiateLiveConsultationAsync");
- } catch (ex) {
- print('OnStartLiveConsultation.to ex' + ex.toString());
- }
- }
- void OnAcceptLiveConsultation(id) async {
- try {
- var service = GetIt.instance.get<ConsultationService>();
- var result = await service.AcceptLiveConsultationAsync(id);
- print("AcceptLiveConsultationAsync");
- } catch (ex) {
- print('OnAcceptLiveConsultation.to ex' + ex.toString());
- }
- }
- void OnRejectLiveConsultation(id) async {
- try {
- var service = GetIt.instance.get<ConsultationService>();
- var result = await service.RejectLiveConsultationAsync(id);
- print("RejectLiveConsultationAsync");
- } catch (ex) {
- print('OnRejectLiveConsultation.to ex' + ex.toString());
- }
- }
- }
- class Consultation {
- final String id;
- final String patientName;
- final String expertName;
- Consultation(
- {required this.id, required this.patientName, required this.expertName});
- factory Consultation.fromJson(Map<String, dynamic> json) {
- var item = Consultation(
- id: json['ConsultationCode'] as String,
- patientName: json['PatientName'] as String,
- expertName: json['ExpertUserName'] as String);
- return item;
- }
- Map<String, dynamic> toMap() {
- return {
- 'ConsultationCode': id,
- 'PatientName': patientName,
- 'ExpertUserName': expertName,
- };
- }
- @override
- String toString() {
- return 'Patient{id: $id}';
- }
- }
|