|
|
|
|
@ -4,6 +4,7 @@ import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/all_requests_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/parts_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
@ -11,6 +12,7 @@ import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/helper_data_models/spare_part/activity_spare_part_model.dart';
|
|
|
|
|
import 'package:test_sa/models/lookup.dart';
|
|
|
|
|
import 'package:test_sa/models/size_config.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
|
|
|
@ -19,6 +21,7 @@ import 'package:test_sa/service_request_latest/service_request_detail_provider.d
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/components/action_button/footer_action_button.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/images/new_multi_image_picker.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../../../../models/service_request/spare_parts.dart';
|
|
|
|
|
import '../../../../../../new_views/common_widgets/app_text_form_field.dart';
|
|
|
|
|
@ -119,6 +122,7 @@ class _SparePartRequestState extends State<SparePartRequest> with TickerProvider
|
|
|
|
|
key: _scaffoldKey,
|
|
|
|
|
appBar: DefaultAppBar(title: context.translation.sparePartRequest),
|
|
|
|
|
body: Consumer<ServiceRequestDetailProvider>(builder: (context, ServiceRequestDetailProvider requestDetailProvider, child) {
|
|
|
|
|
print('data i got is ${requestDetailProvider.sparePartHelperModel?.sparePart?.toJson()}');
|
|
|
|
|
return SafeArea(
|
|
|
|
|
child: Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
@ -155,7 +159,7 @@ class _SparePartRequestState extends State<SparePartRequest> with TickerProvider
|
|
|
|
|
loading: _isLoading,
|
|
|
|
|
initialValue: requestDetailProvider.sparePartHelperModel?.sparePart,
|
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
onSelect: (part) {
|
|
|
|
|
onSelect: (part) async {
|
|
|
|
|
if (part != null) {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.sparePart = part;
|
|
|
|
|
_oracleNoController.text = part.oracleCode ?? '';
|
|
|
|
|
@ -163,6 +167,36 @@ class _SparePartRequestState extends State<SparePartRequest> with TickerProvider
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
if(requestDetailProvider.sparePartHelperModel?.sparePart?.id!=null)...[
|
|
|
|
|
12.height,
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 30.toScreenHeight,
|
|
|
|
|
child: Text('View Parts Availability',style:TextStyle(
|
|
|
|
|
fontSize: 12.toScreenWidth,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
fontStyle: FontStyle.normal,
|
|
|
|
|
color:AppColor.primary10 ,
|
|
|
|
|
decorationColor: AppColor.primary10,
|
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
|
)).onPress(
|
|
|
|
|
() async {
|
|
|
|
|
requestDetailProvider.getStoreAvailabilityById(partId: requestDetailProvider.sparePartHelperModel?.sparePart?.id);
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.vertical(
|
|
|
|
|
top: Radius.circular(20),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
clipBehavior: Clip.antiAliasWithSaveLayer,
|
|
|
|
|
builder: (BuildContext context) => PartDetailBottomSheetSheet(),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
12.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
controller: _partQtyController,
|
|
|
|
|
@ -309,4 +343,58 @@ class _SparePartRequestState extends State<SparePartRequest> with TickerProvider
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PartDetailBottomSheetSheet extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
PartDetailBottomSheetSheet( {Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return SizedBox(
|
|
|
|
|
height: SizeConfig.screenHeight!/2.2,
|
|
|
|
|
width: SizeConfig.screenWidth,
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
8.height,
|
|
|
|
|
'Parts Availability'.heading6(context).paddingOnly(top: 12,start: 12),
|
|
|
|
|
Consumer<ServiceRequestDetailProvider>(
|
|
|
|
|
builder: (context, requestDetailProvider,child) {
|
|
|
|
|
return requestDetailProvider.isLoading
|
|
|
|
|
? const CircularProgressIndicator(color: AppColor.primary10).center
|
|
|
|
|
: requestDetailProvider.storeAvailability.isEmpty
|
|
|
|
|
? const NoDataFound().center
|
|
|
|
|
: ListView.separated(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemCount: requestDetailProvider.storeAvailability.length,
|
|
|
|
|
separatorBuilder: (czt, index) => 12.height,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
StoreAvailability model = requestDetailProvider.storeAvailability[index];
|
|
|
|
|
return partAvailableQuantityCard(context: context,model:model);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
).expanded,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
Widget partAvailableQuantityCard({required StoreAvailability model,required BuildContext context }){
|
|
|
|
|
return Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
'Site Name: ${model.siteName??''}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
8.height,
|
|
|
|
|
'Store Name: ${model.storeName??''}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
8.height,
|
|
|
|
|
'Available Quantity: ${model.availablityQty??''}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
8.height,
|
|
|
|
|
]
|
|
|
|
|
).toShadowContainer(context, padding: 12, showShadow: false,backgroundColor: AppColor.neutral110);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|