import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:flutter_application_1/Project/Admin/conB.dart'; const Color aColor = Color.fromARGB(219, 58, 168, 50); const Color cColor = Color.fromARGB(246, 255, 255, 246); const Color bColor = Color.fromARGB(153, 28, 240, 187); class inB extends StatefulWidget { final String ema; final String an; final String rd; final String bd; const inB({ Key? key, required this.ema, required this.an, required this.rd, required this.bd, }) : super(key: key); @override State createState() => _inBState(); } class _inBState extends State { @override Widget build(BuildContext context) { return Scaffold( body: Container( constraints: const BoxConstraints.expand(), decoration: const BoxDecoration( image: DecorationImage( image: NetworkImage( "https://i.pinimg.com/originals/77/7b/07/777b07a784b619eb9840734261133cbd.jpg"), fit: BoxFit.cover, ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: StreamBuilder( stream: FirebaseFirestore.instance.collection("products").snapshots(), builder: (context, snapshot) { if (snapshot.hasData) { final matchingDocs = snapshot.data!.docs.where((doc) => doc["Asset_Description"] == widget.an.toString()).toList(); if (matchingDocs.isEmpty) { return const SizedBox.shrink(); } final matchingDoc = matchingDocs.first; return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( children: const [ Spacer(), Text( 'Please Confirm Borrowed Item', style: TextStyle(fontSize: 20, fontWeight: FontWeight.w900), ), Spacer(), ], ), const SizedBox(height: 10,), Row( children: [ const Spacer(), const Text( 'Item name : ', style: TextStyle(fontSize: 15, fontWeight: FontWeight.w900), ), Text( widget.an, style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w900), ), const Spacer(), ], ), const SizedBox(height: 20), ElevatedButton( style: ElevatedButton.styleFrom(backgroundColor: aColor), onPressed: () { var data = { 'EmailUserReq': widget.ema, 'BorrowingDay': widget.bd, 'ReturnDay': widget.rd, 'Status': '1', }; FirebaseFirestore.instance .collection('products') .doc(matchingDoc.id) .update(data) .then( (value) => debugPrint('Updating done!'), onError: (e) => debugPrint('Error $e'), ); Navigator.push( context, MaterialPageRoute( builder: ((context) => conAdB( name: widget.an.toString(), categoryName: matchingDoc["cat"], )), ), ); }, child: const Text('Ok'), ), ], ), ); } else if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { return const CircularProgressIndicator(); } }, ), ), ), ); } }