241 lines
7.5 KiB
Dart
241 lines
7.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
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/home/home_response/home_response_model.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/home/widgets/notification_card.dart';
|
|
|
|
import '../widgets.dart';
|
|
|
|
class TabletHomePage extends StatelessWidget {
|
|
const TabletHomePage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Consumer<HomeViewModel>(
|
|
builder: (context, homeViewModel, child) {
|
|
if (homeViewModel.isLoading) {
|
|
return const Center(
|
|
child: CircularProgressIndicator(color: AppColors.secondary50),
|
|
);
|
|
}
|
|
|
|
if (homeViewModel.errorMessage != null) {
|
|
return Center(child: Text(homeViewModel.errorMessage!));
|
|
}
|
|
|
|
return SingleChildScrollView(
|
|
child: Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(
|
|
24.0.w(),
|
|
120.0.h(),
|
|
24.0.w(),
|
|
24.0.h(),
|
|
),
|
|
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.homeResponse!),
|
|
SizedBox(height: 32.0.h()),
|
|
_yourTenderText(),
|
|
SizedBox(height: 8.0.h()),
|
|
_bottomListView(homeViewModel),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
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;
|
|
return Row(
|
|
children: [
|
|
Spacer(),
|
|
SizedBox(width: 20.0.w()),
|
|
ProgressBarColumn(
|
|
text: AppStrings.partnership,
|
|
value: double.parse('$partnershipPercent'),
|
|
amount: partnership.toString(),
|
|
circularProgressIndicatorWidth: 176.0,
|
|
circularProgressIndicatorHeight: 176.0,
|
|
strokeWidth: 8.0,
|
|
),
|
|
ProgressBarColumn(
|
|
text: AppStrings.selfApply,
|
|
value: double.parse(selfApplyPercent.toString()),
|
|
amount: selfApply.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,
|
|
// ),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _firstTenderCardsRow(
|
|
BuildContext context,
|
|
TenderApprovalsStateResponse tenderApprovalsStateResponse,
|
|
) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: TenderCard(
|
|
backgroundColor: AppColors.primary20,
|
|
iconPath: 'assets/icons/arrows.svg',
|
|
title: AppStrings.tenderSubmitted,
|
|
amount:
|
|
tenderApprovalsStateResponse
|
|
.data!
|
|
.approvalsBySubmission!
|
|
.selfApply
|
|
.toString(),
|
|
textColor: Color(0xFF0164FF),
|
|
enableTap: true,
|
|
width: double.infinity,
|
|
height: 148,
|
|
onTap: () {
|
|
YourTendersRouteData().push(context);
|
|
},
|
|
),
|
|
),
|
|
SizedBox(width: 16.0),
|
|
Expanded(
|
|
child: TenderCard(
|
|
backgroundColor: AppColors.primary10,
|
|
iconPath: 'assets/icons/thumb.svg',
|
|
title: AppStrings.approvedTenders,
|
|
amount:
|
|
tenderApprovalsStateResponse.data!.approvedTenders.toString(),
|
|
|
|
textColor: Color(0xFF24848E),
|
|
enableTap: true,
|
|
width: double.infinity,
|
|
height: 148,
|
|
onTap: () {
|
|
YourTendersRouteData().push(context);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
// ignore: unused_element
|
|
Widget _secondTenderCardsRow(HomeResponseModel homeResponse) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: TenderCard(
|
|
backgroundColor: AppColors.orange10,
|
|
iconPath: 'assets/icons/shield.svg',
|
|
title: AppStrings.tenderValue,
|
|
amount: homeResponse.tenderValue ?? '0',
|
|
textColor: Color(0xFFE5821E),
|
|
enableTap: true,
|
|
width: double.infinity,
|
|
height: 148,
|
|
onTap: () {},
|
|
),
|
|
),
|
|
SizedBox(width: 16.0),
|
|
Expanded(
|
|
child: TenderCard(
|
|
backgroundColor: AppColors.grey10,
|
|
iconPath: 'assets/icons/edit.svg',
|
|
title: AppStrings.thunderStatus,
|
|
amount: homeResponse.thunderStatus ?? '0',
|
|
textColor: Color(0xFF9E9E9E),
|
|
enableTap: false,
|
|
width: double.infinity,
|
|
height: 148,
|
|
onTap: () {},
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _yourTenderText() {
|
|
return Text(
|
|
AppStrings.recommendation,
|
|
style: TextStyle(
|
|
fontSize: 18.0.sp(),
|
|
fontWeight: FontWeight.w700,
|
|
color: AppColors.grey80,
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _bottomListView(HomeViewModel homeViewModel) {
|
|
final controller = ScrollController();
|
|
|
|
controller.addListener(() {
|
|
if (controller.position.pixels >=
|
|
controller.position.maxScrollExtent - 200) {
|
|
if (!homeViewModel.isLoadingMore && homeViewModel.hasMore) {
|
|
homeViewModel.getHomeRecommandTenders();
|
|
}
|
|
}
|
|
});
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
height: 387.0.h(),
|
|
child: ListView.builder(
|
|
itemCount:
|
|
homeViewModel.tenders.length +
|
|
(homeViewModel.isLoadingMore ? 1 : 0),
|
|
scrollDirection: Axis.horizontal,
|
|
itemBuilder: (context, index) {
|
|
if (index < homeViewModel.tenders.length) {
|
|
return TendersListItem(tender: homeViewModel.tenders[index]);
|
|
} else {
|
|
return Center(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(16.0),
|
|
child: CircularProgressIndicator(color: AppColors.secondary50),
|
|
),
|
|
);
|
|
}
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|