@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/core/model/packages_offers/requests/OffersC
import ' package:diplomaticquarterapp/core/model/packages_offers/requests/OffersProductsRequestModel.dart ' ;
import ' package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesCategoriesResponseModel.dart ' ;
import ' package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart ' ;
import ' package:diplomaticquarterapp/core/model/packages_offers/responses/offers_stores_response_model.dart ' ;
import ' package:diplomaticquarterapp/core/viewModels/packages_offers/PackagesOffersViewModel.dart ' ;
import ' package:diplomaticquarterapp/core/viewModels/project_view_model.dart ' ;
import ' package:diplomaticquarterapp/models/Authentication/authenticated_user.dart ' ;
@ -88,6 +89,7 @@ class _PackagesHomePageState extends State<PackagesHomePage> {
}
PackagesCategoriesResponseModel selectedClinic ;
OfferProject selectedProject ;
@ override
Widget build ( BuildContext context ) {
@ -106,6 +108,12 @@ class _PackagesHomePageState extends State<PackagesHomePage> {
if ( OFFERS_VIEW_ONLY )
inputWidget ( TranslationBase . of ( context ) . search , " " , _searchTextController , isInputTypeNum: false ) ,
SizedBox ( height: 12 ) ,
Padding (
padding: const EdgeInsets . only ( left: 21 , right: 21 ) ,
child: CommonDropDownView ( TranslationBase . of ( context ) . browseOffersByProject , selectedProject ? . name ? ? TranslationBase . of ( context ) . selectProject , ( ) = > showHospitalSelectionList ( ) )
. withBorderedContainer ,
) ,
SizedBox ( height: 12 ) ,
Padding (
padding: const EdgeInsets . only ( left: 21 , right: 21 ) ,
child: CommonDropDownView ( TranslationBase . of ( context ) . browseOffers , selectedClinic ? . name ? ? TranslationBase . of ( context ) . selectClinic , ( ) = > showClinicSelectionList ( ) )
@ -174,13 +182,7 @@ class _PackagesHomePageState extends State<PackagesHomePage> {
int _selectedClinic = - 1 ;
showClinicSelectionList ( ) async {
var clinics = viewModel . service . categoryList ;
if ( clinics . isEmpty ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
clinics = await viewModel . service . getAllCategories ( OffersCategoriesRequestModel ( ) ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
}
var clinics = await viewModel . service . getAllCategories ( OffersCategoriesRequestModel ( ) ) ;
List < RadioSelectionDialogModel > list = [
for ( int i = 0 ; i < clinics . length ; i + + ) RadioSelectionDialogModel ( clinics [ i ] . name , i ) ,
] ;
@ -204,6 +206,38 @@ class _PackagesHomePageState extends State<PackagesHomePage> {
) ;
}
int _selectedHospital = - 1 ;
showHospitalSelectionList ( ) async {
GifLoaderDialogUtils . showMyDialog ( context ) ;
var hospitals = await viewModel . service . getAllStores ( ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
List < RadioSelectionDialogModel > list = [
for ( int i = 0 ; i < hospitals . length ; i + + ) RadioSelectionDialogModel ( hospitals [ i ] . name , i ) ,
] ;
showDialog (
context: context ,
builder: ( cxt ) = > RadioSelectionDialog (
listData: list ,
selectedIndex: _selectedHospital ,
isScrollable: true ,
onValueSelected: ( index ) async {
_selectedHospital = index ;
selectedProject = hospitals [ index ] ;
var request = OffersProductsRequestModel ( storeId: selectedProject . id ) ;
request . sinceId = 0 ;
var products = await viewModel . service . getAllProducts ( request: request , context: context , showLoading: true ) ;
if ( products . isNotEmpty )
Navigator . of ( context ) . push ( MaterialPageRoute ( builder: ( BuildContext context ) = > ClinicPackagesPage ( products: products ) ) ) ;
else
utils . Utils . showErrorToast ( " No offers available for this clinic " ) ;
setState ( ( ) { } ) ;
} ,
) ,
) ;
}
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / Main Widgets of Page
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -