152 lines
5.6 KiB
Dart
152 lines
5.6 KiB
Dart
import 'package:cheminova/widgets/inventory_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 'package:cheminova/widgets/my_drawer.dart';
|
|
import '../../controller/inventory_management_controller.dart';
|
|
import '../../models/InventoryManagementResponse.dart';
|
|
|
|
class InventoryManagementScreen extends StatefulWidget {
|
|
const InventoryManagementScreen({super.key});
|
|
|
|
@override
|
|
State<InventoryManagementScreen> createState() =>
|
|
_InventoryManagementScreenState();
|
|
}
|
|
|
|
class _InventoryManagementScreenState extends State<InventoryManagementScreen> {
|
|
late Future<InventoryManagementResponse> _productsFuture;
|
|
|
|
final InventoryManagementController _controller =
|
|
Get.put(InventoryManagementController());
|
|
|
|
final List<String> _filterList = [
|
|
"Category",
|
|
"Price Range",
|
|
"Availability",
|
|
];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_productsFuture = _controller.getProducts();
|
|
}
|
|
|
|
@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("Inventory Management"),
|
|
),
|
|
drawer: const MyDrawer(),
|
|
body: Stack(
|
|
fit: StackFit.expand,
|
|
children: [
|
|
Image.asset(
|
|
'assets/images/image_1.png',
|
|
fit: BoxFit.cover,
|
|
),
|
|
SafeArea(
|
|
child: Column(
|
|
children: [
|
|
SizedBox(height: Get.height * 0.01), // Reduced top spacing
|
|
Card(
|
|
margin: const EdgeInsets.symmetric(horizontal: 18),
|
|
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,
|
|
children: [
|
|
SizedBox(
|
|
height: Get.height * 0.05,
|
|
child: ListView.builder(
|
|
shrinkWrap: true,
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: _filterList.length,
|
|
itemBuilder: (context, index) => Padding(
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 4),
|
|
child: Chip(
|
|
label: Text(
|
|
_filterList[index],
|
|
style: GoogleFonts.roboto(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: Get.height * 0.75, // Increased height here
|
|
child: FutureBuilder<InventoryManagementResponse>(
|
|
future: _productsFuture,
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState ==
|
|
ConnectionState.waiting) {
|
|
return const Center(
|
|
child: CircularProgressIndicator());
|
|
} else if (snapshot.hasError) {
|
|
return Center(
|
|
child: Text('Error: ${snapshot.error}'));
|
|
} else if (snapshot.hasData) {
|
|
final products = snapshot.data!.products ?? [];
|
|
return ListView.builder(
|
|
padding: EdgeInsets.zero,
|
|
shrinkWrap: true,
|
|
itemCount: products.length,
|
|
itemBuilder: (context, index) {
|
|
final data = products[index];
|
|
return InventoryProductCard(product: data);
|
|
},
|
|
);
|
|
} else {
|
|
return const Center(
|
|
child: Text('No products found'));
|
|
}
|
|
},
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |