update
This commit is contained in:
parent
bac0d0da5b
commit
478b8e70f1
15 changed files with 374 additions and 148 deletions
|
|
@ -1,13 +1,18 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:pharmacy_mobile/tables/ref_medicines.dart';
|
||||
import 'package:pharmacy_mobile/tables/stocks.dart';
|
||||
import 'package:pharmacy_mobile/tables/storage.dart';
|
||||
import 'package:pharmacy_mobile/widgets/customer_pagebackground_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/customer_title_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/indicator_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/input_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/item_card_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
|
||||
class CustomerSearchPage extends StatefulWidget {
|
||||
const CustomerSearchPage({super.key});
|
||||
|
|
@ -19,10 +24,12 @@ class CustomerSearchPage extends StatefulWidget {
|
|||
class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
||||
final _searchController = TextEditingController();
|
||||
final _storage = Storage();
|
||||
final _refMedicines = RefMedicines();
|
||||
final _stocks = Stocks();
|
||||
// final _refMedicines = RefMedicines();
|
||||
late String imageUrl = '';
|
||||
late List _stockList = [];
|
||||
late List _medicinesList = [];
|
||||
|
||||
Future<void> _getURL() async {
|
||||
final image = await _storage.getPublicURL('ref_medicines_images', 'a3e430fe-86c1-4d46-9c6a-aed2dae57fef.webp');
|
||||
|
|
@ -33,7 +40,10 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
|
||||
Future<void> _getAllStocks() async {
|
||||
_stockList = await _stocks.getList();
|
||||
log(_stockList.toString());
|
||||
}
|
||||
|
||||
Future<void> _getAllMedicines() async {
|
||||
_medicinesList = await _refMedicines.getList();
|
||||
}
|
||||
|
||||
// void getURLs() async {
|
||||
|
|
@ -58,6 +68,7 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
|
||||
void autoRun() async {
|
||||
await _getAllStocks();
|
||||
await _getAllMedicines();
|
||||
await _getURL();
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +92,7 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
|
||||
return Scaffold(
|
||||
body: CustomerPagebackgroundWidget(
|
||||
height: MediaQuery.of(context).size.height + 350,
|
||||
height: MediaQuery.of(context).size.height + 600,
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
|
|
@ -102,37 +113,164 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
),
|
||||
),
|
||||
const Gap(32),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height + 110,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: List.generate(_stockList.length, (index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// ToggleSwitch(
|
||||
// fontSize: 12,
|
||||
// minWidth: 64,
|
||||
// minHeight: 32,
|
||||
// initialLabelIndex: 1,
|
||||
// cornerRadius: 20,
|
||||
// activeFgColor: Colors.white,
|
||||
// inactiveBgColor: const Color.fromRGBO(81, 81, 81, 1),
|
||||
// inactiveFgColor: const Color.fromRGBO(177, 175, 175, 1),
|
||||
// totalSwitches: 2,
|
||||
// labels: ['All', 'Stocks'],
|
||||
// activeBgColors: [
|
||||
// [const Color.fromRGBO(40, 112, 143, 1)],
|
||||
// [const Color.fromRGBO(40, 112, 143, 1)],
|
||||
// ],
|
||||
// // onToggle: (index) {
|
||||
// // print('switched to: $index');
|
||||
// // },
|
||||
// ),
|
||||
// const Gap(8)
|
||||
// ],
|
||||
// ),
|
||||
const IndicatorWidget(text: 'All Stocks'),
|
||||
const Gap(8),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
if (imageUrl.isEmpty)
|
||||
Row(
|
||||
children: [
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
text: 'item[medicine_name]',
|
||||
price: 123,
|
||||
quantity: 123,
|
||||
isLoading: true,
|
||||
),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
price: 20,
|
||||
quantity: 85,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
text: 'item[medicine_name]',
|
||||
price: 123,
|
||||
quantity: 123,
|
||||
isLoading: true,
|
||||
),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'item[medicine_name]',
|
||||
price: 123,
|
||||
quantity: 123,
|
||||
isLoading: true,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
else
|
||||
for (var item in _stockList)
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: item['medicine_name'].toString(),
|
||||
price: item['price'].toDouble(),
|
||||
quantity: item['quantity'].toDouble(),
|
||||
isLoading: false,
|
||||
),
|
||||
],
|
||||
)),
|
||||
const Gap(16),
|
||||
const IndicatorWidget(text: 'For Fever'),
|
||||
const Gap(8),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
],
|
||||
)),
|
||||
const Gap(16),
|
||||
const IndicatorWidget(text: 'For Headaches'),
|
||||
const Gap(8),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
],
|
||||
)),
|
||||
const Gap(16),
|
||||
const IndicatorWidget(text: 'For Colds and Coughes'),
|
||||
const Gap(8),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
)
|
||||
],
|
||||
|
|
|
|||
|
|
@ -4,17 +4,49 @@ class RefMedicines {
|
|||
final SupabaseClient _supabase = Supabase.instance.client;
|
||||
|
||||
Future<List> getList() async {
|
||||
List<Map<String, dynamic>> medicineData = [];
|
||||
|
||||
try {
|
||||
final data = await _supabase
|
||||
.from('ref_medicines')
|
||||
.select('medicine_name, ref_manufactorers(manufactorer_name)')
|
||||
.select('medicine_name, ref_manufacturers(manufacturer_name)')
|
||||
.order('medicine_name', ascending: true);
|
||||
return data.toList();
|
||||
|
||||
for (var item in data) {
|
||||
medicineData.add({
|
||||
'medicine_name': item['medicine_name'],
|
||||
'manufacturer_name': item['ref_manufacturers']['manufacturer_name'],
|
||||
});
|
||||
}
|
||||
|
||||
return medicineData;
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// Future<List> getListAsStocks() async {
|
||||
// List<Map<String, dynamic>> medicineData = [];
|
||||
|
||||
// try {
|
||||
// final data = await _supabase
|
||||
// .from('ref_medicines')
|
||||
// .select('medicine_name, stocks(manufactorer_name)')
|
||||
// .order('medicine_name', ascending: true);
|
||||
|
||||
// for (var item in data) {
|
||||
// medicineData.add({
|
||||
// 'medicine_name': item['medicine_name'],
|
||||
// 'manufacturer_name': item['ref_manufactorers']['manufactorer_name'],
|
||||
// });
|
||||
// }
|
||||
|
||||
// return medicineData;
|
||||
// } catch (e) {
|
||||
// return [];
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<List> getListWithUUID() async {
|
||||
try {
|
||||
final data = await _supabase
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class Stocks {
|
|||
for (var item in data) {
|
||||
stockData.add({
|
||||
'medicine_name': item['ref_medicines']['medicine_name'],
|
||||
'quantity': item['quantity'].toString(),
|
||||
'quantity': item['quantity'],
|
||||
'expiration_date': item['expiration_date'],
|
||||
'price': item['price'],
|
||||
});
|
||||
|
|
|
|||
31
lib/widgets/indicator_widget.dart
Normal file
31
lib/widgets/indicator_widget.dart
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
|
||||
class IndicatorWidget extends StatelessWidget {
|
||||
final String text;
|
||||
final Color? color;
|
||||
const IndicatorWidget({super.key, required this.text, this.color});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
height: 24,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: color ?? const Color.fromRGBO(249, 249, 249, 1), width: 1),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
color: color ?? const Color.fromRGBO(249, 249, 249, 1)),
|
||||
alignment: Alignment.center, // Center the text within the container
|
||||
child: TextWidget(
|
||||
text: text,
|
||||
size: 12,
|
||||
color: const Color.fromRGBO(0, 0, 0, 1),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -38,30 +38,46 @@ class ItemCardWidget extends StatelessWidget {
|
|||
const Gap(8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextWidget(
|
||||
text: text,
|
||||
size: 10,
|
||||
color: const Color.fromRGBO(0, 0, 0, 1),
|
||||
bold: true,
|
||||
),
|
||||
TextWidget(
|
||||
text: text,
|
||||
size: 16,
|
||||
color: Colors.black,
|
||||
)
|
||||
],
|
||||
),
|
||||
const Gap(92),
|
||||
TextWidget(
|
||||
text: quantity.toStringAsFixed(0),
|
||||
size: 12,
|
||||
color: const Color.fromRGBO(39, 39, 39, 1),
|
||||
)
|
||||
]),
|
||||
child: SizedBox(
|
||||
width: imageSize * 0.9,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextWidget(
|
||||
text: text,
|
||||
size: 8,
|
||||
color: const Color.fromRGBO(0, 0, 0, 1),
|
||||
bold: true,
|
||||
),
|
||||
TextWidget(
|
||||
text: text,
|
||||
size: 12,
|
||||
color: Colors.black,
|
||||
)
|
||||
],
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: quantity > 20
|
||||
? const Color.fromRGBO(254, 160, 44, 1)
|
||||
: const Color.fromRGBO(136, 136, 136, 1),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: const Color.fromRGBO(217, 217, 217, 1)),
|
||||
),
|
||||
child: TextWidget(
|
||||
text: quantity.toStringAsFixed(0),
|
||||
size: 12,
|
||||
color:
|
||||
quantity > 20 ? const Color.fromRGBO(0, 0, 0, 1) : const Color.fromRGBO(255, 255, 255, 1),
|
||||
),
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
const Gap(8),
|
||||
Padding(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue