import 'package:fikoyt_sistem/apps/uyar/admin/kullanicilar/kullanici_ekle_form.dart'; import 'package:fikoyt_sistem/apps/uyar/core/base_sol_menu.dart'; import 'package:fikoyt_sistem/apps/uyar/core/services/uyar_service.dart'; import 'package:fikoyt_sistem/main.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:fikoyt_ui/ui/dialogs/fiko_dialog_ayarlari.dart'; import 'package:fikoyt_ui/ui/fikoyt_card.dart'; import 'package:flutter/material.dart'; import 'package:gauge_indicator/gauge_indicator.dart'; class AdminKullanicilar extends StatefulWidget { AdminKullanicilar({Key? key}) : super(key: key); @override State createState() => _AdminKullanicilarState(); } class _AdminKullanicilarState extends State { final UyarService uyarServis = Get.put(UyarService()); /** */ var $baglantiToplamlarOlay; @override void initState() { uyarServis.logicKullanici.toplamlariAl(); uyarServis.logicKullanici.kullanicilariAl(); $baglantiToplamlarOlay = FikoYTCoreService.socket.on("FikoYT.sistem.cihaz.bağlandı.toplamlar", (data) { uyarServis.logicKullanici.toplamlariAl(); }); super.initState(); } @override void dispose() { if ($baglantiToplamlarOlay != null) $baglantiToplamlarOlay(); super.dispose(); } @override Widget build(BuildContext context) { return Column( children: [ Center( child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 760), child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ // SizedBox(height: 22), FittedBox( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: [ ColorFiltered( colorFilter: const ColorFilter.mode(Colors.white, BlendMode.modulate), child: Image.asset("assets/uyar/arkadaslar.webp", height: 256), ), /** */ Center( child: FikoYTButton(text: "Kullanıcılar", tema: FikoYTButtonTheme(fontSize: 24)), ), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, spacing: 5, children: [ FikoYTButton( text: "🟢 Her şey normal görünüyor", tema: FikoYTButtonTheme(fontSize: 12, fontWeight: FontWeight.normal), ), Obx( () => FikoYTButton( text: "💎 ${uyarServis.logicKullanici.toplamlar.value?["soket_sayisi"] ?? 0} adet bağlantı kanalı var var", tema: FikoYTButtonTheme(fontSize: 12, fontWeight: FontWeight.normal), ), ), ], ), ], ), ), Wrap( spacing: 5, runSpacing: 5, children: [ FikoYTCard( theme: FikoYTCardTheme( elevation: 4, backgroundColor: Colors.white, borderColor: Colors.grey, padding: EdgeInsets.all(5), radius: 5, boxConstraints: BoxConstraints(maxWidth: 160), ), children: [ Center( child: Obx( () => FikoYTButton( text: "🧓 ${uyarServis.logicKullanici.toplamlar.value?["kullanici"] ?? 0}", tema: FikoYTButtonTheme(fontSize: 36, fontWeight: FontWeight.bold), ), ), ), Center( child: FikoYTButton( text: "Toplam Kullanıcı", tema: FikoYTButtonTheme( edgePadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), borderColor: Colors.transparent, fontWeight: FontWeight.bold, fontSize: 14, radius: 3.0, textColor: Colors.black45, ), ), ), ], ), FikoYTCard( theme: FikoYTCardTheme( elevation: 4, backgroundColor: Colors.white, borderColor: Colors.grey, padding: EdgeInsets.all(5), radius: 5, boxConstraints: BoxConstraints(maxWidth: 160), ), children: [ Center( child: Obx( () => FikoYTButton( text: "🛰️ ${uyarServis.logicKullanici.toplamlar.value?["aktif_kullanici"] ?? 0}", tema: FikoYTButtonTheme(fontSize: 36, fontWeight: FontWeight.bold), ), ), ), Center( child: FikoYTButton( text: "Online Kullanıcı", tema: FikoYTButtonTheme( edgePadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), borderColor: Colors.transparent, fontWeight: FontWeight.bold, fontSize: 14, radius: 3.0, textColor: Colors.black45, ), ), ), ], ), FikoYTCard( theme: FikoYTCardTheme( elevation: 4, backgroundColor: Colors.white, borderColor: Colors.grey, padding: EdgeInsets.all(5), radius: 5, boxConstraints: BoxConstraints(maxWidth: 160), ), children: [ Center( child: Obx( () => FikoYTButton( text: "🔌 ${uyarServis.logicKullanici.toplamlar.value?["deaktif_kullanici"] ?? 0}", tema: FikoYTButtonTheme(fontSize: 36, fontWeight: FontWeight.bold), ), ), ), Center( child: FikoYTButton( text: "Deaktif Kullanıcı", tema: FikoYTButtonTheme( edgePadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), borderColor: Colors.transparent, fontWeight: FontWeight.bold, fontSize: 14, radius: 3.0, textColor: Colors.black45, ), ), ), ], ), FikoYTCard( theme: FikoYTCardTheme( elevation: 4, backgroundColor: Colors.white, borderColor: Colors.grey, padding: EdgeInsets.all(5), radius: 5, boxConstraints: BoxConstraints(maxWidth: 160), ), children: [ Center( child: Obx( () => FikoYTButton( text: "💎 ${uyarServis.logicKullanici.toplamlar.value?["sistem_kullanici"] ?? 0}", tema: FikoYTButtonTheme(fontSize: 36, fontWeight: FontWeight.bold), ), ), ), Center( child: FikoYTButton( text: "Önemli Kullanıcı", tema: FikoYTButtonTheme( edgePadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), borderColor: Colors.transparent, fontWeight: FontWeight.bold, fontSize: 14, radius: 3.0, textColor: Colors.black45, ), ), ), ], ), ], ), SizedBox(height: 10), Row( spacing: 5, children: [ FikoYTButton(text: "Kullanıcı Listesi", tema: FikoYTButtonTheme(fontSize: 18)), Spacer(), FikoYTButton( text: "♻", tema: FikoYTButtonTheme( fontSize: 14, edgePadding: EdgeInsets.all(3), elevation: 4, radius: 15, backgroundColor: Colors.white, ), onPressed: () { uyarServis.logicKullanici.kullanicilariAl(); }, ), FikoYTButton( text: "➕", tema: FikoYTButtonTheme( fontSize: 14, edgePadding: EdgeInsets.all(3), elevation: 4, radius: 15, backgroundColor: Colors.white, ), onPressed: () { FikoYTCoreService.dialogGoster( context, FikoYTCard( theme: FikoYTCardTheme( elevation: 0, borderRadius: BorderRadius.circular(5), margin: EdgeInsets.all(10), padding: EdgeInsets.all(10), backgroundColor: Theme.of(context).extension()?.cardBackgroundColor, borderColor: Colors.grey.shade400, border: Border.all(color: Colors.grey.shade400), boxConstraints: BoxConstraints(maxWidth: 320), ), children: [KullaniciEkleForm()], ), FikoDialogAyarlari( arkaPlanaTiklanincaKapansin: true, baslik: "👤 Kullanıcı Ekle", // icerik: [ // ], ), ); }, ), ], ), Obx( () => Visibility( visible: uyarServis.logicKullanici.kullanicilar.isEmpty, child: Center( child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 360), child: FikoYTCard( theme: FikoYTCardTheme( elevation: 4, backgroundColor: Colors.white, borderColor: Colors.grey, padding: EdgeInsets.all(5), radius: 5, boxConstraints: BoxConstraints(maxWidth: 360), ), children: [ Center( child: FikoYTButton( text: "👤", tema: FikoYTButtonTheme(fontSize: 64, fontWeight: FontWeight.bold), ), ), Center( child: FikoYTButton( text: "Sisteminize Kayıtlı Hiç Kullanıcı Yok", tema: FikoYTButtonTheme(fontSize: 16, fontWeight: FontWeight.normal, textColor: Colors.black), ), ), Center( child: FikoYTButton( text: "➕ Hemen Ekle", tema: FikoYTButtonTheme( textColor: Colors.white, backgroundColor: Colors.blue.shade500, // fontWeight: FontWeight.w700, edgePadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), borderColor: Colors.transparent, elevation: 3, fontWeight: FontWeight.normal, fontSize: 14, radius: 3.0, ), onPressed: () { uyarServis.logicKullanici.kullanicilariAl(); }, ), ), ], ), ), ), ), ), Obx(() { uyarServis.logicKullanici.kullanicilar.value; return AnimatedSwitcher( duration: const Duration(milliseconds: 1000), child: (uyarServis.logicKullanici.listeIstek.isBusy.value) ? Center( child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 360), child: FikoYTCard( theme: FikoYTCardTheme( elevation: 0, backgroundColor: Colors.transparent, borderColor: Colors.transparent, padding: EdgeInsets.all(5), radius: 5, boxConstraints: BoxConstraints(maxWidth: 360), shadowColor: Colors.transparent, ), children: [ Center(child: CircularProgressIndicator()), Center( child: FikoYTButton( text: "Liste Alınıyor...", tema: FikoYTButtonTheme( fontSize: 16, fontWeight: FontWeight.normal, textColor: Colors.black, ), ), ), ], ), ), ) : Visibility( visible: uyarServis.logicKullanici.kullanicilar.isNotEmpty, child: Wrap( spacing: 5, runSpacing: 5, children: [ ...uyarServis.logicKullanici.kullanicilar.map((uye) { final String imageUrl = "https://fikoyt.com:9000/fapiv1/fikoyt.com.FikoYT.sistem.kullanici.${uye?['_id']?.toString()}.profilResmi?boyut=128x?&t=0.8143431303498987"; final String fullName = "${uye?['isim'] ?? ""} ${uye?['soyIsim'] ?? ""}"; final bool isSuperAdmin = ((uye?['yetkiler'] as List?) ?? []).contains( "Süper Yönetici", ); return FikoYTCard( theme: FikoYTCardTheme( elevation: 4, backgroundColor: Colors.white, borderColor: Colors.grey, padding: EdgeInsets.all(5), radius: 5, boxConstraints: BoxConstraints(maxWidth: 160, maxHeight: 170, minHeight: 150), ), children: [ Stack( alignment: Alignment.topLeft, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ FikoytOvalResim( resimUrl: imageUrl, tema: FikoYTOvalResimTheme(borderColor: Colors.blue, radius: 42, spacing: 7), ), Center( child: FikoYTButton( text: fullName, tema: FikoYTButtonTheme( fontSize: 12, fontWeight: FontWeight.w600, edgePadding: EdgeInsets.all(0), radius: 0, backgroundColor: Colors.transparent, textColor: Colors.black87, ), ), ), SizedBox( height: 36, child: SingleChildScrollView( scrollDirection: Axis.horizontal, physics: BouncingScrollPhysics(), child: Row( spacing: 2, children: [ if (isSuperAdmin) FikoYTButton( text: "👑", tema: FikoYTButtonTheme( fontSize: 14, edgePadding: EdgeInsets.all(3), radius: 5, backgroundColor: context.vRouter.url.startsWith( "/uyar/uye/kullanici/arkadaslar", ) ? Colors.white : Colors.transparent, ), onPressed: () { context.vRouter.to("/uyar/uye/kullanici/arkadaslar"); }, ), ], ), ), ), ], ), ], ), ], ); }).toList(), ], ), ), ); }), ], ), ), ), ), ), ], ); } }