refactor: update getSDUIForm method to require token parameter, enhance error handling in SDUIFormWidget, and clean up code formatting across various files

This commit is contained in:
2026-01-06 15:59:42 +03:30
parent 0f0fa8da09
commit 17f8a2d79b
9 changed files with 26 additions and 26 deletions

File diff suppressed because one or more lines are too long

View File

@@ -27,7 +27,7 @@ class NewInspectionLogic extends GetxController {
RxnString searchedValue = RxnString();
Rx<Jalali> fromDateFilter = Jalali.now().obs;
Rx<Jalali> toDateFilter = Jalali.now().obs;
@override
void onInit() {
super.onInit();

View File

@@ -13,5 +13,7 @@ abstract class VetFarmRemoteDataSource {
required SubmitInspectionResponse request,
});
Future<DioResponse<Map<String, dynamic>>> getSDUIForm({String? token});
Future<DioResponse<Map<String, dynamic>>> getSDUIForm({
required String token,
});
}

View File

@@ -38,18 +38,16 @@ class VetFarmRemoteDataSourceImpl implements VetFarmRemoteDataSource {
}
@override
Future<DioResponse<Map<String, dynamic>>> getSDUIForm({String? token}) async {
DioRemote dio = DioRemote(baseUrl: "http://testbackend.rasadyaar.ir/");
await dio.init();
var res = await dio.get(
'inspection_form_sd_ui/',
Future<DioResponse<Map<String, dynamic>>> getSDUIForm({
required String token,
}) async {
var res = await _httpClient.get(
'/inspection_form_sd_ui/?name=b1',
headers: {'Authorization': 'Bearer $token'},
fromJson: (json) {
return json;
},
);
return res;
},
);
return res;
}
}

View File

@@ -14,5 +14,7 @@ abstract class VetFarmRepository {
});
Future<DioResponse<Map<String, dynamic>>> getSDUIForm({String? token});
Future<DioResponse<Map<String, dynamic>>> getSDUIForm({
required String token,
});
}

View File

@@ -28,7 +28,7 @@ class VetFarmRepositoryImpl implements VetFarmRepository {
return await _remote.submitInspection(token: token, request: request);
}
@override
Future<DioResponse<Map<String, dynamic>>> getSDUIForm({String? token}) async {
Future<DioResponse<Map<String, dynamic>>> getSDUIForm({required String token,}) async {
return await _remote.getSDUIForm(token: token);
}
}

View File

@@ -29,7 +29,9 @@ class NewPageLogic extends GetxController {
Future<void> getSDUIForm() async {
await safeCall(
call: () async => await rootLogic.vetFarmRepository.getSDUIForm(),
call: () async => await rootLogic.vetFarmRepository.getSDUIForm(
token: rootLogic.tokenService.accessToken.value ?? '',
),
onSuccess: (result) {
if (result.data != null) {
try {

View File

@@ -636,7 +636,7 @@ class SDUIFormWidget extends StatelessWidget {
iLog('Stack trace: $stackTrace');
return Container(
padding: EdgeInsets.all(16),
color: Colors.green.withOpacity(0.1),
color: Colors.green.withAlpha(10),
child: Text('Image Picker Error: $e'),
);
}
@@ -712,7 +712,7 @@ class SDUIFormWidget extends StatelessWidget {
iLog('Error building page_view child: $e');
return Container(
padding: EdgeInsets.all(8),
color: Colors.yellow.withOpacity(0.1),
color: Colors.yellow.withAlpha(10),
child: Text('Child Error'),
);
}
@@ -733,7 +733,7 @@ class SDUIFormWidget extends StatelessWidget {
iLog('Stack trace: $stackTrace');
return Container(
padding: EdgeInsets.all(16),
color: Colors.blue.withOpacity(0.1),
color: Colors.blue.withAlpha(10),
child: Text('PageView Error: $e'),
);
}
@@ -1006,8 +1006,6 @@ class SDUIFormWidget extends StatelessWidget {
'sdui_form_stepper_${stepperInfo.stepperData.key ?? 'default'}';
SDUIFormWidgetController formController;
fLog('mj ==>build With Stepper Layout');
try {
formController = Get.find<SDUIFormWidgetController>(tag: controllerTag);
} catch (_) {
@@ -1548,7 +1546,6 @@ class SDUIFormWidget extends StatelessWidget {
child: Row(
spacing: 10.w,
children: [
Expanded(
child: ROutlinedElevated(
height: 40.h,
@@ -1568,7 +1565,7 @@ class SDUIFormWidget extends StatelessWidget {
borderColor: AppColor.blueNormal,
),
),
Expanded(
Expanded(
flex: 2,
child: RElevated(
height: 40.h,
@@ -1590,7 +1587,6 @@ class SDUIFormWidget extends StatelessWidget {
backgroundColor: AppColor.blueNormal,
),
),
],
),
);

View File

@@ -6,7 +6,7 @@ class SDUIFormWidgetController extends GetxController {
String? stepperKey;
void initializeStepper(int totalSteps, String? key) {
this.totalSteps = totalSteps;
this.totalSteps = totalSteps;
this.stepperKey = key;
currentStep.value = 0;
}