Refactor: rename BottomNavigation and update TendersScreen structure
- Renamed BottomNavigation to TenderBottomNavigation for clarity. - Updated TendersScreen to use TenderBottomNavigation. - Converted TendersScreen from StatelessWidget to StatefulWidget to manage tab state. - Added TabController for handling tab changes and improved layout with SafeArea and PageView.
This commit is contained in:
@@ -1,40 +1,82 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/constants/assets.dart';
|
||||
import '../../common/widgets/bottom_navigation.dart';
|
||||
import '../../core/constants/colors.dart';
|
||||
import '../../core/constants/strings.dart';
|
||||
import '../../core/utils/size_config.dart';
|
||||
import 'models/tender_model.dart';
|
||||
import 'widgets/widgets.dart';
|
||||
|
||||
class TendersScreen extends StatelessWidget {
|
||||
class TendersScreen extends StatefulWidget {
|
||||
const TendersScreen({super.key});
|
||||
|
||||
@override
|
||||
State<TendersScreen> createState() => _TendersScreenState();
|
||||
}
|
||||
|
||||
class _TendersScreenState extends State<TendersScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final TabController controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller = TabController(length: 2, vsync: this);
|
||||
// Add listener to rebuild when tab changes
|
||||
controller.addListener(() {
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w(), vertical: 24.0.h()),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
bottomNavigationBar: TenderBottomNavigation(),
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.0.w(),
|
||||
vertical: 24.0.h(),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
AppStrings.tendersTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 20.0.sp(),
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.grey70,
|
||||
TenderAppBar(),
|
||||
SizedBox(height: 24.0.h()),
|
||||
|
||||
MainTabBar(controller: controller),
|
||||
SizedBox(height: 24.0.h()),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 762.0.h(),
|
||||
child: PageView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: sampleTenders.length,
|
||||
itemBuilder: (context, index) {
|
||||
final tender = sampleTenders[index];
|
||||
|
||||
return TenderCard(
|
||||
date: tender.date,
|
||||
deadline: tender.deadline,
|
||||
title: tender.title,
|
||||
description: tender.description,
|
||||
tenderId: tender.tenderId,
|
||||
location: tender.location,
|
||||
country: tender.country,
|
||||
matchPercentage: tender.matchPercentage,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Image.asset(
|
||||
AssetsManager.tenderLogo,
|
||||
width: 59.0.w(),
|
||||
height: 28.0.h(),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user