2024-09-16 15:07:04 +00:00
|
|
|
import 'package:dialer/pages/contact.dart';
|
|
|
|
import 'package:dialer/pages/favorites.dart';
|
|
|
|
import 'package:dialer/pages/history.dart';
|
2024-10-02 22:03:47 +00:00
|
|
|
import 'package:dialer/pages/composition.dart';
|
2024-09-16 15:07:04 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
|
|
|
|
late TabController _tabController;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2024-10-02 22:03:47 +00:00
|
|
|
_tabController = TabController(length: 4, vsync: this, initialIndex: 1);
|
2024-09-16 15:07:04 +00:00
|
|
|
_tabController.addListener(_handleTabIndex);
|
2024-10-02 22:03:47 +00:00
|
|
|
|
2024-09-16 15:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_tabController.removeListener(_handleTabIndex);
|
|
|
|
_tabController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
void _handleTabIndex() {
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2024-10-02 22:03:47 +00:00
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: Colors.black,
|
|
|
|
body: Stack(
|
|
|
|
children: [
|
|
|
|
TabBarView(
|
2024-09-16 15:07:04 +00:00
|
|
|
controller: _tabController,
|
2024-10-02 22:03:47 +00:00
|
|
|
children: const [
|
|
|
|
FavoritePage(),
|
|
|
|
HistoryPage(),
|
|
|
|
ContactPage(),
|
|
|
|
CompositionPage(),
|
2024-09-16 15:07:04 +00:00
|
|
|
],
|
|
|
|
),
|
2024-10-02 22:03:47 +00:00
|
|
|
if (_tabController.index != 3)
|
|
|
|
Positioned(
|
|
|
|
right: 20, // Adjust the right position as needed
|
|
|
|
bottom: 20, // Adjust the bottom position as needed
|
|
|
|
child: FloatingActionButton(
|
|
|
|
onPressed: () {
|
|
|
|
// Handle button press, like navigating to the composition page
|
|
|
|
_tabController.animateTo(3); // Navigates to the CompositionPage (index 3)
|
|
|
|
},
|
|
|
|
backgroundColor: Colors.blue,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(45), // Rounded corners for the square button
|
|
|
|
),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: 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.create : Icons.create_outlined)),
|
|
|
|
],
|
|
|
|
labelColor: Colors.white,
|
|
|
|
unselectedLabelColor: Colors.grey,
|
|
|
|
indicatorSize: TabBarIndicatorSize.label,
|
|
|
|
indicatorColor: Colors.white,
|
2024-09-16 15:07:04 +00:00
|
|
|
),
|
2024-10-02 22:03:47 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-09-16 15:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
const MyHomePage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
_MyHomePageState createState() => _MyHomePageState();
|
|
|
|
}
|