update
This commit is contained in:
parent
ff619ac88a
commit
a76d3a0f35
3 changed files with 175 additions and 118 deletions
|
|
@ -1,6 +1,9 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:pharmacy_mobile/tables/ref_medicines.dart';
|
||||
import 'package:pharmacy_mobile/auth/auth_service.dart';
|
||||
import 'package:pharmacy_mobile/tables/cart.dart';
|
||||
import 'package:pharmacy_mobile/tables/stocks.dart';
|
||||
import 'package:pharmacy_mobile/tables/storage.dart';
|
||||
import 'package:pharmacy_mobile/widgets/customer_pagebackground_widget.dart';
|
||||
|
|
@ -18,12 +21,15 @@ class CustomerSearchPage extends StatefulWidget {
|
|||
|
||||
class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
||||
final _searchController = TextEditingController();
|
||||
final _authService = AuthService();
|
||||
final _storage = Storage();
|
||||
// final _refMedicines = RefMedicines();
|
||||
final _stocks = Stocks();
|
||||
final _carts = Carts();
|
||||
// final _refMedicines = RefMedicines();
|
||||
late String imageUrl = '';
|
||||
late List _stockList = [];
|
||||
late List _cartList = [];
|
||||
// late final List _medicinesList = [];
|
||||
|
||||
Future<void> _getURL() async {
|
||||
|
|
@ -37,6 +43,18 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
_stockList = await _stocks.getList();
|
||||
}
|
||||
|
||||
Future<String> _getCurrentUser() async {
|
||||
final result = _authService.getCurrentUser();
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
Future<void> _getCarts() async {
|
||||
final currentUser = await _getCurrentUser();
|
||||
log('currentUser: $currentUser');
|
||||
_cartList = await _carts.getCart(currentUser);
|
||||
log('cart: ${_cartList.toString()}');
|
||||
}
|
||||
|
||||
// Future<void> _getAllMedicines() async {
|
||||
// _medicinesList = await _refMedicines.getList();
|
||||
// }
|
||||
|
|
@ -63,6 +81,7 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
|
||||
void autoRun() async {
|
||||
await _getAllStocks();
|
||||
await _getCarts();
|
||||
// await _getAllMedicines();
|
||||
await _getURL();
|
||||
}
|
||||
|
|
@ -141,41 +160,41 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
const Row(
|
||||
children: [
|
||||
ItemCardWidget(
|
||||
imageUrl: 'imageUrl',
|
||||
text: 'item[medicine_name]',
|
||||
subtext: 'item[generic_name]',
|
||||
price: 123,
|
||||
quantity: 123,
|
||||
isLoading: true,
|
||||
),
|
||||
imageUrl: 'imageUrl',
|
||||
text: 'item[medicine_name]',
|
||||
subtext: 'item[generic_name]',
|
||||
price: 123,
|
||||
quantity: 123,
|
||||
isLoading: true,
|
||||
cart: 0),
|
||||
ItemCardWidget(
|
||||
imageUrl: 'imageUrl',
|
||||
text: 'item[medicine_name]',
|
||||
subtext: 'item[generic_name]',
|
||||
price: 123,
|
||||
quantity: 123,
|
||||
isLoading: true,
|
||||
),
|
||||
imageUrl: 'imageUrl',
|
||||
text: 'item[medicine_name]',
|
||||
subtext: 'item[generic_name]',
|
||||
price: 123,
|
||||
quantity: 123,
|
||||
isLoading: true,
|
||||
cart: 0),
|
||||
ItemCardWidget(
|
||||
imageUrl: 'imageUrl',
|
||||
text: 'item[medicine_name]',
|
||||
subtext: 'item[generic_name]',
|
||||
price: 123,
|
||||
quantity: 123,
|
||||
isLoading: true,
|
||||
)
|
||||
imageUrl: 'imageUrl',
|
||||
text: 'item[medicine_name]',
|
||||
subtext: 'item[generic_name]',
|
||||
price: 123,
|
||||
quantity: 123,
|
||||
isLoading: true,
|
||||
cart: 0)
|
||||
],
|
||||
)
|
||||
else
|
||||
for (var item in _stockList)
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: item['medicine_name'].toString(),
|
||||
subtext: item['generic_name'].toString(),
|
||||
price: item['price'].toDouble(),
|
||||
quantity: item['quantity'].toDouble(),
|
||||
isLoading: false,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: item['medicine_name'].toString(),
|
||||
subtext: item['generic_name'].toString(),
|
||||
price: item['price'].toDouble(),
|
||||
quantity: item['quantity'].toDouble(),
|
||||
isLoading: false,
|
||||
cart: 0),
|
||||
],
|
||||
)),
|
||||
const Gap(16),
|
||||
|
|
@ -186,29 +205,29 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
child: Row(
|
||||
children: [
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 0,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 0,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 2),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 0),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 0),
|
||||
],
|
||||
)),
|
||||
const Gap(16),
|
||||
|
|
@ -219,29 +238,29 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
child: Row(
|
||||
children: [
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 0),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 0),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 0),
|
||||
],
|
||||
)),
|
||||
const Gap(16),
|
||||
|
|
@ -252,29 +271,29 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
child: Row(
|
||||
children: [
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 0),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 0),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 0),
|
||||
],
|
||||
)),
|
||||
const Gap(16),
|
||||
|
|
@ -285,29 +304,29 @@ class _CustomerSearchPageState extends State<CustomerSearchPage> {
|
|||
child: Row(
|
||||
children: [
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 0),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 0),
|
||||
ItemCardWidget(
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
),
|
||||
imageUrl: imageUrl,
|
||||
text: 'sample',
|
||||
subtext: 'generic_name',
|
||||
price: 500,
|
||||
quantity: 15,
|
||||
isLoading: imageUrl.isEmpty,
|
||||
cart: 0),
|
||||
],
|
||||
)),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue