home logic added
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/core/constants/assets.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 'package:tm_app/views/shared/tender_app_bar.dart';
|
||||
|
||||
import '../widgets.dart';
|
||||
@@ -15,27 +18,69 @@ class MobileHomePage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: tenderMobileAppBar(title: AppStrings.home),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 18.0.h()),
|
||||
_progressBarsRow(),
|
||||
SizedBox(height: 32.0.h()),
|
||||
_firstTenderCardsRow(context),
|
||||
SizedBox(height: 8.0.h()),
|
||||
_secondTenderCardsRow(),
|
||||
SizedBox(height: 32.0.h()),
|
||||
_yourTenderText(),
|
||||
SizedBox(height: 8.0.h()),
|
||||
_bottomListView(),
|
||||
],
|
||||
),
|
||||
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: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
size: 64,
|
||||
color: Colors.red,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
homeViewModel.errorMessage!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey.shade700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
onPressed: () => homeViewModel.getHome(),
|
||||
child: const Text('Try Again'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 18.0.h()),
|
||||
_progressBarsRow(homeViewModel.homeResponse!),
|
||||
SizedBox(height: 32.0.h()),
|
||||
_firstTenderCardsRow(context, homeViewModel.homeResponse!),
|
||||
SizedBox(height: 8.0.h()),
|
||||
_secondTenderCardsRow(homeViewModel.homeResponse!),
|
||||
SizedBox(height: 32.0.h()),
|
||||
_yourTenderText(),
|
||||
SizedBox(height: 8.0.h()),
|
||||
_bottomListView(homeViewModel.homeResponse!),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _progressBarsRow() {
|
||||
Widget _progressBarsRow(HomeResponseModel homeResponse) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
||||
child: Row(
|
||||
@@ -43,25 +88,28 @@ class MobileHomePage extends StatelessWidget {
|
||||
children: [
|
||||
ProgressBarColumn(
|
||||
text: AppStrings.partnership,
|
||||
value: 0.75,
|
||||
amount: '75%',
|
||||
value: double.parse(homeResponse.partnership ?? '0'),
|
||||
amount: '${homeResponse.partnership}%',
|
||||
),
|
||||
ProgressBarColumn(
|
||||
text: AppStrings.selfApply,
|
||||
value: 0.88,
|
||||
amount: '12',
|
||||
value: double.parse(homeResponse.selfApply ?? '0'),
|
||||
amount: homeResponse.selfApply ?? '0',
|
||||
),
|
||||
ProgressBarColumn(
|
||||
text: AppStrings.contracting,
|
||||
value: 0.36,
|
||||
amount: '36',
|
||||
value: double.parse(homeResponse.contracting ?? '0'),
|
||||
amount: homeResponse.contracting ?? '0',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _firstTenderCardsRow(BuildContext context) {
|
||||
Widget _firstTenderCardsRow(
|
||||
BuildContext context,
|
||||
HomeResponseModel homeResponse,
|
||||
) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
||||
child: Row(
|
||||
@@ -71,7 +119,7 @@ class MobileHomePage extends StatelessWidget {
|
||||
backgroundColor: AppColors.primary20,
|
||||
iconPath: AssetsManager.arrows,
|
||||
title: AppStrings.tenderSubmitted,
|
||||
amount: '12',
|
||||
amount: homeResponse.tenderSubmitted ?? '0',
|
||||
textColor: Color(0xFF0164FF),
|
||||
enableTap: true,
|
||||
onTap: () {
|
||||
@@ -82,7 +130,7 @@ class MobileHomePage extends StatelessWidget {
|
||||
backgroundColor: AppColors.primary10,
|
||||
iconPath: AssetsManager.thumb,
|
||||
title: AppStrings.approvedTenders,
|
||||
amount: '03',
|
||||
amount: homeResponse.approvedTenders ?? '0',
|
||||
textColor: Color(0xFF24848E),
|
||||
enableTap: true,
|
||||
onTap: () {
|
||||
@@ -94,7 +142,7 @@ class MobileHomePage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _secondTenderCardsRow() {
|
||||
Widget _secondTenderCardsRow(HomeResponseModel homeResponse) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
||||
child: Row(
|
||||
@@ -104,7 +152,7 @@ class MobileHomePage extends StatelessWidget {
|
||||
backgroundColor: AppColors.orange10,
|
||||
iconPath: AssetsManager.shield,
|
||||
title: AppStrings.tenderValue,
|
||||
amount: '\$250,000',
|
||||
amount: homeResponse.tenderValue ?? '0',
|
||||
textColor: Color(0xFFE5821E),
|
||||
enableTap: true,
|
||||
onTap: () {},
|
||||
@@ -113,7 +161,7 @@ class MobileHomePage extends StatelessWidget {
|
||||
backgroundColor: AppColors.grey10,
|
||||
iconPath: AssetsManager.edit,
|
||||
title: AppStrings.thunderStatus,
|
||||
amount: '23',
|
||||
amount: homeResponse.thunderStatus ?? '0',
|
||||
textColor: Color(0xFF9E9E9E),
|
||||
enableTap: false,
|
||||
onTap: () {},
|
||||
@@ -137,16 +185,16 @@ class MobileHomePage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _bottomListView() {
|
||||
Widget _bottomListView(HomeResponseModel homeResponse) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
height: 310.0.h(),
|
||||
height: 286.0.h(),
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
||||
itemCount: 10,
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w(), vertical: 16.0.h()),
|
||||
itemCount: homeResponse.yourTenders?.length ?? 0,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
return TendersListItem();
|
||||
return TendersListItem(tender: homeResponse.yourTenders![index]);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user