Files
tm_app/lib/views/shared/tablet_navigation_widget.dart
T
amirrezaghabeli ae8501dc36 Refactor navigation structure and update asset references
- Swapped routes for Profile and Notification branches in the app's navigation structure.
- Updated the current index for navigation items in TabletNavigationWidget and related pages to reflect the new routing.
- Added a new logo SVG asset to the asset manager for branding consistency.
- Adjusted the pubspec.lock file to downgrade several package versions for compatibility.
2025-11-22 15:29:46 +03:30

189 lines
6.1 KiB
Dart

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/assets.dart';
import 'package:tm_app/core/services/tab_navigation_service.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/data/services/notification_state_service.dart';
import 'package:tm_app/views/home/strings/home_strings.dart';
import 'package:tm_app/views/profile/strings/profile_strings.dart';
import 'package:tm_app/views/tenders/strings/tenders_strings.dart';
import '../../core/routes/app_routes.dart';
class TabletNavigationWidget extends StatelessWidget {
const TabletNavigationWidget({required this.currentIndex, super.key});
final int currentIndex;
@override
Widget build(BuildContext context) {
return Container(
width: 200.0.w(),
height: double.infinity,
color: AppColors.backgroundColor,
child: Column(
children: [
SizedBox(height: 48.0.h()),
_navigationItem(
context: context,
text: HomeStrings.home,
isActive: currentIndex == 0,
onTap: () {
if (currentIndex == 0) {
return;
} else {
context.pop();
Router.neglect(
context,
() => const HomeRouteData().go(context),
);
context.read<TabNavigationService>().onTabSelected(0);
}
},
iconPath: AssetsManager.home,
activeIconPath: AssetsManager.homeActive,
),
_navigationItem(
context: context,
text: TendersStrings.tendersTitle,
isActive: currentIndex == 1,
onTap: () {
if (currentIndex == 1) {
return;
} else {
context.pop();
Router.neglect(
context,
() => const TendersRouteData().go(context),
);
context.read<TabNavigationService>().onTabSelected(1);
}
},
iconPath: AssetsManager.tenders,
activeIconPath: AssetsManager.tendersActive,
),
// _navigationItem(
// context: context,
// text: ProfileStrings.contracts,
// isActive: currentIndex == 2,
// onTap: () {
// if (currentIndex == 2) {
// return;
// } else {
// // context.pop();
// // Router.neglect(context, () => ProfileRouteData().go(context));
// }
// },
// iconPath: AssetsManager.contracts,
// activeIconPath: AssetsManager.contracts,
// ),
_navigationItem(
context: context,
text: ProfileStrings.notifications,
isActive: currentIndex == 2,
onTap: () {
if (currentIndex == 2) {
return;
} else {
context.pop();
Router.neglect(
context,
() => const NotificationRouteData().go(context),
);
context.read<TabNavigationService>().onTabSelected(2);
}
},
iconPath: AssetsManager.notify,
activeIconPath: AssetsManager.notifyActive,
),
_navigationItem(
context: context,
text: ProfileStrings.profileTitle,
isActive: currentIndex == 3,
onTap: () {
if (currentIndex == 3) {
return;
} else {
context.pop();
Router.neglect(
context,
() => const ProfileRouteData().go(context),
);
}
},
iconPath: AssetsManager.profile,
activeIconPath: AssetsManager.profileActive,
),
],
),
);
}
Widget _navigationItem({
required BuildContext context,
required String text,
required bool isActive,
required VoidCallback onTap,
required String iconPath,
required String activeIconPath,
}) {
final hasUnread =
context.watch<NotificationStateService>().hasUnreadNotification;
return InkWell(
onTap: onTap,
child: Container(
width: 200.0.w(),
height: 64.0.h(),
decoration: BoxDecoration(color: AppColors.backgroundColor),
child: Padding(
padding: EdgeInsetsDirectional.only(start: 24.0.w()),
child: Row(
children: [
Stack(
clipBehavior: Clip.none,
children: [
SvgPicture.asset(isActive ? activeIconPath : iconPath),
if (text == ProfileStrings.notifications && hasUnread)
Positioned(
right: -5,
top: -2,
child: Container(
width: 8,
height: 8,
decoration: const BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
),
),
],
),
SizedBox(width: 12.0.w()),
Text(
text,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: isActive ? FontWeight.w600 : FontWeight.w400,
color: isActive ? AppColors.primaryColor : AppColors.grey60,
),
),
const Spacer(),
Container(
width: 4.0.w(),
height: 64.0.h(),
decoration: BoxDecoration(
color: isActive ? AppColors.primaryColor : Colors.transparent,
),
),
],
),
),
),
);
}
}