You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PatientApp-KKUMC/lib/pages/pharmacies/search_brands_page.dart

151 lines
6.3 KiB
Dart

import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/brand_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/input/text_field.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import '../Blood/new_text_Field.dart';
class SearchBrandsPage extends StatefulWidget {
@override
_SearchBrandsPageState createState() => _SearchBrandsPageState();
}
class _SearchBrandsPageState extends State<SearchBrandsPage> {
final textController = TextEditingController();
final _formKey = GlobalKey<FormState>();
String msg = '';
@override
Widget build(BuildContext context) {
ProjectViewModel projectProvider = Provider.of(context);
return BaseView<BrandsViewModel>(
onModelReady: (model) => model!.searchProducts(productName: ''),
builder: (BuildContext context, model, Widget? child) =>
PharmacyAppScaffold(
appBarTitle: TranslationBase.of(context).search,
isBottomBar: false,
isShowAppBar: true,
backgroundColor: Colors.white,
isShowDecPage: false,
//baseViewModel: model,
body: SingleChildScrollView(
child: Container(
height: SizeConfig.screenHeight,
child: Column(
children: [
Padding(
padding: EdgeInsets.all(8.0),
child: Row(
children: [
Container(
width: MediaQuery.of(context).size.width * 0.79,
child: Form(
key: _formKey,
child: NewTextFields(
autoFocus: true,
hintText: TranslationBase.of(context).search,
fontSize: 19.0,
prefixIcon: Icon(Icons.search),
inputAction: TextInputAction.search,
onSaved: (value) {
//searchMedicine(model, context);
},
onSubmit: (value) {
searchMedicine(model, context);
msg = TranslationBase.of(context).noSearchResultFound;
},
controller: textController,
// validator: (value) {
// if (value.isEmpty) {
// return 'please Enter Product Name';
// }
// return null;
// },
),
),
),
SizedBox(
width: 10.0,
),
InkWell(
child: Texts(
TranslationBase.of(context).cancel,
fontSize: 17.0,
fontWeight: FontWeight.w500,
),
onTap: () {
Navigator.pop(context);
},
),
// child: Container(
// child: Button(
// backgroundColor: Colors.green,
// loading: model.state == ViewState.BusyLocal,
// label: 'Search',
// onTap: () {
// searchMedicine(model, context);
// }),
// width: MediaQuery.of(context).size.width * 0.09,
// ),
],
),
),
model.searchList.length == 0
? Container(
child: Text(
TranslationBase.of(context).noData + model.searchList.length.toString()),
)
: Expanded(
child: Container(
child: ListView.builder(
itemCount: model.searchList.length,
itemBuilder: (BuildContext ctx, index) {
return Padding(
padding: EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Text( projectProvider.isArabic!
? model.searchList[index].namen!
:model.searchList[index].name!,
style: TextStyle(fontSize: 20),
),
),
),
Divider(height: 1, color: Colors.grey)
],
),
);
},
),
),
),
],
),
),
),
),
);
}
searchMedicine(model, BuildContext context) {
Utils.hideKeyboard(context);
if (_formKey.currentState!.validate())
model.searchProducts(productName: textController.text);
}
}