123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- import 'package:flutter/material.dart';
- import 'package:flutter_clock/pages/alarm_page.dart';
- import 'package:flutter_clock/pages/clock_page.dart';
- import 'package:flutter_clock/pages/stopwatch_page.dart';
- import 'package:flutter_clock/pages/timer/timer_page.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- /// Description: main page
- /// Time : 04/06/2025 Sunday
- /// Author : liuyuqi.gov@msn.cn
- class IndexPage extends StatefulWidget {
- @override
- State<StatefulWidget> createState() {
- return _IndexPageState();
- }
- }
- class _IndexPageState extends State<IndexPage>
- with SingleTickerProviderStateMixin {
- late TabController _tabController;
- late List<Widget> _tabs;
- @override
- void initState() {
- super.initState();
- _tabController = TabController(
- length: 4,
- vsync: this,
- initialIndex: 3); // Timer tab is selected by default
-
- // Initialize tabs with screen adaptation
- _tabs = [
- Tab(child: Text('Alarm', style: TextStyle(fontSize: 16.sp))),
- Tab(child: Text('Clock', style: TextStyle(fontSize: 16.sp))),
- Tab(child: Text('Stopwatch', style: TextStyle(fontSize: 16.sp))),
- Tab(child: Text('Timer', style: TextStyle(fontSize: 16.sp))),
- ];
-
- }
- @override
- void dispose() {
- _tabController.dispose();
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- backgroundColor: Colors.white,
- elevation: 0,
- toolbarHeight: 50.h,
- title: TabBar(
- controller: _tabController,
- tabs: _tabs,
- labelColor: Colors.blue,
- unselectedLabelColor: Colors.black,
- indicatorColor: Colors.blue,
- indicatorWeight: 3.h,
- ),
- // actions: [
- // IconButton(
- // icon: Icon(Icons.more_vert, color: Colors.black),
- // onPressed: () {
- // // More options menu
- // },
- // ),
- // ],
- ),
- body: TabBarView(
- controller: _tabController,
- children: [
- AlarmPage(),
- ClockPage(),
- StopwatchPage(),
- TimerPage(),
- ],
- ),
- );
- }
- }
|