G-EIP-700-TLS-7-1-eip-steph.../lib/features/home/home_page.dart

90 lines
2.9 KiB
Dart

import 'package:dialer/features/composition/composition.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
import 'package:dialer/features/Settings/settings.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
late TabController _tabController;
@override
void initState() {
super.initState();
// Update the length to 5
_tabController = TabController(length: 5, 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: Stack(
children: [
TabBarView(
controller: _tabController,
children: const [
FavoritePage(),
HistoryPage(),
ContactPage(),
CompositionPage(),
SettingsPage(), // Ensure this matches the number of tabs
],
),
if (_tabController.index != 3)
Positioned(
right: 20,
bottom: 20,
child: FloatingActionButton(
onPressed: () {
_tabController.animateTo(3);
},
backgroundColor: Colors.blue,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(45),
),
child: const Icon(Icons.dialpad, color: Colors.white),
),
),
],
),
bottomNavigationBar: Container(
color: Colors.black,
child: TabBar(
controller: _tabController,
tabs: [
Tab(icon: Icon(_tabController.index == 0 ? Icons.star : Icons.star_border)),
Tab(icon: Icon(_tabController.index == 1 ? Icons.access_time_filled : Icons.access_time_outlined)),
Tab(icon: Icon(_tabController.index == 2 ? Icons.contacts : Icons.contacts_outlined)),
Tab(icon: Icon(_tabController.index == 3 ? Icons.dialpad : Icons.dialpad_outlined)),
Tab(icon: Icon(_tabController.index == 4 ? Icons.settings : Icons.settings_outlined)), // Settings icon
],
labelColor: Colors.white,
unselectedLabelColor: Colors.grey,
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: Colors.white,
),
),
);
}
}