只保留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: '设置'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../models/song_model.dart';
|
||||
import '../services/audio_service.dart';
|
||||
import '../widgets/full_player_page.dart';
|
||||
|
||||
class PlaylistPage extends StatelessWidget {
|
||||
const PlaylistPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final songs = Song.placeholderSongs; // 后续替换成 WebDAV/SAF 列表
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('我的清听'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.shuffle),
|
||||
onPressed: () {}, // 以后实现随机
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: songs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final song = songs[index];
|
||||
return ListTile(
|
||||
leading: const CircleAvatar(
|
||||
backgroundColor: Color(0xFF2A3332),
|
||||
child: Icon(Icons.audiotrack, size: 20, color: Colors.white54),
|
||||
),
|
||||
title: Text(song.title,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500)),
|
||||
subtitle: Text(song.artist,
|
||||
style: TextStyle(color: Colors.grey[400], fontSize: 13)),
|
||||
trailing: const Icon(Icons.more_vert, color: Colors.grey),
|
||||
onTap: () {
|
||||
// 1. 先更新服务,显示迷你条
|
||||
context.read<AudioService>().playSong(song);
|
||||
// 2. 再跳转全屏播放器
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const FullPlayerPage()),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SettingsPage extends StatelessWidget {
|
||||
const SettingsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('设置')),
|
||||
body: ListView(
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
_buildTile(
|
||||
icon: Icons.folder_open_outlined,
|
||||
title: '本地文件 (SAF)',
|
||||
subtitle: '通过系统文件选择器导入',
|
||||
onTap: () {
|
||||
// 🟢 这里粘贴你旧项目的 SAF 逻辑
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('待接入 SAF 逻辑')),
|
||||
);
|
||||
},
|
||||
),
|
||||
_buildTile(
|
||||
icon: Icons.cloud_outlined,
|
||||
title: 'WebDAV 云盘',
|
||||
subtitle: '连接你的 NAS 或网盘',
|
||||
onTap: () {
|
||||
// 🟢 这里调用你现成的 WebDAV 通道
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('待接入 WebDAV 逻辑')),
|
||||
);
|
||||
},
|
||||
),
|
||||
_buildTile(
|
||||
icon: Icons.equalizer_outlined,
|
||||
title: '均衡器',
|
||||
subtitle: '简单低音增强 (后续)',
|
||||
onTap: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildTile(
|
||||
{required IconData icon,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required VoidCallback onTap}) {
|
||||
return ListTile(
|
||||
leading: Icon(icon, color: const Color(0xFF7C9A9E)),
|
||||
title: Text(title),
|
||||
subtitle: Text(subtitle, style: const TextStyle(fontSize: 12)),
|
||||
trailing: const Icon(Icons.chevron_right, color: Colors.grey),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user