import 'package:bson/bson.dart'; import 'package:dio/dio.dart'; import 'package:fikoyt_hmi_pano/apps/pages/screen_1/controller/screen.controller.dart'; import 'package:fikoyt_ui/core/fiko_request.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart' hide FormData, MultipartFile; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; class UserWidget extends StatefulWidget { const UserWidget({super.key}); @override _UserWidgetState createState() => _UserWidgetState(); } class _UserWidgetState extends State { late final Screen1Controller screenLogic; @override void initState() { screenLogic = Get.put(Screen1Controller()); super.initState(); } @override Widget build(BuildContext context) { return Container( constraints: const BoxConstraints(maxWidth: double.infinity, maxHeight: double.infinity), width: 350, // height: height ?? double.infinity, // height: 450, // margin: const EdgeInsets.all(2.0), padding: const EdgeInsets.all(5.0), clipBehavior: Clip.none, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.0), border: Border.all( color: Colors.grey.shade300, width: 1, style: BorderStyle.solid, ), ), child: Column( children: [ Row( children: [ FikoYTButton( text: "👑", onPressed: () {}, ), Expanded( child: FikoYTButton( text: "FikoYT Kart Okuyucu", tema: FikoYTButtonTheme(textColor: Theme.of(context).extension()?.textColor), ), ), FikoYTButton( text: "⚙️", onPressed: () {}, ), ], ), Divider( height: 14, ), FikoYTRippleWave( color: Colors.green.shade400, repeat: true, waveCount: 4, rectRadius: 16, // delay: 2500.ms, shape: RippleShape.circle, child: Center( child: Stack( alignment: Alignment.center, children: [ CircleAvatar( backgroundColor: Colors.green.shade700, radius: (54) + 10.0, //CircleAvatar ), CircleAvatar( backgroundColor: Theme.of(context).extension()?.backgroundColor, radius: 54, child: ClipOval( child: Stack( alignment: Alignment.center, children: [ Positioned( top: -3, left: -3, right: -3, bottom: -3, child: Obx( () => Image.network( "https://fikoyt.com:3000/fapiv1/fikoyt.com.FikoYT.sistem.kullanici.${FikoYTEvent('FikoYT.uyar.nfc.kullanici').$value.value?["_id"]}.profilResmi?boyut=480x?&t=${FikoYTEvent('FikoYT.uyar.resim.cache.value').$value.value}", fit: BoxFit.cover, loadingBuilder: (context, child, loadingProgress) { if (loadingProgress == null) return child; return Center( child: CircularProgressIndicator( value: loadingProgress.expectedTotalBytes != null ? loadingProgress.cumulativeBytesLoaded / (loadingProgress.expectedTotalBytes ?? 0).toDouble() : null, ), ); }, ), ), ), ], ), ), ), ], ), //CircleAvatar ), ), SizedBox( height: 10, ), Obx( () => FikoYTButton( text: "${FikoYTEvent('FikoYT.uyar.nfc.kullanici').$value.value?["isim"] ?? ''} ${FikoYTEvent('FikoYT.uyar.nfc.kullanici').$value.value?["soyIsim"] ?? ''}", tema: FikoYTButtonTheme( textAlign: TextAlign.center, fontSize: 18, fontWeight: FontWeight.bold, textColor: Theme.of(context).extension()?.backgroundColor, textStrokeColor: Theme.of(context).extension()?.textColor, textStrokeWidth: 2, ), onPressed: () async { final ImagePicker picker = ImagePicker(); // Pick an image. var image = await picker.pickImage(source: ImageSource.gallery); // print(toJson()); var formData = FormData(); if (image != null) { var resimId = ObjectId().oid; formData.files.add(MapEntry(resimId, MultipartFile.fromFileSync(image.path, filename: resimId))); } formData.fields.add(MapEntry("req_body", "{}")); istek_yap(command: "FikoYT.sistem.kullanici.${FikoYTEvent('FikoYT.uyar.nfc.kullanici').value?["_id"]}.profilResmi.degistir", parameters: formData).listen((sonuc) async { // print("${sonuc.type} ${sonuc.requestProgress?.percent} ${sonuc.requestProgress?.total}"); if (sonuc.type == FikoYTRequestType.RESPONDED) { await Future.delayed(Duration(seconds: 1)); await screenLogic.cacheDegistir(); } }).onError((hata) async {}); }, ), ), FikoYTButton( text: "Cnc Operatörü", tema: FikoYTButtonTheme( textAlign: TextAlign.center, fontSize: 14, fontWeight: FontWeight.bold, textColor: Theme.of(context).extension()?.textColor, // textStrokeColor: Theme.of(context).extension()?.textColor, textStrokeWidth: 0, ), ), Obx( () => AnimatedFikoYTButton1( text: "Kart Id: ${FikoYTEvent('FikoYT.uyar.cardId.value').value ?? ''}", tema: FikoYTButtonTheme( textAlign: TextAlign.center, fontSize: 9, fontWeight: FontWeight.bold, textColor: Theme.of(context).extension()?.textColor, // textStrokeColor: Theme.of(context).extension()?.textColor, textStrokeWidth: 0, ), // onPressed: () { // FikoYTEvent("FikoYT.uyar.cardId.value").value = Random.secure().nextInt(1500).toString(); // }, ), ), Spacer(), Container( alignment: Alignment.centerLeft, padding: const EdgeInsets.all(1), margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10), decoration: BoxDecoration( border: Border.all(color: Colors.grey.shade300), borderRadius: BorderRadius.circular(15), color: Colors.white.withAlpha(100), // boxShadow: [ // BoxShadow( // color: Theme.of(context).extension()?.shadowColor?.withAlpha(100) ?? Colors.black.withAlpha(100), //New // blurRadius: 4.0, // offset: Offset(4, 4)) // ], ), child: SizedBox( height: 18.0, child: ShaderMask( shaderCallback: (Rect rect) { return const LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, colors: [Colors.purple, Colors.transparent, Colors.transparent, Colors.purple], stops: [0.0, 0.1, 0.9, 1.0], // 10% purple, 80% transparent, 10% purple ).createShader(rect); }, blendMode: BlendMode.dstOut, child: SingleChildScrollView( scrollDirection: Axis.horizontal, physics: const BouncingScrollPhysics(), child: Row( children: [ FikoYTButton( text: "🏠 Ana Sayfa", tema: Theme.of(context).extension()?.copyWith( fontSize: 10, textAlign: TextAlign.start, edgePadding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 5), textStrokeWidth: 0, textColor: Colors.black87, textStrokeColor: Colors.transparent, ), onPressed: () {}, ), FikoYTButton( text: "❓ Bilgilerim", tema: Theme.of(context).extension()?.copyWith( fontSize: 10, textAlign: TextAlign.start, edgePadding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 5), textStrokeWidth: 0, textColor: Colors.black87, textStrokeColor: Colors.transparent, ), onPressed: () async {}, ), FikoYTButton( text: "📈 İstatistiklerim", tema: Theme.of(context).extension()?.copyWith( fontSize: 10, textAlign: TextAlign.start, edgePadding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 5), textStrokeWidth: 0, textColor: Colors.black87, textStrokeColor: Colors.transparent, ), onPressed: () async {}, ), FikoYTButton( text: "📂 Dosyalarım", tema: Theme.of(context).extension()?.copyWith( fontSize: 10, textAlign: TextAlign.start, edgePadding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 5), textStrokeWidth: 0, textColor: Colors.black87, textStrokeColor: Colors.transparent, ), onPressed: () async {}, ), FikoYTButton( text: "🛡️ Güvenlik", tema: Theme.of(context).extension()?.copyWith( fontSize: 10, textAlign: TextAlign.start, edgePadding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 5), textStrokeWidth: 0, textColor: Colors.black87, textStrokeColor: Colors.transparent, ), onPressed: () async {}, onLongPress: () {}, ), ], ), ), ), ), ) ], ), ); } }