175 lines
5.3 KiB
Dart
175 lines
5.3 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/view_models/home_view_model.dart';
|
|
|
|
import '../widgets.dart';
|
|
|
|
class DesktopHomePage extends StatelessWidget {
|
|
const DesktopHomePage({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: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
SizedBox(height: 55),
|
|
_progressBarsRow(homeViewModel.homeResponse!),
|
|
SizedBox(height: 32.0.h()),
|
|
_firstTenderCardsRow(context, homeViewModel.homeResponse!),
|
|
SizedBox(height: 32.0.h()),
|
|
_yourTenderText(),
|
|
SizedBox(height: 8.0.h()),
|
|
_bottomListView(homeViewModel.homeResponse!),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _progressBarsRow(HomeResponseModel homeResponse) {
|
|
return Row(
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
ProgressBarColumn(
|
|
text: AppStrings.partnership,
|
|
value: double.parse(homeResponse.partnership ?? '0'),
|
|
amount: homeResponse.partnership ?? '0',
|
|
circularProgressIndicatorWidth: 176,
|
|
circularProgressIndicatorHeight: 176,
|
|
),
|
|
SizedBox(width: 106),
|
|
ProgressBarColumn(
|
|
text: AppStrings.selfApply,
|
|
value: double.parse(homeResponse.selfApply ?? '0'),
|
|
amount: homeResponse.selfApply ?? '0',
|
|
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,
|
|
HomeResponseModel homeResponse,
|
|
) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
TenderCard(
|
|
backgroundColor: AppColors.primary20,
|
|
iconPath: 'assets/icons/arrows.svg',
|
|
title: AppStrings.tenderSubmitted,
|
|
amount: homeResponse.tenderSubmitted ?? '0',
|
|
textColor: Color(0xFF0164FF),
|
|
enableTap: true,
|
|
width: 178,
|
|
height: 148,
|
|
onTap: () {
|
|
YourTendersRouteData().push(context);
|
|
},
|
|
),
|
|
SizedBox(width: 10),
|
|
TenderCard(
|
|
backgroundColor: AppColors.primary10,
|
|
iconPath: 'assets/icons/thumb.svg',
|
|
title: AppStrings.approvedTenders,
|
|
amount: homeResponse.approvedTenders ?? '0',
|
|
textColor: Color(0xFF24848E),
|
|
enableTap: true,
|
|
width: 178,
|
|
height: 148,
|
|
onTap: () {
|
|
YourTendersRouteData().push(context);
|
|
},
|
|
),
|
|
SizedBox(width: 10),
|
|
TenderCard(
|
|
backgroundColor: AppColors.orange10,
|
|
iconPath: 'assets/icons/shield.svg',
|
|
title: AppStrings.tenderValue,
|
|
amount: homeResponse.tenderValue ?? '0',
|
|
textColor: Color(0xFFE5821E),
|
|
enableTap: true,
|
|
width: 178,
|
|
height: 148,
|
|
onTap: () {},
|
|
),
|
|
SizedBox(width: 10),
|
|
TenderCard(
|
|
backgroundColor: AppColors.grey10,
|
|
iconPath: 'assets/icons/edit.svg',
|
|
title: AppStrings.thunderStatus,
|
|
amount: homeResponse.thunderStatus ?? '0',
|
|
textColor: Color(0xFF9E9E9E),
|
|
enableTap: false,
|
|
width: 178,
|
|
height: 148,
|
|
onTap: () {},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _yourTenderText() {
|
|
return ConstrainedBox(
|
|
constraints: BoxConstraints(maxWidth: 740),
|
|
child: Align(
|
|
alignment: Alignment.centerLeft,
|
|
child: Text(
|
|
AppStrings.yourTenders,
|
|
style: TextStyle(
|
|
fontSize: 20.0.sp(),
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.grey60,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _bottomListView(HomeResponseModel homeResponse) {
|
|
return SizedBox(
|
|
width: 740,
|
|
height: 310.0.h(),
|
|
child: ListView.builder(
|
|
itemCount: homeResponse.yourTenders?.length ?? 0,
|
|
scrollDirection: Axis.horizontal,
|
|
itemBuilder: (context, index) {
|
|
return TendersListItem(tender: homeResponse.yourTenders![index]);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|