import 'package:fikoyt_ui/fikoyt_ui.dart'; class ActiveUserModel { ActiveUserModel({this.id, this.adSoyad, this.kullaniciAdi, this.eposta, this.parola, this.profilResmi, this.aktif, this.yetkiler, this.superKullanici}); String? id; String? adSoyad; String? kullaniciAdi; String? eposta; String? parola; String? profilResmi; bool? aktif; List? yetkiler; String? superKullanici; factory ActiveUserModel.fromJson(Map json) => ActiveUserModel(id: json["_id"] is ObjectId ? json["_id"].$oid : json["_id"], adSoyad: json["adSoyad"], kullaniciAdi: json["kullaniciAdi"], eposta: json["eposta"], parola: json["parola"], profilResmi: json["profilResmi"] is ObjectId ? json["profilResmi"].$oid : json["profilResmi"], aktif: json["aktif"], yetkiler: json["yetkiler"] ?? [], superKullanici: json["superKullanici"]); Map toJson() => { "_id": id, "adSoyad": adSoyad, "kullaniciAdi": kullaniciAdi, "eposta": eposta, "parola": parola, "profilResmi": profilResmi, "aktif": aktif, "yetkiler": yetkiler, "superKullanici": superKullanici, }; } class AktifKullanici { Rx? bilgiler; Rx resimZamanEtiket = DateTime.now().obs; // ignore: non_constant_identifier_names // Future girisYap(String kullaniciAdi,String parola) async { // try { // Response? cevap = await dio?.post( // 'fapi/FikoYT.sistem.girisYap', // data: {'adi': kullaniciAdi, 'parola': parola}, // onSendProgress: (int sent, int total) { // // if (kDebugMode) { // // print("$sent $total"); // // } // }, // ); // bilgiler = ActiveUserModel.fromJson(cevap?.data).obs; // update(); // return bilgiler; // } on DioError catch (e) { // if (e.response != null) { // if (kDebugMode) { // print(e.response?.data); // print(e.response?.headers); // print(e.message); // } // bilgiler=null; // return null; // } else { // // Something happened in setting up or sending the request that triggered an Error // if (kDebugMode) { // print(e.requestOptions); // print(e.message); // } // bilgiler=null; // return null; // } // } // } // Future cikisYap() async { // try { // Response? cevap = await dio?.post( // 'fapi/FikoYT.sistem.cikisYap', // data: {"id":aktifKullanici.bilgiler?.value.id}, // onSendProgress: (int sent, int total) { // // if (kDebugMode) { // // print("$sent $total"); // // } // }, // ); // if (kDebugMode) { // print(cevap); // } // // fikoyt.sezonBosta.iptal(); // bilgiler = null; // update(); // return bilgiler; // } on DioError catch (e) { // if (e.response != null) { // if (kDebugMode) { // print(e.response?.data); // print(e.response?.headers); // print(e.message); // } // bilgiler=null; // return null; // } else { // // Something happened in setting up or sending the request that triggered an Error // if (kDebugMode) { // print(e.requestOptions); // print(e.message); // } // bilgiler=null; // return null; // } // } // } guncellendiResim() async { resimZamanEtiket.update((val) => DateTime.now()); // update(); } List intersection(Iterable> iterables) { return iterables.map((e) => e.toSet()).reduce((a, b) => a.intersection(b)).toList(); } bool yetkiVarmi(ytk) { if (ytk is String) { return bilgiler?.value.yetkiler?.contains(ytk) == true; } else if (ytk is List) { if (ytk.isEmpty) return true; return intersection([bilgiler?.value.yetkiler ?? [], ytk]).isEmpty != true; } else { return false; } } }