@ -1,6 +1,4 @@
import ' dart:convert ' ;
import ' package:mc_common_app/models/general_models/generic_resp_model.dart ' ;
import ' package:mc_common_app/generated/locale_keys.g.dart ' ;
import ' package:mc_common_app/view_models/service_view_model.dart ' ;
import ' package:car_provider_app/views/settings/services/duplication/sheet/approved_branches_list_sheet.dart ' ;
import ' package:car_provider_app/views/settings/services/duplication/sheet/items_selection_sheet.dart ' ;
@ -11,7 +9,6 @@ import 'package:mc_common_app/extensions/string_extensions.dart';
import ' package:flutter_svg/flutter_svg.dart ' ;
import ' package:mc_common_app/models/services_models/item_model.dart ' ;
import ' package:mc_common_app/theme/colors.dart ' ;
import ' package:mc_common_app/utils/navigator.dart ' ;
import ' package:mc_common_app/utils/utils.dart ' ;
import ' package:mc_common_app/widgets/bottom_sheet.dart ' ;
import ' package:mc_common_app/widgets/button/show_fill_button.dart ' ;
@ -20,6 +17,7 @@ import 'package:mc_common_app/widgets/dropdown/dropdown_text.dart';
import ' package:mc_common_app/widgets/empty_widget.dart ' ;
import ' package:mc_common_app/widgets/extensions/extensions_widget.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:easy_localization/easy_localization.dart ' ;
class MatchedServicesPage extends StatefulWidget {
final MatchServicesArguments ? matchServicesArguments ;
@ -47,8 +45,8 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
@ override
Widget build ( BuildContext context ) {
return Scaffold (
appBar: const CustomAppBar (
title: " Select Services " ,
appBar: CustomAppBar (
title: LocaleKeys . selectServices . tr ( ) ,
) ,
body: SizedBox (
width: double . infinity ,
@ -74,19 +72,17 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
serviceVM . selectAllServices ( v ? ? false ) ;
} ,
) ,
" Select All " . toText (
isBold: true ,
)
LocaleKeys . selectAll . tr ( ) . toText ( isBold: true )
] ,
) ,
Container (
alignment: Alignment . centerRight ,
child: " Unselect All " . toText (
color: MyColors . primaryColor ,
isUnderLine: true ,
isBold: true ,
) ,
margin: const EdgeInsets . symmetric ( horizontal: 14 , vertical: 7 ) ,
child: LocaleKeys . unselectAll . tr ( ) . toText (
color: MyColors . primaryColor ,
isUnderLine: true ,
isBold: true ,
) ,
) . onPress ( ( ) {
serviceVM . selectAllServices ( false ) ;
} ) ,
@ -98,7 +94,7 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
if ( model . matchedServices = = null ) {
return const Center ( child: CircularProgressIndicator ( ) ) ;
} else if ( model . matchedServices ! . isEmpty ) {
return const EmptyWidget ( text: " No Services found " , isWra pedColumn: false ) ;
return EmptyWidget ( text: LocaleKeys . noServicesAvailable . tr ( ) , isWrap pedColumn: false ) ;
}
return ListView . separated (
itemBuilder: ( context , index ) {
@ -110,7 +106,7 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
value: model . matchedServices ! [ index ] . isExpandedOrSelected ,
onChanged: ( v ) {
if ( model . matchedServices ! [ index ] . serviceItems ! . isEmpty ) {
Utils . showToast ( " No Items Available in this service " ) ;
Utils . showToast ( LocaleKeys . noItemstoShow . tr ( ) ) ;
} else {
model . matchedServices ! [ index ] . isExpandedOrSelected = v ? ? false ;
model . updateServiceItem ( index , model . matchedServices ! [ index ] . isExpandedOrSelected ) ;
@ -123,8 +119,7 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
model . matchedServices ! [ index ] . serviceDescription . toString ( ) . toText ( fontSize: 16 , isBold: true ) ,
" ${ model . matchedServices ! [ index ] . serviceItems ! . where ( ( c ) = > c . isUpdateOrSelected = = true ) . length } items selected out of ${ model . matchedServices ! [ index ] . serviceItems ! . length } "
. toText ( color: MyColors . lightTextColor )
" ${ model . matchedServices ! [ index ] . serviceItems ! . where ( ( c ) = > c . isUpdateOrSelected = = true ) . length } items selected out of ${ model . matchedServices ! [ index ] . serviceItems ! . length } " . toText ( color: MyColors . lightTextColor )
] ,
) ,
) ,
@ -158,25 +153,14 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
) ,
12. height ,
ShowFillButton (
title: " Copy Selected Services " ,
title: LocaleKeys . copySelectedServices . tr ( ) ,
maxWidth: double . infinity ,
margin: const EdgeInsets . all ( 14 ) ,
onPressed: ( ) async {
Utils . showLoading ( context ) ;
List < int > items = [ ] ;
for ( var element in serviceVM . matchedServices ! ) {
items . addAll ( element . serviceItems ! . where ( ( e ) = > e . isUpdateOrSelected = = true ) . map ( ( e ) = > e . id ? ? 0 ) . toList ( ) ) ;
}
Map < String , dynamic > map = {
" providerBranchID " : widget . matchServicesArguments ! . newBranch . toString ( ) ,
" serviceItems " : items ,
} ;
print ( jsonEncode ( map ) ) ;
GenericRespModel mResponse = await serviceVM . duplicateItems ( map ) ;
Utils . hideLoading ( context ) ;
Utils . showToast ( mResponse . message ? ? " " ) ;
pop ( context ) ;
pop ( context ) ;
await serviceVM . duplicateItems (
providerBranchID: widget . matchServicesArguments ! . newBranch . toString ( ) ,
context: context ,
) ;
} ,
) ,
] ,