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,
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
)
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue