Merge pull request 'fix web bug and navigations' (#69) from web_all into main
Reviewed-on: https://repo.ravanertebat.com/TM/tm_app/pulls/69
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
@@ -7,6 +8,10 @@ import 'package:tm_app/views/detail/widgets/tender_detail_action.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_card.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_header.dart';
|
||||
|
||||
import '../../../view_models/home_view_model.dart';
|
||||
import '../../../view_models/tenders_view_model.dart';
|
||||
import '../../shared/desktop_navigation_widget.dart';
|
||||
|
||||
class TenderDetailDesktopPage extends StatefulWidget {
|
||||
final String tenderId;
|
||||
const TenderDetailDesktopPage({required this.tenderId, super.key});
|
||||
@@ -72,46 +77,83 @@ class _TenderDetailDesktopPageState extends State<TenderDetailDesktopPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
body: Consumer<TenderDetailViewModel>(
|
||||
builder: (context, tenderViewModel, child) {
|
||||
if (tenderViewModel.isLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(color: AppColors.secondary50),
|
||||
);
|
||||
}
|
||||
return PopScope(
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.read<TendersViewModel>().getTenderApprovals(widget.tenderId);
|
||||
});
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
body: Consumer<TenderDetailViewModel>(
|
||||
builder: (context, tenderViewModel, child) {
|
||||
if (tenderViewModel.isLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(color: AppColors.secondary50),
|
||||
);
|
||||
}
|
||||
|
||||
if (tenderViewModel.errorMessage != null) {
|
||||
return Center(child: Text(tenderViewModel.errorMessage!));
|
||||
}
|
||||
if (tenderViewModel.errorMessage != null) {
|
||||
return Center(child: Text(tenderViewModel.errorMessage!));
|
||||
}
|
||||
|
||||
final detail = tenderViewModel.tenderDetail;
|
||||
if (detail == null) {
|
||||
return const Center(child: Text('No tender details available'));
|
||||
}
|
||||
final detail = tenderViewModel.tenderDetail;
|
||||
if (detail == null) {
|
||||
return const Center(child: Text('No tender details available'));
|
||||
}
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 740,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TenderDetailHeader(isScreenBig: true, detail: detail),
|
||||
SizedBox(height: 32.0.h()),
|
||||
TenderDetailCard(detail: detail),
|
||||
SizedBox(height: 24.0.h()),
|
||||
TenderDetailActions(isScreenBig: true, detail: detail),
|
||||
],
|
||||
return Column(
|
||||
children: [
|
||||
DesktopNavigationWidget(
|
||||
currentIndex: 1, // Home index
|
||||
onTabChanged: (index) {
|
||||
// Navigate to different screens based on index
|
||||
switch (index) {
|
||||
case 0:
|
||||
Router.neglect(context, () => context.go('/home'));
|
||||
context.read<HomeViewModel>().init();
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
// Navigate to profile
|
||||
Router.neglect(context, () => context.go('/profile'));
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 740,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TenderDetailHeader(
|
||||
isScreenBig: true,
|
||||
detail: detail,
|
||||
),
|
||||
SizedBox(height: 32.0.h()),
|
||||
TenderDetailCard(detail: detail),
|
||||
SizedBox(height: 24.0.h()),
|
||||
TenderDetailActions(
|
||||
isScreenBig: true,
|
||||
detail: detail,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:go_router/go_router.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/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/view_models/home_view_model.dart';
|
||||
import 'package:tm_app/view_models/tender_detail_view_model.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_action.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_card.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_header.dart';
|
||||
import 'package:tm_app/views/shared/tablet_navigation_widget.dart';
|
||||
|
||||
class TenderDetailTabletPage extends StatefulWidget {
|
||||
final String tenderId;
|
||||
@@ -74,9 +76,54 @@ class _TenderDetailTabletPageState extends State<TenderDetailTabletPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final GlobalKey<ScaffoldState> key = GlobalKey();
|
||||
return Scaffold(
|
||||
key: key,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
appBar: _buildAppBar(context),
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(64),
|
||||
child: AppBar(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
elevation: 0,
|
||||
titleSpacing: 0,
|
||||
leading: Padding(
|
||||
padding: EdgeInsetsDirectional.only(start: 24.0.w()),
|
||||
child: SvgPicture.asset(AssetsManager.logoSmall),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Padding(
|
||||
padding: EdgeInsetsDirectional.only(end: 24.0.w()),
|
||||
child: SvgPicture.asset(
|
||||
AssetsManager.menu,
|
||||
height: 32.0.w(),
|
||||
width: 32.0.w(),
|
||||
),
|
||||
),
|
||||
onPressed: () => key.currentState!.openDrawer(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
drawer: TabletNavigationWidget(
|
||||
currentIndex: 1, // Home is index 0
|
||||
onTabChanged: (index) {
|
||||
// Handle navigation to other tabs
|
||||
switch (index) {
|
||||
case 0:
|
||||
Router.neglect(context, () => context.go('/home'));
|
||||
context.read<HomeViewModel>().init();
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
// Navigate to profile
|
||||
context.pop();
|
||||
Router.neglect(context, () => context.go('/profile'));
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
body: Consumer<TenderDetailViewModel>(
|
||||
builder: (context, tenderViewModel, child) {
|
||||
if (tenderViewModel.isLoading) {
|
||||
@@ -118,31 +165,4 @@ class _TenderDetailTabletPageState extends State<TenderDetailTabletPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
PreferredSizeWidget _buildAppBar(BuildContext context) {
|
||||
return PreferredSize(
|
||||
preferredSize: const Size.fromHeight(60),
|
||||
child: AppBar(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
elevation: 0,
|
||||
titleSpacing: 0,
|
||||
leading: IconButton(
|
||||
icon: SvgPicture.asset(
|
||||
AssetsManager.arrowLeft,
|
||||
height: 24.0.w(),
|
||||
width: 24.0.w(),
|
||||
),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: Text(
|
||||
AppStrings.tenderDetailTitle,
|
||||
style: TextStyle(
|
||||
color: AppColors.grey70,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 20.0.sp(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,83 +21,7 @@ class TenderDetailActions extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return isScreenBig
|
||||
? Row(
|
||||
children: [
|
||||
Spacer(),
|
||||
Consumer<TenderDetailViewModel>(
|
||||
builder: (context, viewModel, child) {
|
||||
return viewModel.isRejectApprovalLoading
|
||||
? BaseButton(
|
||||
isEnabled: true,
|
||||
text: AppStrings.tenderRejectButton,
|
||||
textColor: AppColors.red10,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
borderWidth: 1,
|
||||
onPressed: () {},
|
||||
width: 120.0.w(),
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: true,
|
||||
text: AppStrings.tenderRejectButton,
|
||||
textColor: AppColors.red10,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
borderWidth: 1,
|
||||
onPressed: () {
|
||||
viewModel.rejectTenderApproval(
|
||||
tenderId: detail.id!,
|
||||
submissionMode: 'self-apply',
|
||||
);
|
||||
},
|
||||
width: 120.0.w(),
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
Consumer<TenderDetailViewModel>(
|
||||
builder: (context, viewModel, child) {
|
||||
return viewModel.isSubmitApprovalLoading
|
||||
? BaseButton(
|
||||
isEnabled: true,
|
||||
text: AppStrings.tenderSubmitButton,
|
||||
backgroundColor: AppColors.lightBlue,
|
||||
textColor: AppColors.mainBlue,
|
||||
onPressed: () {},
|
||||
width: 120.0.w(),
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: true,
|
||||
text: AppStrings.tenderSubmitButton,
|
||||
backgroundColor: AppColors.lightBlue,
|
||||
textColor: AppColors.mainBlue,
|
||||
onPressed: () {
|
||||
if (viewModel.status == 'submitted') {
|
||||
viewModel.submitTenderApproval(
|
||||
tenderId: detail.id!,
|
||||
submissionMode: 'self-apply',
|
||||
);
|
||||
} else {
|
||||
showModalBottomSheet(
|
||||
isDismissible: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SelectSubmissionBottomSheet(
|
||||
onConfirm: (value) {
|
||||
viewModel.submitTenderApproval(
|
||||
tenderId: detail.id!,
|
||||
submissionMode: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
width: 120.0.w(),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
? _webActions()
|
||||
: Column(
|
||||
children: [
|
||||
Consumer<TenderDetailViewModel>(
|
||||
@@ -180,4 +104,84 @@ class TenderDetailActions extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Row _webActions() {
|
||||
return Row(
|
||||
children: [
|
||||
Spacer(),
|
||||
Consumer<TenderDetailViewModel>(
|
||||
builder: (context, viewModel, child) {
|
||||
return viewModel.isRejectApprovalLoading
|
||||
? BaseButton(
|
||||
isEnabled: true,
|
||||
text: AppStrings.tenderRejectButton,
|
||||
textColor: AppColors.red10,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
borderWidth: 1,
|
||||
onPressed: () {},
|
||||
width: 120.0.w(),
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: true,
|
||||
text: AppStrings.tenderRejectButton,
|
||||
textColor: AppColors.red10,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
borderWidth: 1,
|
||||
onPressed: () {
|
||||
viewModel.rejectTenderApproval(
|
||||
tenderId: detail.id!,
|
||||
submissionMode: 'self-apply',
|
||||
);
|
||||
},
|
||||
width: 120.0.w(),
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
Consumer<TenderDetailViewModel>(
|
||||
builder: (context, viewModel, child) {
|
||||
return viewModel.isSubmitApprovalLoading
|
||||
? BaseButton(
|
||||
isEnabled: true,
|
||||
text: AppStrings.tenderSubmitButton,
|
||||
backgroundColor: AppColors.lightBlue,
|
||||
textColor: AppColors.mainBlue,
|
||||
onPressed: () {},
|
||||
width: 120.0.w(),
|
||||
)
|
||||
: BaseButton(
|
||||
isEnabled: true,
|
||||
text: AppStrings.tenderSubmitButton,
|
||||
backgroundColor: AppColors.lightBlue,
|
||||
textColor: AppColors.mainBlue,
|
||||
onPressed: () {
|
||||
if (viewModel.status == 'submitted') {
|
||||
viewModel.submitTenderApproval(
|
||||
tenderId: detail.id!,
|
||||
submissionMode: 'self-apply',
|
||||
);
|
||||
} else {
|
||||
showModalBottomSheet(
|
||||
isDismissible: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SelectSubmissionBottomSheet(
|
||||
onConfirm: (value) {
|
||||
viewModel.submitTenderApproval(
|
||||
tenderId: detail.id!,
|
||||
submissionMode: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
width: 120.0.w(),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,9 @@ class TenderActionButtonsRow extends StatelessWidget {
|
||||
|
||||
Widget _rejectButton(TendersViewModel viewModel) {
|
||||
// Find approval for this specific tender
|
||||
if (tender.id == null) return const SizedBox.shrink();
|
||||
if (tender.id == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final approval = viewModel.getTenderApprovalForTender(tender.id!);
|
||||
final isRejected = approval?.status == 'rejected';
|
||||
@@ -101,7 +103,9 @@ class TenderActionButtonsRow extends StatelessWidget {
|
||||
|
||||
Widget _submitButton(TendersViewModel viewModel, BuildContext context) {
|
||||
// Find approval for this specific tender
|
||||
if (tender.id == null) return const SizedBox.shrink();
|
||||
if (tender.id == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final approval = viewModel.getTenderApprovalForTender(tender.id!);
|
||||
final isApproved = approval?.status == 'submitted';
|
||||
@@ -172,7 +176,9 @@ class TenderActionButtonsRow extends StatelessWidget {
|
||||
|
||||
Widget _dislikeButton(TendersViewModel viewModel) {
|
||||
// Find feedback for this specific tender
|
||||
if (tender.id == null) return const SizedBox.shrink();
|
||||
if (tender.id == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final feedback = viewModel.getFeedbackForTender(tender.id!);
|
||||
final isDisliked = feedback?.feedbackType == 'dislike';
|
||||
@@ -214,7 +220,9 @@ class TenderActionButtonsRow extends StatelessWidget {
|
||||
|
||||
Widget _likeButton(TendersViewModel viewModel) {
|
||||
// Find feedback for this specific tender
|
||||
if (tender.id == null) return const SizedBox.shrink();
|
||||
if (tender.id == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final feedback = viewModel.getFeedbackForTender(tender.id!);
|
||||
final isLiked = feedback?.feedbackType == 'like';
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/core/constants/strings.dart';
|
||||
import 'package:tm_app/core/theme/colors.dart';
|
||||
@@ -9,6 +11,9 @@ import 'package:tm_app/views/your_tenders/widgets/approved_tenders.dart';
|
||||
import 'package:tm_app/views/your_tenders/widgets/tablet_desktop_appbar.dart';
|
||||
import 'package:tm_app/views/your_tenders/widgets/tenders_submitted.dart';
|
||||
|
||||
import '../../../core/constants/assets.dart';
|
||||
import '../../shared/tablet_navigation_widget.dart';
|
||||
|
||||
class YourTendersTabletPage extends StatefulWidget {
|
||||
const YourTendersTabletPage({super.key});
|
||||
|
||||
@@ -38,15 +43,59 @@ class _YourTendersTabletPageState extends State<YourTendersTabletPage>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final GlobalKey<ScaffoldState> key = GlobalKey();
|
||||
return Scaffold(
|
||||
key: key,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(64),
|
||||
child: AppBar(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
elevation: 0,
|
||||
titleSpacing: 0,
|
||||
leading: Padding(
|
||||
padding: EdgeInsetsDirectional.only(start: 24.0.w()),
|
||||
child: SvgPicture.asset(AssetsManager.logoSmall),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Padding(
|
||||
padding: EdgeInsetsDirectional.only(end: 24.0.w()),
|
||||
child: SvgPicture.asset(
|
||||
AssetsManager.menu,
|
||||
height: 32.0.w(),
|
||||
width: 32.0.w(),
|
||||
),
|
||||
),
|
||||
onPressed: () => key.currentState!.openDrawer(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
drawer: TabletNavigationWidget(
|
||||
currentIndex: 1, // Home is index 0
|
||||
onTabChanged: (index) {
|
||||
// Handle navigation to other tabs
|
||||
switch (index) {
|
||||
case 0:
|
||||
Router.neglect(context, () => context.go('/home'));
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
// Navigate to profile
|
||||
context.pop();
|
||||
Router.neglect(context, () => context.go('/profile'));
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 720,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 64.0.h()),
|
||||
SizedBox(height: 64.0),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.0.w()),
|
||||
child: TabletDesktopAppbar(),
|
||||
|
||||
Reference in New Issue
Block a user