fix web bug and navigations

This commit is contained in:
amirrezaghabeli
2025-08-27 07:38:09 +03:30
parent 9b87221e3e
commit 18834e492d
5 changed files with 270 additions and 147 deletions
+77 -35
View File
@@ -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,
),
],
),
),
),
),
),
),
),
),
);
},
],
);
},
),
),
);
}
+49 -29
View File
@@ -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(),
);
},
),
],
);
}
}