import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter_application_1/Project/Admin/Returned.dart';
const Color aColor = Color.fromARGB(255, 0, 0, 0);
const Color bColor = Color.fromARGB(255, 255, 255, 255);
const Color cColor = Color.fromRGBO(93, 176, 116, 1);
class conAdR extends StatefulWidget {
final String name1;
final String categoryName1;
const conAdR({Key? key, required this.name1, required this.categoryName1})
: super(key: key);
@override
State<conAdR> createState() => _conAdRState();
}
class _conAdRState extends State<conAdR> {
@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: StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection("Categories")
.doc('pnVca0ijTvmowHmN8cXq')
.collection(widget.categoryName1)
.snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
final docs = snapshot.data!.docs;
final matchingDocs = docs.where((doc) =>
doc["Asset_Description"] == widget.name1.toString()).toList();
if (matchingDocs.isEmpty) {
return const SizedBox.shrink();
}
final matchingDoc = matchingDocs.first;
return Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.check_circle_outline,
size: 100,
color: cColor,
),
Row(
children: const [
Spacer(),
Text(
"Order Confirmed!",
style: TextStyle(
fontSize: 30, fontWeight: FontWeight.w900),
),
Spacer(),
],
),
const SizedBox(
height: 15,
),
Row(
children: const [
Spacer(),
Text(
"You confirmed order Name : ",
style: TextStyle(
fontSize: 15, fontWeight: FontWeight.w700),
),
Spacer(),
],
),
Row(
children: [
const Spacer(),
Text(
"${widget.name1}",
style: const TextStyle(
fontSize: 15, fontWeight: FontWeight.w700),
),
const Spacer(),
],
),
const SizedBox(
height: 10,
),
Row(
children: const [
Spacer(),
Text(
"Update Status!",
style: TextStyle(
fontSize: 15, fontWeight: FontWeight.w600),
),
Spacer(),
],
),
const SizedBox(
height: 30,
),
Row(
children: [
const Spacer(),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: cColor,
),
onPressed: () {
var data = {'Status': '0'};
FirebaseFirestore.instance
.collection('Categories')
.doc('pnVca0ijTvmowHmN8cXq')
.collection(widget.categoryName1)
.doc(matchingDoc.id)
.update(data)
.then(
(value) => debugPrint('Updating done!'),
onError: (e) => debugPrint('Error $e'),
);
Navigator.push(
context,
MaterialPageRoute(
builder: ((context) => const ReProject())),
);
},
child: const Text('Ok'),
),
const Spacer(),
],
),
],
),
);
} else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else {
return const CircularProgressIndicator();
}
},
),
),
);
}
}