update
This commit is contained in:
parent
47a2d34933
commit
4586256032
9 changed files with 246 additions and 154 deletions
|
|
@ -10,7 +10,6 @@ import 'package:pharmacy_mobile/widgets/input_widget.dart';
|
|||
import 'package:pharmacy_mobile/widgets/page_background_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/title_widget.dart';
|
||||
import 'package:visibility_detector/visibility_detector.dart'; // Import this package
|
||||
|
||||
// import 'package:intl/intl.dart';
|
||||
|
||||
|
|
@ -32,7 +31,6 @@ class _AddStockPageState extends State<AddStockPage> {
|
|||
late List _medicineList = [];
|
||||
late String _selectedMedicine = '';
|
||||
late DateTime selectedDate = DateTime.now();
|
||||
bool _isVisible = false;
|
||||
|
||||
void autoRun() async {
|
||||
_medicineList = await _refMedicines.getList();
|
||||
|
|
@ -63,61 +61,49 @@ class _AddStockPageState extends State<AddStockPage> {
|
|||
_selectedMedicine = '';
|
||||
_quantityController.dispose();
|
||||
_dateController.dispose();
|
||||
_isVisible = false;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: VisibilityDetector(
|
||||
key: Key('AddStockPage'),
|
||||
onVisibilityChanged: (visibilityInfo) {
|
||||
if (visibilityInfo.visibleFraction > 0.5 && !_isVisible) {
|
||||
setState(() {
|
||||
_isVisible = true;
|
||||
autoRun();
|
||||
});
|
||||
}
|
||||
},
|
||||
child: PageBackgroundWidget(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const Gap(96),
|
||||
const TitleWidget(firstTextSize: 20, secondTextSize: 32),
|
||||
const Gap(32),
|
||||
const TextWidget(text: 'Add Stock'),
|
||||
const Gap(16),
|
||||
FormBorderWidget(
|
||||
color: 'green',
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
DropDownWidget(
|
||||
label: 'Medicine Name',
|
||||
list: _medicineList,
|
||||
listTitle: 'medicine_name',
|
||||
onChanged: _updateMedicine),
|
||||
const Gap(16),
|
||||
InputWidget(label: 'Quantity', controller: _quantityController),
|
||||
const Gap(16),
|
||||
DatePickerWidget(
|
||||
label: 'Date Expiration',
|
||||
controller: _dateController,
|
||||
value: selectedDate,
|
||||
),
|
||||
const Gap(16),
|
||||
ButtonWidget(text: 'Add Stock', onPressed: saveStock)
|
||||
],
|
||||
),
|
||||
body: PageBackgroundWidget(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const Gap(96),
|
||||
const TitleWidget(firstTextSize: 20, secondTextSize: 32),
|
||||
const Gap(32),
|
||||
const TextWidget(text: 'Add Stock'),
|
||||
const Gap(16),
|
||||
FormBorderWidget(
|
||||
color: 'green',
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
DropDownWidget(
|
||||
label: 'Medicine Name',
|
||||
list: _medicineList,
|
||||
listTitle: 'medicine_name',
|
||||
onChanged: _updateMedicine),
|
||||
const Gap(16),
|
||||
InputWidget(label: 'Quantity', controller: _quantityController),
|
||||
const Gap(16),
|
||||
DatePickerWidget(
|
||||
label: 'Date Expiration',
|
||||
controller: _dateController,
|
||||
value: selectedDate,
|
||||
),
|
||||
const Gap(16),
|
||||
ButtonWidget(text: 'Add Stock', onPressed: saveStock)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue