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
+73 -86
View File
@@ -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,
+12 -31
View File
@@ -31,7 +31,8 @@ class MobileHomePage extends StatelessWidget {
}
if (homeViewModel.tenderApprovalsStateResponse != null &&
homeViewModel.data != null) {
homeViewModel.data != null &&
homeViewModel.feedbackStats != null) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -39,7 +40,7 @@ class MobileHomePage extends StatelessWidget {
// SizedBox(height: 18.0.h()),
// NotificationCard(),
SizedBox(height: 32.0.h()),
_progressBarsRow(homeViewModel.tenderApprovalsStateResponse!),
_progressBarsRow(homeViewModel),
SizedBox(height: 32.0.h()),
_firstTenderCardsRow(
context,
@@ -62,17 +63,7 @@ class MobileHomePage extends StatelessWidget {
);
}
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 Padding(
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
child: Row(
@@ -81,22 +72,17 @@ class MobileHomePage extends StatelessWidget {
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(),
),
Spacer(),
ProgressBarColumn(
text: AppStrings.selfApply,
value: double.parse(selfApplyPercent.toString()),
amount: double.parse(selfApplyPercent.toString()).toString(),
value: homeViewModel.selfApplyPercent,
amount: homeViewModel.selfApplyPercent.toString(),
),
SizedBox(width: 20.0.w()),
Spacer(),
// ProgressBarColumn(
// text: AppStrings.contracting,
// value: double.parse(tenderApprovalsStateResponse.data.contracting ?? '0'),
// amount: tenderApprovalsStateResponse.data.contracting ?? '0',
// ),
],
),
);
@@ -117,12 +103,7 @@ class MobileHomePage extends StatelessWidget {
title: AppStrings.tenderSubmitted,
amount:
tenderApprovalsStateResponse.data!.submittedTenders.toString(),
// tenderApprovalsStateResponse
// .data!
// .approvalsBySubmission!
// .selfApply
// .toString(),
textColor: Color(0xFF0164FF),
textColor: AppColors.mainBlue,
enableTap: true,
onTap: () {
YourTendersRouteData().push(context);
@@ -134,7 +115,7 @@ class MobileHomePage extends StatelessWidget {
title: AppStrings.approvedTenders,
amount: '0',
textColor: Color(0xFF24848E),
textColor: AppColors.jellyBean,
enableTap: true,
onTap: () {
YourTendersRouteData().push(context);
@@ -157,7 +138,7 @@ class MobileHomePage extends StatelessWidget {
iconPath: AssetsManager.shield,
title: AppStrings.tenderValue,
amount: '3',
textColor: Color(0xFFE5821E),
textColor: AppColors.orange,
enableTap: true,
onTap: () {},
),
@@ -166,7 +147,7 @@ class MobileHomePage extends StatelessWidget {
iconPath: AssetsManager.thumbLike,
title: AppStrings.likedTenders,
amount: homeViewModel.feedbackStats?.totalLikes.toString() ?? '0',
textColor: Color(0xFF9E9E9E),
textColor: AppColors.grey80,
enableTap: false,
onTap: () {},
),
+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,
+1 -1
View File
@@ -78,7 +78,7 @@ class _ProgressBarColumnState extends State<ProgressBarColumn>
animation: _animation,
builder:
(context, child) => CircularProgressIndicator(
backgroundColor: Color(0xFFE1E1E1),
backgroundColor: AppColors.grey10,
strokeCap: StrokeCap.round,
strokeWidth: widget.strokeWidth ?? 6.0,
valueColor: AlwaysStoppedAnimation<Color>(AppColors.jellyBean),
+2 -1
View File
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import '../../core/constants/assets.dart';
import '../../core/theme/colors.dart';
import '../../core/utils/size_config.dart';
class TenderCard extends StatelessWidget {
@@ -50,7 +51,7 @@ class TenderCard extends StatelessWidget {
style: TextStyle(
fontSize: 16.0.sp(),
fontWeight: FontWeight.bold,
color: Color(0xFF777777),
color: AppColors.grey80,
),
),
Spacer(),
-18
View File
@@ -97,7 +97,6 @@ class TendersListItem extends StatelessWidget {
),
),
Spacer(),
// SizedBox(height: 18.0.h()),
TenderCardProgressBar(),
SizedBox(height: 15.0.h()),
@@ -123,23 +122,6 @@ class TendersListItem extends StatelessWidget {
),
),
Spacer(),
// Container(
// width: 96.0.w(),
// height: 24.0.h(),
// decoration: BoxDecoration(
// color: AppColors.grey30,
// borderRadius: BorderRadius.circular(88),
// ),
// alignment: Alignment.center,
// child: Text(
// 'tender.type',
// style: TextStyle(
// fontSize: 12.0.sp(),
// fontWeight: FontWeight.w500,
// color: AppColors.grey60,
// ),
// ),
// ),
],
),
],