Browse Source

修复tab 文字颜色问题

liuyuqi-cnb 1 month ago
parent
commit
512eee5330
1 changed files with 12 additions and 19 deletions
  1. 12 19
      lib/index_page.dart

+ 12 - 19
lib/index_page.dart

@@ -1,4 +1,5 @@
 import 'package:flutter/material.dart';
+import 'package:flutter_clock/model/constants.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';
@@ -31,10 +32,10 @@ class _IndexPageState extends State<IndexPage>
     
     // 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))),  
+      Tab(text: 'Alarm'),
+      Tab(text: 'Clock'),
+      Tab(text: 'Stopwatch'),
+      Tab(text: 'Timer'),  
     ];
     
   }
@@ -51,26 +52,18 @@ class _IndexPageState extends State<IndexPage>
       appBar: AppBar(
         backgroundColor: Colors.white,
         elevation: 0,
-        toolbarHeight: 50.h,
+        toolbarHeight: 60.h,
         title: TabBar(
           controller: _tabController,
           tabs: _tabs,
-          labelColor: Colors.blue,
-          unselectedLabelColor: Colors.black,
-          indicatorColor: Colors.blue,
+          labelColor: kPrimaryColor,
+          unselectedLabelColor: kGrayColor,
+          indicatorColor: kPrimaryColor,
           indicatorWeight: 3.h,
-          labelStyle: TextStyle(fontWeight: FontWeight.bold),
-          unselectedLabelStyle: TextStyle(fontWeight: FontWeight.normal),
+          labelPadding: EdgeInsets.symmetric(horizontal: 4.w),
+          labelStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 15.sp),
+          unselectedLabelStyle: TextStyle(fontWeight: FontWeight.normal, fontSize: 15.sp),
         ),
-        // actions: [
-        //   IconButton(
-        //     icon: Icon(Icons.more_vert, color: Colors.black),
-        //     onPressed: () {
-        //       // More options menu
-
-        //     },
-        //   ),
-        // ],
       ),
       body: TabBarView(
         controller: _tabController,