first commit

This commit is contained in:
Sas Andy
2025-02-04 19:39:14 +07:00
commit 541d84755c
179 changed files with 9390 additions and 0 deletions

View File

@@ -0,0 +1,706 @@
import 'dart:async';
import 'dart:convert';
import 'dart:developer';
import 'dart:html';
import 'package:audioplayers/audioplayers.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_image_slideshow/flutter_image_slideshow.dart';
import 'package:intl/intl.dart';
import 'package:queuedisplay/model/branch_model.dart';
import 'package:queuedisplay/model/display_counter_dedicated_modelv2.dart';
import 'package:queuedisplay/model/service_model.dart';
import 'package:queuedisplay/provider/all_service_provider.dart';
import 'package:queuedisplay/screen/with_media_promo.dart';
import 'package:queuedisplay/widget/my_counter_customer_service_dedicated.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:socket_io_client/socket_io_client.dart' as IO;
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:flutter/material.dart';
import 'package:text_scroll/text_scroll.dart';
import '../app/constant.dart';
import '../app/route.dart';
import '../model/layanan_dokter.dart';
import '../provider/display_counter_dedicated_provider.dart';
import '../widget/clock.dart';
import '../widget/my_antrian_customer_service_dedicated.dart';
import '../widget/my_error_dialog.dart';
import 'no_media_promo.dart';
class CustomerServiceDedicatedV2 extends StatefulHookConsumerWidget {
const CustomerServiceDedicatedV2({super.key});
@override
ConsumerState<ConsumerStatefulWidget> createState() =>
_CustomerServiceDedicatedV2State();
}
class _CustomerServiceDedicatedV2State
extends ConsumerState<CustomerServiceDedicatedV2> {
late IO.Socket socket;
late String typeJson = "";
@override
void initState() {
initSocket();
super.initState();
}
initSocket() {
socket = IO.io('https://${Constant.baseSocket}:9099', <String, dynamic>{
'autoConnect': false,
'transports': ['websocket'],
});
socket.connect();
socket.onConnect((_) {
print('Connection established');
});
socket.onDisconnect((_) => print('Connection Disconnection'));
socket.onConnectError((err) => print(err));
socket.onError((err) => print(err));
}
@override
void dispose() {
socket.disconnect();
socket.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final isLoading = useState(false);
final errorMessage = useState("");
final ListErrorMessage = useState<List<String>>(List.empty());
final listService =
useState<List<DisplayCounterDedicatedModelV2>>(List.empty());
final listBelumDilayani = useState<List<NotServed>>(List.empty());
final listSedangDilayani = useState<List<Served>>(List.empty());
final listCall = useState<List<Call>>(List.empty());
final selectedBranch = useState(BranchModel(mBranchID: '0'));
final judul = useState("");
final dataLayanan = useState<List<int>>(List.empty());
final lastTimeCall =
useState<DateTime>(DateTime.now().subtract(Duration(minutes: 1)));
final locationIDCall = useState(0);
final serviceIDArr = useState<List>(List.empty());
final serviceIDArrSuara = useState<List>(List.empty());
final selectedCounter = useState<List<Layanan>>(List.empty());
final scrlCnt = useScrollController();
final activeSoundDoctor = useState<List<int>>(List.empty());
final activeSoundCounter = useState<List<int>>(List.empty());
final activeSoundSamplingLocation = useState<List<int>>(List.empty());
final listNotification = useState<List<String>>(List.empty());
final serviceIDCounterArr = useState<List<int>>(List.empty());
final notifState = useState<Map<String, DateTime>>({});
// media promo
final tanpaMediaPromo = useState(false);
void goFullScreen() {
document.documentElement?.requestFullscreen();
}
// mp3
wordToMp3(int number) {
var result = "";
print("number = $number");
int ribu = (number / 1000).floor();
// print("ribu = $ribu");
if (ribu > 0) {
if (ribu == 1) {
result += "seribu" + '${number % 1000 == 0 ? "" : ","}';
} else {
result += "$ribu,ribu" + '${number % 1000 == 0 ? "" : ","}';
}
}
int cur = number - ribu * 1000;
int ratus = (cur / 100).floor();
// print("ratus = $ratus");
if (ratus > 0) {
if (ratus == 1) {
result += "100";
} else {
result += "$ratus,ratus";
}
}
cur = cur - ratus * 100;
int puluh = (cur / 10).floor();
// print("puluh = $puluh");
if (puluh > 0) {
if (result != "") result += ",";
if (puluh == 1) {
if (cur - 10 == 1) {
result += "11";
return result;
}
// else if(cur - 10 == 0){
// result += "10";
// return result;
// }
else {
int hasil = cur - 10;
if (hasil == 0) {
result += "10";
} else {
result += "$hasil,belas";
}
}
} else {
result += "$puluh,puluh";
}
}
cur = cur - (puluh * 10);
// print("akhir = $cur");
if (cur > 0) {
if (puluh == 1) {
result += "";
} else {
if (result != "") result += ",";
result += "$cur";
}
}
return result;
}
void downloadMp3(String param) async {
try {
var url = "http://${Constant.baseSocket}/audio/?prm=$param";
final player = AudioPlayer();
player.setSource(UrlSource(url));
print(url);
player.resume();
} catch (e) {
print(e);
}
}
process_sound(String number, String Counter) {
String antrian = number.replaceAll(RegExp(r'[^0-9]'), '');
String code = number.replaceAll(RegExp(r'[^A-Z]'), '');
var splitedCode = code.split("");
String joinCode = splitedCode.join(",");
String counterNum = Counter.replaceAll(RegExp(r'[^0-9]'), '');
String counterCode = Counter.replaceAll(RegExp(r'[^A-Z]'), '');
var splitedCodeCounter = counterCode.split("");
String joinCodeCounter = splitedCodeCounter.join(",");
if (antrian.isNotEmpty && counterNum.isNotEmpty) {
String param = "antrian,$joinCode," +
"${wordToMp3(int.parse(antrian))}," +
"counter,$joinCodeCounter," +
wordToMp3(int.parse(counterNum));
downloadMp3(param);
}
}
process_sound_sampling(String number, String Counter) {
try {
String antrian = number.replaceAll(RegExp(r'[^0-9]'), '');
String code = number.replaceAll(RegExp(r'[^A-Z]'), '');
var splitedCode = code.split("");
String joinCode = splitedCode.join(",");
String counterNum = Counter.replaceAll(RegExp(r'[^0-9]'), '');
String counterCode = Counter.replaceAll(RegExp(r'[^A-Z]'), '');
var splitedCodeCounter = counterCode.split("");
String joinCodeCounter = splitedCodeCounter.join(",");
String param = "antrian,$joinCode," +
"${wordToMp3(int.parse(antrian))},ruangan,r$Counter";
print(param);
downloadMp3(param);
// }
} catch (e) {
print(e);
}
}
process_sound_doctor(String number, String Counter, String serviceID) {
try {
String antrian = number.replaceAll(RegExp(r'[^0-9]'), '');
String code = number.replaceAll(RegExp(r'[^A-Z]'), '');
var splitedCode = code.split("");
String joinCode = splitedCode.join(",");
var allLayanan = ref.read(allServiceDoctorProvider.notifier).state;
LayananDokter lyn = allLayanan.firstWhere(
(element) => element.id == int.parse(serviceID.toString()));
if (antrian.isNotEmpty && lyn.doctorName != '') {
String service = lyn.doctorName;
String processService = service
.replaceAll('.', '')
.replaceAll(' ', '_')
.replaceAll(',', '')
.toLowerCase();
String param = "antrian,$joinCode," +
"${wordToMp3(int.parse(antrian))}," +
processService;
downloadMp3(param);
}
} catch (e) {
print(e);
}
}
// mp3
// socket.off("notification", (data) {});
socket.on('notification', (data) {
String pesan = data['type'];
if (notifState.value.containsKey(pesan)) {
var lasDate = notifState.value[pesan];
if (DateTime.now()
.subtract(const Duration(seconds: 10))
.isBefore(lasDate!)) {
return;
}
var notifNew = notifState.value;
notifNew[pesan] = DateTime.now();
notifState.value = notifNew;
} else {
var notifNew = notifState.value;
notifNew[pesan] = DateTime.now();
notifState.value = notifNew;
}
print(data);
// typeJsonSocketIO.value = data['type'];
var splited_pesan = pesan.split(".");
// var splited_pesan = pesan.split(".");
// print(splited_pesan);
if (splited_pesan[0] == 'call') {
var xList = listNotification.value.toList();
List<String> msgList = xList;
if (splited_pesan[1] == 'fo') {
var serviceValidation = serviceIDArr.value.where((element) =>
int.parse(element.toString()) ==
int.parse(splited_pesan[2].toString()));
var counterValidation = dataLayanan.value.where((element) =>
int.parse(element.toString()) ==
int.parse(splited_pesan[5].toString()));
locationIDCall.value = int.parse(splited_pesan[2]);
if (serviceValidation.isNotEmpty && counterValidation.isNotEmpty) {
ref.read(displayProvider.notifier).listDisplayByCounterID(
dataLayanan.value, selectedBranch.value.mBranchID ?? "0");
}
}
if (xList.isEmpty) {
// if (activeSoundDoctor.value.isNotEmpty && splited_pesan[1] == 'kd') {
// var validation =
// activeSoundDoctor.value.contains(int.parse(splited_pesan[2]));
// if (validation) {
// msgList.add(pesan);
// }
// }
if (activeSoundCounter.value.isNotEmpty &&
splited_pesan[1] == 'fo' &&
splited_pesan[6] == selectedBranch.value.mBranchID) {
var serviceValidation = serviceIDArrSuara.value.where((element) =>
int.parse(element.toString()) ==
int.parse(splited_pesan[2].toString()));
var counterValidation = activeSoundCounter.value.where((element) =>
int.parse(element.toString()) ==
int.parse(splited_pesan[5].toString()));
locationIDCall.value = int.parse(splited_pesan[2]);
if (serviceValidation.isNotEmpty && counterValidation.isNotEmpty) {
msgList.add(pesan);
}
}
// if (activeSoundSamplingLocation.value.isNotEmpty &&
// splited_pesan[1] == 'sm') {
// var validation = activeSoundSamplingLocation.value
// .contains(int.parse(splited_pesan[2]));
// if (validation) {
// msgList.add(pesan);
// }
// }
}
// else {
// if (activeSoundDoctor.value.isNotEmpty && splited_pesan[1] == 'kd') {
// var validation =
// activeSoundDoctor.value.contains(int.parse(splited_pesan[2]));
// var msgValidation = msgList.contains(pesan.toString());
// if (validation && !msgValidation) {
// msgList.add(pesan);
// }
// }
// if (activeSoundCounter.value.isNotEmpty && splited_pesan[1] == 'fo') {
// var validation =
// activeSoundCounter.value.contains(int.parse(splited_pesan[5]));
// var counterValidation =
// serviceIDCounterArr.value.contains(int.parse(splited_pesan[2]));
// var msgValidation = msgList.contains(pesan.toString());
// if (validation && !msgValidation && counterValidation) {
// msgList.add(pesan);
// }
// }
// if (activeSoundSamplingLocation.value.isNotEmpty &&
// splited_pesan[1] == 'sm') {
// var validation = activeSoundSamplingLocation.value
// .contains(int.parse(splited_pesan[2]));
// var msgValidation = msgList.contains(pesan.toString());
// if (validation && !msgValidation) {
// msgList.add(pesan);
// }
// }
// }
listNotification.value = msgList;
print('List Notification : ${listNotification.value}');
} else if (splited_pesan[0] == 'skip') {
if (splited_pesan[1] == 'fo' &&
splited_pesan[4] == selectedBranch.value.mBranchID) {
var serviceValidation = serviceIDArr.value.where((element) =>
int.parse(element.toString()) ==
int.parse(splited_pesan[2].toString()));
var counterValidation = dataLayanan.value.where((element) =>
int.parse(element.toString()) ==
int.parse(splited_pesan[3].toString()));
if (serviceValidation.isNotEmpty && counterValidation.isNotEmpty) {
ref.read(displayProvider.notifier).listDisplayByCounterID(
dataLayanan.value, selectedBranch.value.mBranchID ?? "0");
}
}
} else if (splited_pesan[0] == 'serve') {
if (splited_pesan[1] == 'fo' &&
splited_pesan[4] == selectedBranch.value.mBranchID) {
var serviceValidation = serviceIDArr.value.where((element) =>
int.parse(element.toString()) ==
int.parse(splited_pesan[2].toString()));
var counterValidation = dataLayanan.value.where((element) =>
int.parse(element.toString()) ==
int.parse(splited_pesan[3].toString()));
if (serviceValidation.isNotEmpty && counterValidation.isNotEmpty) {
ref.read(displayProvider.notifier).listDisplayByCounterID(
dataLayanan.value, selectedBranch.value.mBranchID ?? "0");
}
}
} else if (splited_pesan[0] == 'done') {
if (splited_pesan[1] == 'fo' &&
splited_pesan[4] == selectedBranch.value.mBranchID) {
var serviceValidation = serviceIDArr.value.where((element) =>
int.parse(element.toString()) ==
int.parse(splited_pesan[2].toString()));
var counterValidation = dataLayanan.value.where((element) =>
int.parse(element.toString()) ==
int.parse(splited_pesan[3].toString()));
if (serviceValidation.isNotEmpty && counterValidation.isNotEmpty) {
ref.read(displayProvider.notifier).listDisplayByCounterID(
dataLayanan.value, selectedBranch.value.mBranchID ?? "0");
}
}
} else if (splited_pesan[0] == "printed") {
if (splited_pesan[1] == 'fo') {
var serviceValidation = serviceIDArr.value.where((element) =>
int.parse(element.toString()) ==
int.parse(splited_pesan[2].toString()));
if (serviceValidation.isNotEmpty &&
splited_pesan[3] == selectedBranch.value.mBranchID) {
ref.read(displayProvider.notifier).listDisplayByCounterID(
dataLayanan.value, selectedBranch.value.mBranchID ?? "0");
}
}
}
});
void autoScroll() {
if (scrlCnt.hasClients) {
if (scrlCnt.offset == 0) {
scrlCnt.animateTo(scrlCnt.position.maxScrollExtent,
duration: Duration(milliseconds: 100), curve: Curves.linear);
} else {
scrlCnt.animateTo(scrlCnt.position.minScrollExtent,
duration: Duration(milliseconds: 100), curve: Curves.linear);
}
}
}
Timer? tmr2;
Timer? tmr;
useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
goFullScreen();
tmr = Timer.periodic(Duration(seconds: 5), (timer) {
autoScroll();
});
final prefs = await SharedPreferences.getInstance();
var rawData = prefs.getString('counter_dedicated') ?? 'a';
if (rawData != 'a') {
print(rawData);
var data = json.decode(rawData);
judul.value = data['judul'];
serviceIDArr.value = data['serviceID'];
// suara
serviceIDArrSuara.value = data['serviceIDSuara'];
// klu di check(true) maka tanpa media promo
tanpaMediaPromo.value = data['tanpaMediaPromo'];
//Selected branch
selectedBranch.value = BranchModel.fromJson(data['selectedBranch']);
List<int> listServiceID = List.empty(growable: true);
for (var x in data['activeLayanan']) {
listServiceID.add(int.parse(x.toString()));
}
dataLayanan.value = listServiceID;
List<int> listSoundDoctorID = List.empty(growable: true);
for (var x in data['activeSoundDoctor']) {
listSoundDoctorID.add(int.parse(x.toString()));
}
activeSoundDoctor.value = listSoundDoctorID;
List<int> listSoundSamplingID = List.empty(growable: true);
for (var x in data['activeSoundSamplingLocation']) {
listSoundSamplingID.add(int.parse(x.toString()));
}
activeSoundSamplingLocation.value = listSoundSamplingID;
List<int> listsoundCounter = List.empty(growable: true);
for (var x in data['activeSoundCounter']) {
listsoundCounter.add(int.parse(x.toString()));
}
activeSoundCounter.value = listsoundCounter;
List<int> listServiceCounterIDarr = List.empty(growable: true);
for (var x in data['serviceIDSuara']) {
listServiceCounterIDarr.add(int.parse(x.toString()));
}
serviceIDCounterArr.value = listServiceCounterIDarr;
var listCounter = ref.read(allServiceProvider.notifier).state;
List<Layanan> sc = List.empty(growable: true);
for (var i = 0; i < listCounter.length; i++) {
for (var j = 0; j < listServiceID.length; j++) {
if (int.parse(listCounter[i].counterID.toString()) ==
listServiceID[j]) {
sc.add(listCounter[i]);
}
}
}
selectedCounter.value = sc;
tmr2 = Timer.periodic(Duration(seconds: 10), (timer) {
if (listNotification.value.isNotEmpty) {
String pesan = listNotification.value[0];
print('Proses Sound : $pesan ');
var notif = listNotification.value.toList();
var splited_pesan = pesan.split(".");
if (splited_pesan[1] == 'kd') {
var serviceID = splited_pesan[2];
process_sound_doctor(
splited_pesan[3], splited_pesan[4], serviceID);
}
if (splited_pesan[1] == 'fo') {
process_sound(splited_pesan[3], splited_pesan[4]);
}
if (splited_pesan[1] == 'sm') {
print('masuk sampling');
process_sound_sampling(splited_pesan[3], splited_pesan[5]);
}
notif.removeAt(0);
listNotification.value = notif;
}
});
ref.read(displayProvider.notifier).listDisplayByCounterID(
listServiceID, selectedBranch.value.mBranchID ?? "0");
} else {
Navigator.of(context)
.pushNamedAndRemoveUntil(settingRoute, (route) => false);
return;
}
});
return () {
tmr!.cancel();
tmr2!.cancel();
};
}, []);
showDialogError(BuildContext context, String msg) {
var lstMsg = ListErrorMessage.value;
var validation = false;
for (var i = 0; i < lstMsg.length; i++) {
if (lstMsg[i] == msg) {
validation = true;
} else {
validation = false;
var newMsg = [...ListErrorMessage.value];
newMsg.add(msg);
ListErrorMessage.value = newMsg;
}
}
if (lstMsg.length == 0) {
validation = false;
List<String> newMsg = List.empty(growable: true);
newMsg.add(msg.toString());
ListErrorMessage.value = newMsg;
}
if (!validation) {
// print("modal cek ");
// print(_isThereCurrentDialogShowing(BuildContext context) =>
// ModalRoute.of(context)?.isCurrent != true);
var joinMsg = ListErrorMessage.value.join(",");
myErrorDialog(context, joinMsg, 'ERROR');
}
}
Timer? timer;
ref.listen(displayProvider, (prev, next) {
if (next is DisplayCounterDedicatedStateLoading) {
isLoading.value = true;
} else if (next is DisplayCounterDedicatedStateError) {
isLoading.value = false;
//kalau error msg connection mengaktifkan blink error
//update error counter
//if error counter lebih dari sama dengan 3 retry
// kalau done erro msg blink di nonaktifkan error counter di nolkan
if (errorMessage.value != next.message) {
myErrorDialog(context, next.message, 'ERROR');
}
errorMessage.value = next.message;
// showDialogError(context, next.message);
// print("error" + next.message);
Timer(const Duration(seconds: 3), () {
errorMessage.value = "";
});
} else if (next is DisplayCounterDedicatedStateDone) {
isLoading.value = false;
listService.value = next.model;
next.model.forEach((element) {
listBelumDilayani.value = element.notServed;
listSedangDilayani.value = element.served;
listCall.value = element.call;
});
// print(jsonEncode(listBelumDilayani.value));
}
});
getNomorAntrian(String counterID) {
var rawCall = listCall.value;
// print(rawCall);
Call call = Call(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawCall.length; i++) {
if (rawCall[i].queueCounterID == counterID) {
call = rawCall[i];
}
}
var rawProcess = listSedangDilayani.value;
Served process = Served(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawProcess.length; i++) {
if (rawProcess[i].queueCounterID == counterID) {
process = rawProcess[i];
}
}
if (call.queueID != '0' && process.queueID == '0') {
return call.queueNumber;
} else if (call.queueID == '0' && process.queueID != '0') {
return process.queueNumber;
} else if (call.queueID == '0' && process.queueID == '0') {
return '-';
} else {
return call.queueNumber;
}
}
getBlinkAntrian(String counterID) {
var rawCall = listCall.value;
// print(rawCall);
Call call = Call(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawCall.length; i++) {
if (rawCall[i].queueCounterID == counterID) {
call = rawCall[i];
}
}
var rawProcess = listSedangDilayani.value;
Served process = Served(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawProcess.length; i++) {
if (rawProcess[i].queueCounterID == counterID) {
process = rawProcess[i];
}
}
if (call.queueID != '0' && process.queueID == '0') {
return true;
} else if (call.queueID == '0' && process.queueID != '0') {
return false;
} else if (call.queueID == '0' && process.queueID == '0') {
return false;
} else {
return true;
}
}
if (tanpaMediaPromo.value == true) {
return DisplayTanpaPromo(
isLoading: isLoading,
judul: judul,
scrlCnt: scrlCnt,
selectedCounter: selectedCounter,
listBelumDilayani: listBelumDilayani,
listCall: listCall,
listSedangDilayani: listSedangDilayani,
);
} else {
return WithMediaPromo(
listBelumDilayani: listBelumDilayani,
isLoading: isLoading,
judul: judul,
scrlCnt: scrlCnt,
selectedCounter: selectedCounter,
listCall: listCall,
listSedangDilayani: listSedangDilayani,
);
}
}
}

View File

@@ -0,0 +1,294 @@
import 'package:flutter/material.dart';
import 'package:text_scroll/text_scroll.dart';
import '../app/constant.dart';
import '../model/display_counter_dedicated_modelv2.dart';
import '../model/service_model.dart';
import '../widget/clock.dart';
import '../widget/my_antrian_customer_service_dedicated.dart';
import '../widget/my_counter_customer_service_dedicated.dart';
import 'customer_service_dedicatedv2.dart';
class DisplayTanpaPromo extends StatelessWidget {
const DisplayTanpaPromo(
{Key? key,
required this.isLoading,
required this.judul,
required this.scrlCnt,
required this.selectedCounter,
required this.listBelumDilayani,
required this.listCall,
required this.listSedangDilayani})
: super(key: key);
final ValueNotifier<bool> isLoading;
final ValueNotifier<String> judul;
final ScrollController scrlCnt;
final ValueNotifier<List<Layanan>> selectedCounter;
final ValueNotifier<List<NotServed>> listBelumDilayani;
final ValueNotifier<List<Call>> listCall;
final ValueNotifier<List<Served>> listSedangDilayani;
@override
Widget build(BuildContext context) {
getNomorAntrian(String counterID) {
var rawCall = listCall.value;
// print(rawCall);
Call call = Call(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawCall.length; i++) {
if (rawCall[i].queueCounterID == counterID) {
call = rawCall[i];
}
}
var rawProcess = listSedangDilayani.value;
Served process = Served(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawProcess.length; i++) {
if (rawProcess[i].queueCounterID == counterID) {
process = rawProcess[i];
}
}
if (call.queueID != '0' && process.queueID == '0') {
return call.queueNumber;
} else if (call.queueID == '0' && process.queueID != '0') {
return process.queueNumber;
} else if (call.queueID == '0' && process.queueID == '0') {
return '-';
} else {
return call.queueNumber;
}
}
getBlinkAntrian(String counterID) {
var rawCall = listCall.value;
// print(rawCall);
Call call = Call(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawCall.length; i++) {
if (rawCall[i].queueCounterID == counterID) {
call = rawCall[i];
}
}
var rawProcess = listSedangDilayani.value;
Served process = Served(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawProcess.length; i++) {
if (rawProcess[i].queueCounterID == counterID) {
process = rawProcess[i];
}
}
if (call.queueID != '0' && process.queueID == '0') {
return true;
} else if (call.queueID == '0' && process.queueID != '0') {
return false;
} else if (call.queueID == '0' && process.queueID == '0') {
return false;
} else {
return true;
}
}
return Material(
child: Container(
width: Constant.getActualX(context: context, x: 1920),
height: Constant.getActualY(context: context, y: 1080),
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/background.png'), fit: BoxFit.fill),
),
child: Padding(
padding:
const EdgeInsets.only(left: 68, right: 68, top: 34, bottom: 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// judul start
Row(
children: [
Expanded(
flex: 3,
child: Container(
// color: Colors.green,
// width: Constant.getActualX(context: context, x: 900),
height: Constant.getActualY(context: context, y: 120),
child: Stack(
alignment: Alignment.centerLeft,
children: [
Container(
width:
Constant.getActualX(context: context, x: 1400),
height:
Constant.getActualY(context: context, y: 72),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.25),
blurRadius: 8)
],
borderRadius: BorderRadius.circular(20),
color: Colors.white),
child: Padding(
padding: const EdgeInsets.only(
top: 6,
left: 80,
),
child: Stack(
alignment: Alignment.centerLeft,
children: [
if (isLoading.value)
SizedBox(
width: Constant.getActualX(
context: context, x: 60),
height: Constant.getActualX(
context: context, x: 70),
child: const CircularProgressIndicator(),
),
Padding(
padding:
EdgeInsets.only(left: 40, right: 40),
child: TextScroll(
judul.value,
velocity: Velocity(
pixelsPerSecond: Offset(50, 0)),
style: Constant.body_3(context: context)
.copyWith(color: Constant.textRed),
),
),
],
),
),
),
Container(
width:
Constant.getActualX(context: context, x: 100),
height:
Constant.getActualY(context: context, y: 100),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: LinearGradient(
colors: [Constant.red1, Constant.red2])),
),
Positioned(
top: 0,
child: Image.asset(
'images/cs.png',
fit: BoxFit.cover,
height: 100,
),
)
],
),
),
),
Expanded(
flex: 1,
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: Clock(),
),
),
],
),
// judul end
// counter list start
Expanded(
child: Container(
// color: Colors.blue,
width: Constant.getActualX(context: context, x: 1920),
height: Constant.getActualY(context: context, y: 400),
child: GridView.count(
scrollDirection: Axis.horizontal,
controller: scrlCnt,
crossAxisSpacing: 0.6,
// mainAxisSpacing: 30,
childAspectRatio: 1,
crossAxisCount: 1,
children: selectedCounter.value
.map(
(e) => MyCounterCustomerServiceDedicated(
// counter: 'DOKTER UMUM',
counter: 'Counter ${e.counterCode}',
nomorAntrian:
getNomorAntrian(e.counterID.toString()),
// nomorAntrian: 'LA 001',
borderDalam: const BorderRadius.only(
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
bottomLeft: Radius.circular(50)),
borderLuar: const BorderRadius.only(
topLeft: Radius.circular(60),
topRight: Radius.circular(60),
bottomLeft: Radius.circular(60),
),
blink: getBlinkAntrian(e.counterID.toString()),
),
)
.toList()),
),
),
// counter list end
// antrian selanjutnya start
SizedBox(
width: Constant.getActualX(context: context, x: 882),
height: Constant.getActualY(context: context, y: 66),
child: Text('Antrian Selanjutnya',
style: Constant.S50(context: context)
.copyWith(color: Constant.textBlack)),
),
SizedBox(
height: Constant.getActualY(context: context, y: 24),
),
Container(
// color: Colors.yellowAccent,
width: Constant.getActualX(context: context, x: 1920),
height: Constant.getActualY(context: context, y: 360),
child: GridView.count(
crossAxisSpacing: 10,
mainAxisSpacing: 0,
crossAxisCount: 3,
childAspectRatio: 5,
children: listBelumDilayani.value
.map(
(e) => MyAntrianCustomerServiceDedicated(
antrian: e.queueNumber,
skip: e.skipQueue,
),
)
.toList(),
),
),
],
),
),
),
);
}
}

View File

@@ -0,0 +1,63 @@
import 'package:equatable/equatable.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:queuedisplay/model/branch_model.dart';
import 'package:queuedisplay/provider/dio_provider.dart';
import 'package:queuedisplay/repository/base_repository.dart';
import 'package:queuedisplay/repository/counter_repository.dart';
abstract class BranchListState extends Equatable {
final DateTime date;
const BranchListState(this.date);
@override
List<Object?> get props => [date];
}
class BranchListStateInit extends BranchListState {
BranchListStateInit() : super(DateTime.now());
}
class BranchListStateLoading extends BranchListState {
BranchListStateLoading() : super(DateTime.now());
}
class BranchListStateError extends BranchListState {
final String message;
BranchListStateError({
required this.message,
}) : super(DateTime.now());
}
class BranchListStateDone extends BranchListState {
final List<BranchModel> model;
BranchListStateDone({
required this.model,
}) : super(DateTime.now());
}
//notifier
class BranchListNotifier extends StateNotifier<BranchListState> {
final Ref ref;
BranchListNotifier({
required this.ref,
}) : super(BranchListStateInit());
void list() async {
try {
state = BranchListStateLoading();
final dio = ref.read(dioProvider);
final resp = await CounterRepository(dio: dio).getBranch();
state = BranchListStateDone(model: resp);
} catch (e) {
if (e is BaseRepositoryException) {
state = BranchListStateError(message: e.message);
} else {
state = BranchListStateError(message: e.toString());
}
}
}
}
//provider
final BranchListProvider =
StateNotifierProvider<BranchListNotifier, BranchListState>(
(ref) => BranchListNotifier(ref: ref));

View File

@@ -0,0 +1,656 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:queuedisplay/app/route.dart';
import 'package:queuedisplay/model/branch_model.dart';
import 'package:queuedisplay/model/error_msg_model.dart';
import 'package:queuedisplay/model/layanan_dokter.dart';
import 'package:queuedisplay/model/service_model.dart';
import 'package:queuedisplay/provider/layanan_dokter_provider.dart';
import 'package:queuedisplay/provider/service_provider.dart';
import 'package:queuedisplay/screen/settings/branch_list_provider.dart';
import 'package:queuedisplay/widget/display_counter.dart';
import 'package:queuedisplay/widget/my_error_dialog_state.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../app/constant.dart';
import '../../model/counter_model.dart';
import '../../model/sampling_location_model.dart';
import '../../provider/all_service_provider.dart';
import '../../provider/counter_provider.dart';
import '../../provider/sampling_location_provider.dart';
import '../../widget/SamplingSoundSetting.dart';
import '../../widget/counter_sound_setting.dart';
import '../../widget/display_dokter.dart';
import '../../widget/my_error_dialog.dart';
class SettingScreenCounterDedicated extends HookConsumerWidget {
const SettingScreenCounterDedicated({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final init = useState(true);
final ctrlJudul = useTextEditingController(text: "");
final ctrlJudulError = useState(false);
final isLoading = useState(false);
final errorMessage = useState("");
final listService = useState<List<Layanan>>(List.empty());
final activeLayanan = useState<List>(List.empty());
final activeSoundCounter = useState<List>(List.empty());
final serviceIDArr = useState<List>(List.empty());
final data = useState('N');
final isLoadingDoctor = useState(false);
final listServiceDoctor = useState<List<LayananDokter>>(List.empty());
final activeSoundDoctor = useState<List>(List.empty());
// Sampling
final isLoadingSamplingLocation = useState(false);
final listSamplingLocation = useState<List<SamplingLocation>>(List.empty());
final activeSoundSamplingLocation = useState<List>(List.empty());
// Media Promo
final tanpaMediaPromo = useState(false);
final errorMsgList = useState<List<ErrorMsgModel>>(List.empty());
//Branch
final branchList = useState<List<BranchModel>>([]);
final selectedBranch = useState<BranchModel?>(null);
_isThereCurrentDialogShowing(BuildContext context) =>
ModalRoute.of(context)?.isCurrent != true;
// function
Future delData() async {
// Obtain shared preferences.
try {
final prefs = await SharedPreferences.getInstance();
await prefs.remove('counter_dedicated');
} catch (e) {
// print(e);
}
}
Future getData() async {
try {
final prefs = await SharedPreferences.getInstance();
var rawData = prefs.getString('counter_dedicated') ?? 'a';
data.value = rawData;
if (rawData != 'a') {
listService.value = ref.read(allServiceProvider);
var data = json.decode(rawData);
ctrlJudul.text = data['judul'];
activeLayanan.value = data['activeLayanan'] ?? List.empty();
activeSoundCounter.value = data['activeSoundCounter'] ?? List.empty();
activeSoundDoctor.value = data['activeSoundDoctor'] ?? List.empty();
activeSoundSamplingLocation.value =
data['activeSoundSamplingLocation'] ?? List.empty();
selectedBranch.value = BranchModel.fromJson(data['selectedBranch']);
// media promo
tanpaMediaPromo.value = data['tanpaMediaPromo'] ?? List.empty();
if (activeLayanan.value.isNotEmpty) {
activeLayanan.value.forEach((e) {
listService.value.forEach((f) {
if (e == f.counterID) {
f.value = true;
}
});
});
}
// suara counter
if (activeSoundCounter.value.isNotEmpty) {
activeSoundCounter.value.forEach((e) {
listService.value.forEach((f) {
if (e == f.counterID) {
f.sound = true;
}
});
});
}
// suara sampling
if (activeSoundSamplingLocation.value.isNotEmpty) {
activeSoundSamplingLocation.value.forEach((e) {
listSamplingLocation.value.forEach((f) {
if (e == f.mLocationID) {
f.value = true;
// print(e);
}
});
});
}
// suara dokter
if (activeSoundDoctor.value.isNotEmpty) {
activeSoundDoctor.value.forEach((e) {
listServiceDoctor.value.forEach((f) {
if (e == f.id) {
f.value = true;
// print(e);
}
});
});
}
}
} catch (e) {
// print(e);
myErrorDialog(
context, e.toString(), 'ERROR: Get data shared preference');
}
}
Future<bool> saveData() async {
try {
final prefs = await SharedPreferences.getInstance();
var distinctList = activeLayanan.value.toSet().toList();
// suara counter
var distinctListCounterSnd = activeSoundCounter.value.toSet().toList();
// suara doctor
var distinctListDoctorSnd = activeSoundDoctor.value.toSet().toList();
// suara sampling
var distinctListSamplingSnd =
activeSoundSamplingLocation.value.toSet().toList();
// media promo
var distinctMediaPromoSnd = tanpaMediaPromo.value;
var serviceIDTemp = List.empty(growable: true);
var serviceIDTempSuara = List.empty(growable: true);
listService.value.forEach((i) {
distinctList.forEach((j) {
if (i.counterID == int.parse(j.toString())) {
if (i.serviceID != null) {
List listServiceIDx = i.serviceID!.split(',');
serviceIDTemp.addAll(listServiceIDx);
}
}
});
});
// suara counter
listService.value.forEach((i) {
distinctListCounterSnd.forEach((j) {
if (i.counterID == int.parse(j.toString())) {
if (i.serviceID != null) {
List listServiceIDx = i.serviceID!.split(',');
serviceIDTempSuara.addAll(listServiceIDx);
}
}
});
});
final Map<String, dynamic> data = {
"judul": ctrlJudul.text,
"activeLayanan": distinctList,
"activeSoundDoctor": distinctListDoctorSnd,
"activeSoundCounter": distinctListCounterSnd,
"activeSoundSamplingLocation": distinctListSamplingSnd,
"tanpaMediaPromo": distinctMediaPromoSnd,
"serviceID": serviceIDTemp,
"selectedBranch": selectedBranch.value,
"serviceIDSuara": serviceIDTempSuara,
};
await prefs.setString('counter_dedicated', json.encode(data));
// print(data);
return true;
} catch (e) {
myErrorDialog(
context, e.toString(), 'ERROR: Save data sahred preference');
// print(e);
return false;
}
}
useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
ref.read(BranchListProvider.notifier).list();
// ref.read(layananProvider.notifier).list();
// ref.read(SamplingLocationProvider.notifier).list();
await getData();
});
return () {};
}, []);
useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
if (selectedBranch.value != null) {
if (!init.value) {
activeLayanan.value = [];
listService.value = [];
activeSoundCounter.value = [];
}
init.value = false;
ref
.read(serviceProvider.notifier)
.list(selectedBranch.value?.mBranchID ?? ')');
}
});
return () {};
}, [selectedBranch.value]);
// counter
ref.listen(serviceProvider, (prev, next) {
if (next is ServiceListStateLoading) {
isLoading.value = true;
} else if (next is ServiceListStateError) {
isLoading.value = false;
errorMessage.value = next.message;
List<ErrorMsgModel> msg = ref.read(errorListMsgProvider);
msg.add(ErrorMsgModel(
title: "ERROR: Get data list counter", msg: next.message));
ref.read(errorListMsgProvider.notifier).state = msg;
if (!_isThereCurrentDialogShowing(context)) {
myErrorDialogState(context, 'ERROR: Get data list counter');
}
Timer(const Duration(seconds: 3), () {
errorMessage.value = "";
});
} else if (next is ServiceListStateDone) {
isLoading.value = false;
listService.value = next.model;
if (activeLayanan.value.isNotEmpty) {
activeLayanan.value.forEach((e) {
listService.value.forEach((f) {
if (e == f.counterID) {
f.value = true;
}
});
});
}
// suara aktif?
if (activeSoundCounter.value.isNotEmpty) {
activeSoundCounter.value.forEach((e) {
listService.value.forEach((f) {
if (e == f.counterID) {
f.sound = true;
}
});
});
}
}
});
// sampling location
ref.listen(SamplingLocationProvider, (prev, next) {
if (next is SamplingLocationListLoading) {
isLoadingSamplingLocation.value = true;
} else if (next is SamplingLocationListError) {
isLoadingSamplingLocation.value = false;
errorMessage.value = next.message;
List<ErrorMsgModel> msg = ref.read(errorListMsgProvider);
msg.add(ErrorMsgModel(
title: "ERROR: Get data list sampling sound", msg: next.message));
ref.read(errorListMsgProvider.notifier).state = msg;
if (!_isThereCurrentDialogShowing(context)) {
myErrorDialogState(context, 'ERROR: Get data list sampling sound');
}
Timer(const Duration(seconds: 3), () {
errorMessage.value = "";
});
} else if (next is SamplingLocationListDone) {
isLoadingSamplingLocation.value = false;
listSamplingLocation.value = next.model;
if (activeSoundSamplingLocation.value.isNotEmpty) {
activeSoundSamplingLocation.value.forEach((e) {
listSamplingLocation.value.forEach((f) {
if (e == f.mLocationID) {
f.value = true;
// print(e);
}
});
});
}
// print(jsonEncode(next.model));
}
});
// layanan dokter
ref.listen(layananProvider, (prev, next) {
if (next is LayananListStateLoading) {
isLoadingDoctor.value = true;
} else if (next is LayananListStateError) {
isLoadingDoctor.value = false;
errorMessage.value = next.message;
List<ErrorMsgModel> msg = ref.read(errorListMsgProvider);
msg.add(ErrorMsgModel(
title: "ERROR: Get data list sound doctor", msg: next.message));
ref.read(errorListMsgProvider.notifier).state = msg;
if (!_isThereCurrentDialogShowing(context)) {
myErrorDialogState(context, 'ERROR: Get data list sound doctor');
}
Timer(const Duration(seconds: 3), () {
errorMessage.value = "";
});
} else if (next is LayananListStateDone) {
isLoadingDoctor.value = false;
listServiceDoctor.value = next.model;
if (activeSoundDoctor.value.isNotEmpty) {
activeSoundDoctor.value.forEach((e) {
listServiceDoctor.value.forEach((f) {
if (e == f.id) {
f.value = true;
}
});
});
}
}
});
ref.listen(BranchListProvider, (previous, next) {
if (next is BranchListStateLoading) {
isLoading.value = true;
} else if (next is BranchListStateError) {
myErrorDialog(context, next.message, 'ERROR');
isLoading.value = false;
} else if (next is BranchListStateDone) {
// ref.read(allServiceProvider.notifier).state = next.model;
// print(ref.read(allServiceProvider));
branchList.value = next.model;
isLoading.value = false;
}
});
return Material(
child: Container(
height: Constant.getActualY(context: context, y: 982),
width: Constant.getActualX(context: context, x: 1512),
decoration: const BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage('images/background.png'),
),
),
child: Center(
child: Card(
color: Colors.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
elevation: 5,
child: SizedBox(
height: Constant.getActualY(context: context, y: 880),
width: Constant.getActualX(context: context, x: 1360),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: Constant.getActualX(context: context, x: 30),
vertical: Constant.getActualY(context: context, y: 30),
),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
// TextButton(
// onPressed: () {
// Navigator.of(context)
// .popAndPushNamed(displayRoute);
// // print(pm.currentStatusUSB);
// // print(pm.currentStatusUSB);
// },
// child: const Text('back')),
Text(
'Setting',
style: Constant.subTitle(context: context),
),
// TextButton(
// onPressed: () {
// delData();
// },
// child: const Text('Delete All')),
],
),
SizedBox(
height: Constant.getActualY(context: context, y: 30),
),
Text(
'Cabang*',
style: Constant.label(context: context),
),
SizedBox(
height: Constant.getActualY(context: context, y: 60),
child: DropdownButtonFormField<BranchModel>(
style: Constant.normal(context: context)
.copyWith(color: Colors.black),
decoration: const InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8),
),
),
),
menuMaxHeight:
Constant.getActualY(context: context, y: 500),
hint: Text(selectedBranch.value?.mBranchName ?? ''),
items: branchList.value
.map((e) => DropdownMenuItem<BranchModel>(
value: e, child: Text(e.mBranchName ?? '')))
.toList(),
onChanged: (BranchModel? e) {
// print(e);
selectedBranch.value = e!;
},
),
),
SizedBox(
height: Constant.getActualY(context: context, y: 20),
),
Text(
'Judul Header*',
style: Constant.label(context: context),
),
SizedBox(
width: Constant.getActualX(context: context, x: 1300),
child: TextField(
controller: ctrlJudul,
onChanged: (value) {
if (value.trim() == "") {
ctrlJudulError.value = true;
}
if (value.trim() != "") {
ctrlJudulError.value = false;
}
},
decoration: InputDecoration(
errorText: ctrlJudulError.value
? "Tidak boleh kosong"
: null,
border: const OutlineInputBorder(),
focusedBorder: const OutlineInputBorder(
borderSide:
BorderSide(color: Colors.blue, width: 2)),
hintText: "example Customer Service",
hintStyle: Constant.label(context: context)),
),
),
SizedBox(
height: Constant.getActualY(context: context, y: 20),
),
Text(
'Display Counter*',
style: Constant.label(context: context),
),
// widget counter
DisplayCounter(
isloading: isLoading,
listService: listService,
activeLayanan: activeLayanan,
),
//SOUND COUNTER
SizedBox(
height: Constant.getActualY(context: context, y: 50),
),
Text(
'Proses Suara Counter/FO',
style: Constant.label(context: context),
),
// suara
CounterSoundSetting(
isLoading: isLoading,
listService: listService,
activeSoundCounter: activeSoundCounter),
//END SOUND COUNTER
SizedBox(
height: Constant.getActualY(context: context, y: 50),
),
// Text(
// 'Proses Suara Sampling',
// style: Constant.label(context: context),
// ),
// SamplingSoundSetting(
// isloading: isLoadingSamplingLocation,
// listSamplingLocation: listSamplingLocation,
// activeSoundSampling: activeSoundSamplingLocation,
// ),
// SizedBox(
// height: Constant.getActualY(context: context, y: 50),
// ),
// Text(
// 'Proses Suara Layanan Dokter ',
// style: Constant.label(context: context),
// ),
// // DISPLAY LAYANAN DOKTER
// DisplayDoctor(
// isLoadingDoctor: isLoadingDoctor,
// listServiceDoctor: listServiceDoctor,
// activeSoundDoctor: activeSoundDoctor,
// ),
// // // END DISPLAY LAYANAN DOKTER
// Checkbox banner media promo start
// SizedBox(
// height: Constant.getActualY(context: context, y: 50),
// ),
Text(
'Media Promo',
style: Constant.label(context: context),
),
SizedBox(
// width: Constant.getActualX(
// context: context, x: 500),
height: Constant.getActualY(context: context, y: 200),
child: GridView.count(
childAspectRatio:
Constant.getActualY(context: context, y: 150) /
Constant.getActualX(context: context, x: 15),
crossAxisCount: 2,
children: [
Row(
children: [
FractionallySizedBox(
child: CupertinoSwitch(
value: tanpaMediaPromo.value,
onChanged: (val) {
if (val) {
var rwData =
json.encode(tanpaMediaPromo.value);
bool data = json.decode(rwData);
bool actlyn = data;
actlyn = !val;
tanpaMediaPromo.value = actlyn;
}
if (!val) {
var rwData =
json.encode(tanpaMediaPromo.value);
bool data = json.decode(rwData);
bool actlyn = data;
actlyn = !val;
tanpaMediaPromo.value = actlyn;
}
tanpaMediaPromo.value = val;
},
),
),
Expanded(
child: Text(
"Tanpa Media Promo",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: Constant.normal(context: context),
),
)
],
),
]),
),
// Checkbox banner media promo end
SizedBox(
height: Constant.getActualY(context: context, y: 20),
),
Center(
child: SizedBox(
height: Constant.getActualY(context: context, y: 60),
width: Constant.getActualX(context: context, x: 200),
child: TextButton(
onPressed: () {
if (ctrlJudul.text.isNotEmpty &&
activeLayanan.value.isNotEmpty &&
selectedBranch.value != null) {
saveData();
ref.read(allServiceProvider.notifier).state =
listService.value;
ref
.read(allServiceDoctorProvider.notifier)
.state = listServiceDoctor.value;
Navigator.of(context).pushNamedAndRemoveUntil(
customerServiceDedicatedRoute,
(route) => false);
return;
} else {
if (ctrlJudul.text.isEmpty) {
myErrorDialog(
context,
'Input bertanda * tidak boleh kosong',
'PERINGATAN');
} else if (activeLayanan.value.isEmpty) {
myErrorDialog(
context,
'Layanan belum ada yang aktif',
'PERINGATAN');
}
}
},
style: TextButton.styleFrom(
elevation: 5, backgroundColor: Colors.blue),
child: Text(
'Save',
style: Constant.subTitle(context: context)
.copyWith(color: Colors.white),
),
)),
)
],
),
),
),
),
),
),
));
}
}

View File

@@ -0,0 +1,425 @@
import 'package:flutter/material.dart';
import 'package:flutter_image_slideshow/flutter_image_slideshow.dart';
import 'package:text_scroll/text_scroll.dart';
import '../app/constant.dart';
import '../model/display_counter_dedicated_modelv2.dart';
import '../model/service_model.dart';
import '../widget/clock.dart';
import '../widget/my_antrian_customer_service_dedicated.dart';
import '../widget/my_counter_customer_service_dedicated.dart';
class WithMediaPromo extends StatelessWidget {
const WithMediaPromo({
Key? key,
required this.listBelumDilayani,
required this.isLoading,
required this.judul,
required this.scrlCnt,
required this.selectedCounter,
required this.listCall,
required this.listSedangDilayani,
}) : super(key: key);
final ValueNotifier<List<NotServed>> listBelumDilayani;
final ValueNotifier<bool> isLoading;
final ValueNotifier<String> judul;
final ScrollController scrlCnt;
final ValueNotifier<List<Layanan>> selectedCounter;
final ValueNotifier<List<Call>> listCall;
final ValueNotifier<List<Served>> listSedangDilayani;
@override
Widget build(BuildContext context) {
getNomorAntrian(String counterID) {
var rawCall = listCall.value;
// print(rawCall);
Call call = Call(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawCall.length; i++) {
if (rawCall[i].queueCounterID == counterID) {
call = rawCall[i];
}
}
var rawProcess = listSedangDilayani.value;
Served process = Served(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawProcess.length; i++) {
if (rawProcess[i].queueCounterID == counterID) {
process = rawProcess[i];
}
}
if (call.queueID != '0' && process.queueID == '0') {
return call.queueNumber;
} else if (call.queueID == '0' && process.queueID != '0') {
return process.queueNumber;
} else if (call.queueID == '0' && process.queueID == '0') {
return '-';
} else {
return call.queueNumber;
}
}
getBlinkAntrian(String counterID) {
var rawCall = listCall.value;
// print(rawCall);
Call call = Call(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawCall.length; i++) {
if (rawCall[i].queueCounterID == counterID) {
call = rawCall[i];
}
}
var rawProcess = listSedangDilayani.value;
Served process = Served(
queueID: '0',
statusID: '0',
queueNumber: '0',
queueCounterID: '0',
counterCode: '0',
orderStatus: '0');
for (var i = 0; i < rawProcess.length; i++) {
if (rawProcess[i].queueCounterID == counterID) {
process = rawProcess[i];
}
}
if (call.queueID != '0' && process.queueID == '0') {
return true;
} else if (call.queueID == '0' && process.queueID != '0') {
return false;
} else if (call.queueID == '0' && process.queueID == '0') {
return false;
} else {
return true;
}
}
return Material(
child: Container(
width: Constant.getActualX(context: context, x: 1920),
height: Constant.getActualY(context: context, y: 1080),
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/background.png'), fit: BoxFit.fill)),
child: Padding(
padding: EdgeInsets.only(
left: Constant.getActualX(context: context, x: 68),
right: Constant.getActualX(context: context, x: 68),
top: Constant.getActualY(context: context, y: 34),
bottom: Constant.getActualY(context: context, y: 32)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Column(
// mainAxisAlignment: MainAxisAlignment.end,
// crossAxisAlignment: CrossAxisAlignment.start,
children: [
//TV
SizedBox(
width: Constant.getActualX(context: context, x: 882),
height: Constant.getActualY(context: context, y: 508),
child: ImageSlideshow(
indicatorColor: Colors.transparent,
indicatorBackgroundColor: Colors.transparent,
autoPlayInterval: 5000,
isLoop: true,
children: [
// Container(
// child:
// ),
Image.network(
'https://${Constant.baseSocket}/one-media/one-queue/slide-counter/1.jpg',
errorBuilder: (context, error, stackTrace) {
return Image.asset(
'images/1.jpg',
fit: BoxFit.fitWidth,
);
},
headers: {
'Access-Control-Allow-Origin': '*',
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) {
return child;
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
Image.network(
'https://${Constant.baseSocket}/one-media/one-queue/slide-counter/2.jpg',
errorBuilder: (context, error, stackTrace) {
return Image.asset(
'images/2.jpg',
fit: BoxFit.fitWidth,
);
},
headers: {
'Access-Control-Allow-Origin': '*',
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) {
return child;
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
Image.network(
'https://${Constant.baseSocket}/one-media/one-queue/slide-counter/3.jpg',
errorBuilder: (context, error, stackTrace) {
return Image.asset(
'images/3.jpg',
fit: BoxFit.fitWidth,
);
},
headers: {
'Access-Control-Allow-Origin': '*',
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) {
return child;
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
Image.network(
'https://${Constant.baseSocket}/one-media/one-queue/slide-counter/4.jpg',
errorBuilder: (context, error, stackTrace) {
return Image.asset(
'images/4.jpg',
fit: BoxFit.fitWidth,
);
},
headers: {
'Access-Control-Allow-Origin': '*',
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) {
return child;
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
Image.network(
'https://${Constant.baseSocket}/one-media/one-queue/slide-counter/5.jpg',
errorBuilder: (context, error, stackTrace) {
return Image.asset(
'images/5.jpg',
fit: BoxFit.fitWidth,
);
},
headers: {
'Access-Control-Allow-Origin': '*',
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) {
return child;
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
],
),
),
SizedBox(
height: Constant.getActualY(context: context, y: 10),
),
// waktu yg direvisi
Clock(),
//Antrian Selanjutnya
SizedBox(
width: Constant.getActualX(context: context, x: 882),
height: Constant.getActualY(context: context, y: 66),
child: Text('Antrian Selanjutnya',
style: Constant.S50(context: context)
.copyWith(color: Constant.textBlack)),
),
SizedBox(
height: Constant.getActualY(context: context, y: 24),
),
SizedBox(
width: Constant.getActualX(context: context, x: 882),
height: Constant.getActualY(context: context, y: 300),
child: GridView.count(
crossAxisSpacing: 10,
mainAxisSpacing: 0,
crossAxisCount: 2,
childAspectRatio: 4,
children: listBelumDilayani.value
.map(
(e) => GestureDetector(
onTap: () {
// process_sound(
// e['waiting'].queueNumber, "r117");
},
child: MyAntrianCustomerServiceDedicated(
skip: e.skipQueue,
antrian: e.queueNumber,
),
),
)
.toList(),
),
),
],
),
// const Spacer(),
SizedBox(
width: Constant.getActualX(context: context, x: 40),
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
children: [
SizedBox(
width: Constant.getActualX(context: context, x: 808),
height: Constant.getActualY(context: context, y: 160),
child: Stack(
alignment: Alignment.centerLeft,
children: [
Container(
width:
Constant.getActualX(context: context, x: 808),
height:
Constant.getActualY(context: context, y: 72),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.25),
blurRadius: 8)
],
borderRadius: BorderRadius.circular(20),
color: Colors.white),
child: Padding(
padding: EdgeInsets.only(
top: 6,
left: Constant.getActualX(
context: context, x: 120),
),
child: Stack(
alignment: Alignment.centerLeft,
children: [
if (isLoading.value)
SizedBox(
width: Constant.getActualX(
context: context, x: 60),
height: Constant.getActualX(
context: context, x: 70),
child:
const CircularProgressIndicator(),
),
TextScroll(judul.value,
velocity: Velocity(
pixelsPerSecond: Offset(50, 0)),
style: Constant.body_3(context: context)
.copyWith(color: Constant.textRed)),
],
),
),
),
Container(
width:
Constant.getActualX(context: context, x: 100),
height:
Constant.getActualY(context: context, y: 100),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: LinearGradient(
colors: [Constant.red1, Constant.red2])),
),
Positioned(
top: 0,
child: Image.asset(
'images/cs.png',
fit: BoxFit.cover,
height: 100,
),
)
],
),
),
SizedBox(
width: Constant.getActualX(context: context, x: 20),
),
],
),
SizedBox(
width: Constant.getActualX(context: context, x: 808),
height: Constant.getActualY(context: context, y: 820),
child: GridView.count(
scrollDirection: Axis.horizontal,
controller: scrlCnt,
crossAxisSpacing: 90,
mainAxisSpacing: 60,
crossAxisCount: 2,
children: selectedCounter.value
.map(
(e) => MyCounterCustomerServiceDedicated(
// counter: 'DOKTER UMUM',
counter: 'Counter ${e.counterCode}',
nomorAntrian:
getNomorAntrian(e.counterID.toString()),
// nomorAntrian: 'LA 001',
borderDalam: const BorderRadius.only(
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
bottomLeft: Radius.circular(50)),
borderLuar: const BorderRadius.only(
topLeft: Radius.circular(60),
topRight: Radius.circular(60),
bottomLeft: Radius.circular(60),
),
blink: getBlinkAntrian(e.counterID.toString()),
),
)
.toList()),
),
],
),
],
),
),
),
);
}
}