refactor home
This commit is contained in:
@@ -6,7 +6,6 @@ import 'package:tm_app/core/constants/strings.dart';
|
||||
import 'package:tm_app/core/routes/app_routes.dart';
|
||||
import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/data/services/model/tender_approvals_state_response/tender_approvals_state_response.dart';
|
||||
import 'package:tm_app/view_models/home_view_model.dart';
|
||||
import 'package:tm_app/views/shared/desktop_navigation_widget.dart';
|
||||
|
||||
@@ -30,111 +29,99 @@ class DesktopHomePage extends StatelessWidget {
|
||||
return Center(child: Text(homeViewModel.errorMessage!));
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
DesktopNavigationWidget(
|
||||
currentIndex: 0, // Home index
|
||||
onTabChanged: (index) {
|
||||
// Navigate to different screens based on index
|
||||
switch (index) {
|
||||
case 0:
|
||||
// Already on home
|
||||
break;
|
||||
case 1:
|
||||
// Navigate to tenders
|
||||
Router.neglect(context, () => context.go('/tenders'));
|
||||
break;
|
||||
case 2:
|
||||
// Navigate to profile
|
||||
Router.neglect(context, () => context.go('/profile'));
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 780,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 55),
|
||||
// SizedBox(width: 780, child: NotificationCard()),
|
||||
SizedBox(height: 40.0),
|
||||
_progressBarsRow(
|
||||
homeViewModel.tenderApprovalsStateResponse!,
|
||||
),
|
||||
SizedBox(height: 32.0.h()),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15.0.w()),
|
||||
child: _firstTenderCardsRow(
|
||||
context,
|
||||
homeViewModel.tenderApprovalsStateResponse!,
|
||||
homeViewModel,
|
||||
if (homeViewModel.tenderApprovalsStateResponse != null &&
|
||||
homeViewModel.data != null &&
|
||||
homeViewModel.feedbackStats != null) {
|
||||
return Column(
|
||||
children: [
|
||||
DesktopNavigationWidget(
|
||||
currentIndex: 0, // Home index
|
||||
onTabChanged: (index) {
|
||||
// Navigate to different screens based on index
|
||||
switch (index) {
|
||||
case 0:
|
||||
// Already on home
|
||||
break;
|
||||
case 1:
|
||||
// Navigate to tenders
|
||||
Router.neglect(context, () => context.go('/tenders'));
|
||||
break;
|
||||
case 2:
|
||||
// Navigate to profile
|
||||
Router.neglect(context, () => context.go('/profile'));
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 780,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 55),
|
||||
// SizedBox(width: 780, child: NotificationCard()),
|
||||
SizedBox(height: 40.0),
|
||||
_progressBarsRow(homeViewModel),
|
||||
SizedBox(height: 32.0.h()),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 15.0.w(),
|
||||
),
|
||||
child: _firstTenderCardsRow(
|
||||
context,
|
||||
homeViewModel,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 32.0.h()),
|
||||
_yourTenderText(homeViewModel),
|
||||
SizedBox(height: 8.0.h()),
|
||||
_bottomListView(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(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ProgressBarColumn(
|
||||
text: AppStrings.partnership,
|
||||
value: double.parse('$partnershipPercent'),
|
||||
amount: double.parse('$partnershipPercent').toString(),
|
||||
value: homeViewModel.partnershipPercent,
|
||||
amount: homeViewModel.partnershipPercent.toString(),
|
||||
circularProgressIndicatorWidth: 176,
|
||||
circularProgressIndicatorHeight: 176,
|
||||
),
|
||||
SizedBox(width: 106),
|
||||
ProgressBarColumn(
|
||||
text: AppStrings.selfApply,
|
||||
value: double.parse(selfApplyPercent.toString()),
|
||||
amount: double.parse(selfApplyPercent.toString()).toString(),
|
||||
value: homeViewModel.selfApplyPercent,
|
||||
amount: homeViewModel.selfApplyPercent.toString(),
|
||||
circularProgressIndicatorWidth: 176,
|
||||
circularProgressIndicatorHeight: 176,
|
||||
),
|
||||
//SizedBox(width: 106),
|
||||
// ProgressBarColumn(
|
||||
// text: AppStrings.contracting,
|
||||
// value: double.parse(homeResponse.contracting ?? '0'),
|
||||
// amount: homeResponse.contracting ?? '0',
|
||||
// circularProgressIndicatorWidth: 176,
|
||||
// circularProgressIndicatorHeight: 176,
|
||||
// ),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _firstTenderCardsRow(
|
||||
BuildContext context,
|
||||
TenderApprovalsStateResponse tenderApprovalsStateResponse,
|
||||
HomeViewModel homeViewModel,
|
||||
) {
|
||||
return Row(
|
||||
@@ -143,16 +130,16 @@ class DesktopHomePage 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),
|
||||
homeViewModel
|
||||
.tenderApprovalsStateResponse!
|
||||
.data!
|
||||
.submittedTenders
|
||||
.toString(),
|
||||
|
||||
textColor: AppColors.mainBlue,
|
||||
enableTap: true,
|
||||
width: 178,
|
||||
height: 148,
|
||||
@@ -168,7 +155,7 @@ class DesktopHomePage extends StatelessWidget {
|
||||
iconPath: AssetsManager.approve,
|
||||
title: AppStrings.approvedTenders,
|
||||
amount: '0',
|
||||
textColor: Color(0xFF24848E),
|
||||
textColor: AppColors.jellyBean,
|
||||
enableTap: true,
|
||||
width: 178,
|
||||
height: 148,
|
||||
@@ -180,10 +167,10 @@ class DesktopHomePage extends StatelessWidget {
|
||||
SizedBox(width: 10),
|
||||
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: 178,
|
||||
height: 148,
|
||||
@@ -195,7 +182,7 @@ class DesktopHomePage extends StatelessWidget {
|
||||
iconPath: AssetsManager.thumbLike,
|
||||
title: AppStrings.likedTenders,
|
||||
amount: homeViewModel.feedbackStats?.totalLikes.toString() ?? '0',
|
||||
textColor: Color(0xFF9E9E9E),
|
||||
textColor: AppColors.grey80,
|
||||
enableTap: false,
|
||||
width: 178,
|
||||
height: 148,
|
||||
|
||||
Reference in New Issue
Block a user