feat:增加主题颜色和暗黑模式

This commit is contained in:
2025-11-11 20:02:09 +08:00
parent 703a5a6aeb
commit 741d6842b8
13 changed files with 446 additions and 183 deletions

View File

@@ -28,20 +28,38 @@ class _MainScreenState extends State<MainScreen> {
return Scaffold(
drawer: const AppDrawer(),
appBar: AppBar(
title: Text(_getAppBarTitle(appProvider.currentIndex)),
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
title: Text(_getAppBarTitle(appProvider.currentTab)),
backgroundColor: Theme.of(context).colorScheme.primary,
foregroundColor: Theme.of(context).colorScheme.onPrimary,
elevation: 0,
),
body: _buildPage(appProvider.currentIndex),
bottomNavigationBar: BottomNavigationBar(
currentIndex: appProvider.currentIndex,
onTap: (index) => appProvider.changeTab(index),
type: BottomNavigationBarType.fixed,
backgroundColor: Colors.white,
items: navItems,
body: _buildPage(appProvider.currentTab),
bottomNavigationBar: Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.shadow.withAlpha(20),
blurRadius: 8,
offset: const Offset(0, -2),
),
],
),
child: BottomNavigationBar(
currentIndex: appProvider.currentTab,
onTap: (index) => appProvider.changeTab(index),
type: BottomNavigationBarType.fixed,
backgroundColor: Theme.of(context).colorScheme.surface,
selectedItemColor: Theme.of(context).colorScheme.primary,
unselectedItemColor: Theme.of(context).colorScheme.onSurface.withAlpha(120),
showSelectedLabels: true,
showUnselectedLabels: true,
items: navItems,
),
),
floatingActionButton: _buildFloatingButton(
context,
appProvider.currentTab,
),
floatingActionButton: _buildFloatingButton(appProvider.currentIndex),
);
},
);
@@ -59,7 +77,7 @@ class _MainScreenState extends State<MainScreen> {
}
}
Widget _buildFloatingButton(int index) {
Widget _buildFloatingButton(BuildContext context, int index) {
return FloatingActionButton(
onPressed: () => _onPressFloatingButton(index),
backgroundColor: Colors.transparent,
@@ -70,18 +88,7 @@ class _MainScreenState extends State<MainScreen> {
height: 50,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Colors.orange.shade300, Colors.orange.shade500],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
boxShadow: [
BoxShadow(
color: Colors.orange.shade100,
blurRadius: 12,
offset: Offset(0, 6),
),
],
color: Theme.of(context).colorScheme.primary,
),
child: Icon(Icons.add, color: Colors.white, size: 36),
),