只保留Android支持
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../services/audio_service.dart';
|
||||
import '../widgets/mini_player_bar.dart';
|
||||
import 'playlist_page.dart';
|
||||
import 'settings_page.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
int _currentIndex = 0;
|
||||
final List<Widget> _pages = const [
|
||||
PlaylistPage(),
|
||||
SettingsPage(),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 监听播放状态,只要有歌就显示迷你条
|
||||
final audioService = context.watch<AudioService>();
|
||||
final showMiniBar = audioService.currentSong != null;
|
||||
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: IndexedStack(
|
||||
index: _currentIndex,
|
||||
children: _pages,
|
||||
),
|
||||
),
|
||||
if (showMiniBar) const MiniPlayerBar(), // 底部迷你播放器
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _currentIndex,
|
||||
backgroundColor: const Color(0xFF1A1F1E),
|
||||
selectedItemColor: const Color(0xFFB8D4D0),
|
||||
unselectedItemColor: Colors.grey[600],
|
||||
onTap: (index) => setState(() => _currentIndex = index),
|
||||
items: const [
|
||||
BottomNavigationBarItem(icon: Icon(Icons.music_note), label: '歌单'),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.settings_outlined), label: '设置'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user