pd-android-app/lib/screens/product/product_detail_screen.dart
saritabirare 174d7afa99 1)get all Place Order api integration done
2) single Place order api integration done
3) Refresh inidicator added
4)Caps Functionality added
2024-09-11 12:24:48 +05:30

223 lines
8.8 KiB
Dart

import 'package:cheminova/models/product_model.dart';
import 'package:cheminova/models/product_model1.dart';
import 'package:cheminova/screens/order/checkout_screen.dart';
import 'package:cheminova/utils/show_snackbar.dart';
import 'package:cheminova/widgets/my_drawer.dart';
import 'package:cheminova/widgets/product_card.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import '../../controller/cart_controller.dart';
import 'cart_screen.dart';
class ProductDetailScreen extends StatefulWidget {
Product? productModel;
ProductModel? product;
ProductDetailScreen({super.key, this.product, this.productModel});
@override
State<ProductDetailScreen> createState() => _ProductDetailScreenState();
}
class _ProductDetailScreenState extends State<ProductDetailScreen> {
final CartController _cartController = Get.put(CartController());
String capitalizeFirstLetter(String text) {
if (text.isEmpty) return text;
return text[0].toUpperCase() + text.substring(1).toLowerCase();
}
@override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.transparent,
elevation: 0,
leading: Builder(
builder: (context) {
return GestureDetector(
onTap: () => Scaffold.of(context).openDrawer(),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: SvgPicture.asset(
'assets/svg/menu.svg',
),
),
);
},
),
actions: [
GestureDetector(
onTap: () => Get.back(),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SvgPicture.asset(
'assets/svg/back_arrow.svg',
),
),
),
],
title: const Text(
"Product Detail",
),
),
drawer: const MyDrawer(),
body: Stack(
fit: StackFit.expand,
children: [
Image.asset(
'assets/images/image_1.png',
fit: BoxFit.cover,
),
SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
height: Get.height * 0.02,
),
Card(
margin: const EdgeInsets.symmetric(horizontal: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(19),
side: const BorderSide(color: Color(0xFFFDFDFD)),
),
color: const Color(0xFFB4D1E5).withOpacity(0.9),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: Get.height * 0.4,
width: Get.width * 0.8,
decoration: BoxDecoration(
border: Border.all(
width: 4,
color: Colors.white,
),
borderRadius: BorderRadius.circular(15),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.asset("assets/images/product.png", fit: BoxFit.cover,),
// Image.asset(
// widget.product.image,
// fit: BoxFit.cover,
// ),
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Product Name ",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 16),),
Text(
capitalizeFirstLetter(widget.productModel!.name),
style: GoogleFonts.roboto(
fontSize: 16,
// fontWeight: FontWeight.w600,
color: Colors.black,
),
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Price ",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold),),
Text(
"${widget.productModel!.price.toString()}",
style: GoogleFonts.roboto(
fontSize: 16,
//fontWeight: FontWeight.w800,
color: Colors.black,
),
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Category ",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 16),),
Text(
capitalizeFirstLetter(widget.productModel!.category!.categoryName),
style: GoogleFonts.roboto(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black,
),
),
],
),
),
const SizedBox(height: 8),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: [
Text("Description",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 16)),
Text(
capitalizeFirstLetter(widget.productModel!.description),
style: GoogleFonts.roboto(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black,
),
),
],
),
),
],
),
),
),
SizedBox(height: Get.height * 0.04),
SizedBox(
width: Get.width * 0.9,
height: Get.height * 0.06,
child: ElevatedButton(
onPressed: () {
// Pass the product data to the CartScreen
_cartController.addToCart(widget.productModel!);
showSnackbar("Product successfully added to your cart");
},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: const Color(0xFF00784C),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
child: Text(
"Add To Cart",
style: GoogleFonts.roboto(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
),
],
),
),
],
),
);
}
}