This repository has been archived on 2024-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
dialer/lib/features/home/home_page.dart
2024-10-18 22:45:35 +03:00

67 lines
2.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:dialer/features/contacts/contact_page.dart'; // Import ContactPage
import 'package:dialer/features/favorites/favorites_page.dart'; // Import FavoritePage
import 'package:dialer/features/history/history_page.dart'; // Import HistoryPage
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
late TabController _tabController;
@override
void initState() {
super.initState();
// Update TabController to handle 3 tabs (Favorites, History, Contacts)
_tabController = TabController(length: 3, vsync: this, initialIndex: 1);
_tabController.addListener(_handleTabIndex);
}
@override
void dispose() {
_tabController.removeListener(_handleTabIndex);
_tabController.dispose();
super.dispose();
}
void _handleTabIndex() {
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: TabBarView(
controller: _tabController,
// Add the new ContactPage in the TabBarView
children: [
FavoritePage(), // Favorites page
HistoryPage(), // History page
ContactPage(), // New Contacts page
],
),
bottomNavigationBar: Container(
color: Colors.black,
child: TabBar(
controller: _tabController,
tabs: [
Tab(icon: Icon(_tabController.index == 0 ? Icons.star : Icons.star_border)), // Favorite tab
Tab(icon: Icon(_tabController.index == 1 ? Icons.access_time_filled : Icons.access_time_outlined)), // History tab
Tab(icon: Icon(_tabController.index == 2 ? Icons.contacts : Icons.contacts_outlined)), // Contact tab
],
labelColor: Colors.white,
unselectedLabelColor: Colors.grey,
indicatorSize: TabBarIndicatorSize.label,
indicatorPadding: const EdgeInsets.only(bottom: -0), // Adjust padding if needed
indicatorColor: Colors.white, // White horizontal indicator line
),
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
_MyHomePageState createState() => _MyHomePageState();
}