update
This commit is contained in:
parent
ee1884790a
commit
f71cb96421
5 changed files with 155 additions and 125 deletions
|
|
@ -9,6 +9,7 @@ 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';
|
||||
|
||||
class AddGenericsPage extends StatefulWidget {
|
||||
const AddGenericsPage({super.key});
|
||||
|
|
@ -23,6 +24,7 @@ class AddGenericsPageState extends State<AddGenericsPage> {
|
|||
final _refGenericNames = RefGenericNames();
|
||||
final _nameController = TextEditingController();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
bool _isVisible = false;
|
||||
|
||||
late List _categoryList = [];
|
||||
late String _selectedCategory = '';
|
||||
|
|
@ -54,35 +56,50 @@ class AddGenericsPageState extends State<AddGenericsPage> {
|
|||
_categoryList = [];
|
||||
_selectedCategory = '';
|
||||
_categoryUUID = '';
|
||||
_isVisible = false;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: PageBackgroundWidget(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const Gap(120),
|
||||
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
|
||||
const Gap(32),
|
||||
const TextWidget(text: 'Add Generics'),
|
||||
const Gap(16),
|
||||
Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
InputWidget(label: 'Name', controller: _nameController),
|
||||
const Gap(16),
|
||||
DropDownWidget(
|
||||
label: 'Category', list: _categoryList, listTitle: 'category_name', onChanged: _updateCategory),
|
||||
const Gap(16),
|
||||
ButtonWidget(text: 'Add', onPressed: saveGeneric)
|
||||
],
|
||||
))
|
||||
],
|
||||
)),
|
||||
body: VisibilityDetector(
|
||||
key: Key('AddGenericsPage'),
|
||||
onVisibilityChanged: (visibilityInfo) {
|
||||
if (visibilityInfo.visibleFraction > 0.5 && !_isVisible) {
|
||||
setState(() {
|
||||
_isVisible = true;
|
||||
autoRun();
|
||||
});
|
||||
}
|
||||
},
|
||||
child: PageBackgroundWidget(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const Gap(120),
|
||||
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
|
||||
const Gap(32),
|
||||
const TextWidget(text: 'Add Generics'),
|
||||
const Gap(16),
|
||||
Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
InputWidget(label: 'Name', controller: _nameController),
|
||||
const Gap(16),
|
||||
DropDownWidget(
|
||||
label: 'Category',
|
||||
list: _categoryList,
|
||||
listTitle: 'category_name',
|
||||
onChanged: _updateCategory),
|
||||
const Gap(16),
|
||||
ButtonWidget(text: 'Add', onPressed: saveGeneric)
|
||||
],
|
||||
))
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue