refactor home

This commit is contained in:
amirrezaghabeli
2025-08-27 13:22:35 +03:30
parent bcd499843b
commit dd46eb6054
12 changed files with 169 additions and 202 deletions
+46 -60
View File
@@ -81,58 +81,56 @@ class TabletHomePage extends StatelessWidget {
return Center(child: Text(homeViewModel.errorMessage!));
}
return SingleChildScrollView(
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
24.0.w(),
24.0.h(),
24.0.w(),
24.0.h(),
if (homeViewModel.tenderApprovalsStateResponse != null &&
homeViewModel.data != null &&
homeViewModel.feedbackStats != null) {
return SingleChildScrollView(
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
24.0.w(),
24.0.h(),
24.0.w(),
24.0.h(),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// NotificationCard(),
SizedBox(height: 40.0.h()),
_progressBarsRow(homeViewModel),
SizedBox(height: 32.0.h()),
_firstTenderCardsRow(
context,
homeViewModel.tenderApprovalsStateResponse!,
),
SizedBox(height: 8.0.h()),
_secondTenderCardsRow(homeViewModel),
SizedBox(height: 32.0.h()),
_yourTenderText(homeViewModel),
SizedBox(height: 8.0.h()),
_bottomListView(homeViewModel),
],
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// NotificationCard(),
SizedBox(height: 40.0.h()),
_progressBarsRow(homeViewModel.tenderApprovalsStateResponse!),
SizedBox(height: 32.0.h()),
_firstTenderCardsRow(
context,
homeViewModel.tenderApprovalsStateResponse!,
),
SizedBox(height: 8.0.h()),
_secondTenderCardsRow(homeViewModel),
SizedBox(height: 32.0.h()),
_yourTenderText(homeViewModel),
SizedBox(height: 8.0.h()),
_bottomListView(homeViewModel),
],
),
),
);
}
return const Center(
child: CircularProgressIndicator(color: AppColors.secondary50),
);
},
),
);
}
Widget _progressBarsRow(
TenderApprovalsStateResponse tenderApprovalsStateResponse,
) {
final partnership =
tenderApprovalsStateResponse.data!.partnershipCount ?? 0;
final selfApply = tenderApprovalsStateResponse.data!.selfApplyCount ?? 0;
final total = (partnership + selfApply);
final partnershipPercent = total > 0 ? (partnership / total) * 100 : 0;
final selfApplyPercent = total > 0 ? (selfApply / total) * 100 : 0;
Widget _progressBarsRow(HomeViewModel homeViewModel) {
return Row(
children: [
Spacer(),
SizedBox(width: 20.0.w()),
ProgressBarColumn(
text: AppStrings.partnership,
value: double.parse('$partnershipPercent'),
amount: double.parse('$partnershipPercent').toString(),
value: homeViewModel.partnershipPercent,
amount: homeViewModel.partnershipPercent.toString(),
circularProgressIndicatorWidth: 176.0,
circularProgressIndicatorHeight: 176.0,
strokeWidth: 8.0,
@@ -140,22 +138,14 @@ class TabletHomePage extends StatelessWidget {
Spacer(),
ProgressBarColumn(
text: AppStrings.selfApply,
value: double.parse(selfApplyPercent.toString()),
amount: double.parse(selfApplyPercent.toString()).toString(),
value: homeViewModel.selfApplyPercent,
amount: homeViewModel.selfApplyPercent.toString(),
circularProgressIndicatorWidth: 176.0,
circularProgressIndicatorHeight: 176.0,
strokeWidth: 8.0,
),
SizedBox(width: 20.0.w()),
Spacer(),
// ProgressBarColumn(
// text: AppStrings.contracting,
// value: double.parse(homeResponse.contracting ?? '0'),
// amount: homeResponse.contracting ?? '0',
// circularProgressIndicatorWidth: 176.0,
// circularProgressIndicatorHeight: 176.0,
// strokeWidth: 8.0,
// ),
],
);
}
@@ -170,16 +160,12 @@ class TabletHomePage extends StatelessWidget {
Expanded(
child: TenderCard(
backgroundColor: AppColors.primary20,
iconPath: 'assets/icons/arrows.svg',
iconPath: AssetsManager.arrows,
title: AppStrings.tenderSubmitted,
amount:
tenderApprovalsStateResponse.data!.submittedTenders.toString(),
// tenderApprovalsStateResponse
// .data!
// .approvalsBySubmission!
// .selfApply
// .toString(),
textColor: Color(0xFF0164FF),
textColor: AppColors.mainBlue,
enableTap: true,
width: double.infinity,
height: 148,
@@ -196,7 +182,7 @@ class TabletHomePage extends StatelessWidget {
title: AppStrings.approvedTenders,
amount: '0',
textColor: Color(0xFF24848E),
textColor: AppColors.jellyBean,
enableTap: true,
width: double.infinity,
height: 148,
@@ -217,10 +203,10 @@ class TabletHomePage extends StatelessWidget {
Expanded(
child: TenderCard(
backgroundColor: AppColors.orange10,
iconPath: 'assets/icons/shield.svg',
iconPath: AssetsManager.shield,
title: AppStrings.tenderValue,
amount: '3',
textColor: Color(0xFFE5821E),
textColor: AppColors.orange,
enableTap: true,
width: double.infinity,
height: 148,
@@ -234,7 +220,7 @@ class TabletHomePage extends StatelessWidget {
iconPath: AssetsManager.thumbLike,
title: AppStrings.likedTenders,
amount: homeViewModel.feedbackStats?.totalLikes.toString() ?? '0',
textColor: Color(0xFF9E9E9E),
textColor: AppColors.grey80,
enableTap: false,
width: double.infinity,
height: 148,