import 'dart:convert'; import 'package:fikoyt_sistem/apps/uyar/core/services/kullanici_service.dart'; import 'package:fikoyt_ui/core/fiko_request.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart' hide FormData, MultipartFile; import 'package:dio/dio.dart'; class UyarService extends GetxService { KullaniciService logicKullanici = KullaniciService().init(); /** */ Rx aktifKullanici = Rx(null); Future init() async { return this; } girisYap(BuildContext context, {required String ad, required String parola}) async { // print(toJson()); var formData = FormData(); formData.fields.add(MapEntry("req_body", jsonEncode({"kullaniciAdi": ad, "parola": parola}).toString())); istek_yap(command: 'FikoYT.sistem.giris.yap', parameters: formData) .listen((sonuc) async { if (sonuc.type == FikoYTRequestType.RESPONDED) { toastification.dismissAll(delayForAnimation: true); aktifKullanici.value = sonuc.result?["sonuc"]; FikoYTCoreService.serviceSettings.socketDataMiddleWare = {"kullanici_kimlik": aktifKullanici.value?["_id"]}; FikoYTCoreService.socket.disconnect(); FikoYTCoreService.socket.connect(); /// Giriş Başarılı toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.success, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text( "Sn. ${sonuc.result?['sonuc']?['isim'] ?? ''} ${sonuc.result?['sonuc']?['soyIsim'] ?? ''} Girişiniz Yapıldı.", ), alignment: Alignment.topRight, margin: EdgeInsets.only(top: 32, right: 20), autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); context.vRouter.to("/uyar/uye/ana-sayfa"); } }) /** */ .onError((hata) async { toastification.dismissAll(delayForAnimation: true); /// Giriş Başarılı toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.error, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text("Girilen Bilgileri Kontrol Ediniz."), alignment: Alignment.topRight, margin: EdgeInsets.only(top: 32, right: 20), autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); }); } cikisYap(BuildContext context) { istek_yap(command: 'FikoYT.sistem.cikis.yap') .listen((sonuc) async { if (sonuc.type == FikoYTRequestType.RESPONDED) { toastification.dismissAll(delayForAnimation: true); aktifKullanici.value = null; FikoYTCoreService.serviceSettings.socketDataMiddleWare = {"kullanici_kimlik": null}; FikoYTCoreService.socket.disconnect(); FikoYTCoreService.socket.connect(); /// Giriş Başarılı toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.info, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text("Çıkışınız Yapıldı."), alignment: Alignment.topRight, margin: EdgeInsets.only(top: 32, right: 20), autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); context.vRouter.to("/uyar/kisi/ana-sayfa"); FikoYTCoreService.ioEmit("FikoYT.sistem.io.cihaz.baglandi", {}); } }) /** */ .onError((hata) async { toastification.dismissAll(delayForAnimation: true); FikoYTCoreService.ioEmit("FikoYT.sistem.io.cihaz.baglandi", {}); }); } }