feat: 优化推荐页面

liao
Spark 8 months ago
parent 7f4a2a89cf
commit 6fcc6a1a38

File diff suppressed because one or more lines are too long

@ -7,12 +7,6 @@ import '../models/getRank_bean.dart';
import '../view_model/rank_view_model.dart'; import '../view_model/rank_view_model.dart';
import 'music_view.dart'; import 'music_view.dart';
import '../common_widget/Song_widegt.dart'; import '../common_widget/Song_widegt.dart';
import '../api/api_collection.dart';
import '../api/api_music_likes.dart';
import '../api/api_music_list.dart';
import '../models/universal_bean.dart';
import 'comment_view.dart';
import '../models/getMusicList_bean.dart';
class RankView extends StatefulWidget { class RankView extends StatefulWidget {
const RankView({super.key}); const RankView({super.key});
@ -53,6 +47,8 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
rankSingerName.clear(); rankSingerName.clear();
rankCoverPath.clear(); rankCoverPath.clear();
rankMusicPath.clear(); rankMusicPath.clear();
rankMid.clear();
songs.clear();
setState(() { setState(() {
List<int> ids = bean2.data!.map((data) => data.id!).toList(); List<int> ids = bean2.data!.map((data) => data.id!).toList();
@ -122,11 +118,6 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
fontSize: 40, fontSize: 40,
fontWeight: FontWeight.w500), fontWeight: FontWeight.w500),
), ),
// SizedBox(height: 10),
// Text(
// '2023/12/12更新 1期',
// style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
// ),
], ],
), ),
), ),
@ -269,25 +260,6 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
color: Colors.grey[100], color: Colors.grey[100],
child: const Icon(Icons.music_note, size: 30), child: const Icon(Icons.music_note, size: 30),
), ),
// loadingBuilder: (context, child, loadingProgress) {
// if (loadingProgress == null) return child;
// return Container(
// width: 60,
// height: 60,
// color: Colors.grey[100],
// child: Center(
// child: CircularProgressIndicator(
// strokeWidth: 2,
// valueColor: const AlwaysStoppedAnimation<Color>(
// Color(0xff429482)),
// value: loadingProgress.expectedTotalBytes != null
// ? loadingProgress.cumulativeBytesLoaded /
// loadingProgress.expectedTotalBytes!
// : null,
// ),
// ),
// );
// },
), ),
), ),
), ),
@ -321,21 +293,6 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
const SizedBox(width: 18), const SizedBox(width: 18),
], ],
), ),
// IconButton(
// onPressed: () {
// _bottomSheet(context, index);
// },
// icon: Image.asset(
// 'assets/img/More.png',
// width: 25,
// height: 25,
// errorBuilder: (context, error, stackTrace) {
// print('Error loading image: $error');
// return const Icon(Icons.error, size: 25);
// },
// ),
// ),
], ],
), ),
const SizedBox(height: 10) const SizedBox(height: 10)
@ -358,170 +315,4 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
), ),
); );
} }
Future _bottomSheet(BuildContext context, int index) {
return showModalBottomSheet(
context: context,
backgroundColor: Colors.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
),
builder: (context) => StatefulBuilder(
builder: (context, setState) {
//
bool likesnot = songs[index].likes ?? false;
bool collectionsnot = songs[index].collection ?? false;
return Container(
height: 150,
padding: const EdgeInsets.only(top: 20),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
IconButton(
onPressed: (){},
icon: Image.asset("assets/img/list_add.png"),
iconSize: 60,
),
const Text("加入歌单")
],
),
Column(
children: [
IconButton(
onPressed: (){},
icon: Image.asset("assets/img/list_download.png"),
iconSize: 60,
),
const Text("下载")
],
),
Column(
children: [
IconButton(
onPressed: () async {
// 1. UI
setState(() {
collectionsnot = !collectionsnot;
songs[index].collection = collectionsnot;
});
// 2. API
UniversalBean response = await CollectionApiMusic().addCollection(
musicId: songs[index].id,
Authorization: AppData().currentToken,
);
// 3. API
if (response.code != 200) {
// API
setState(() {
collectionsnot = !collectionsnot;
songs[index].collection = collectionsnot;
});
} else {
// 4. API
downloadManager.updateSongInfo(
songs[index].id, // ID
collectionsnot, //
songs[index].likes ?? false //
);
}
},
icon: SizedBox(
width: 60,
height: 60,
child: Image.asset(
//
collectionsnot
? "assets/img/list_collection.png" //
: "assets/img/list_collection_un.png" //
),
),
),
const Text("收藏"),
],
),
Column(
children: [
IconButton(
onPressed: () async {
// 1. UI
setState(() {
likesnot = !likesnot;
songs[index].likes = likesnot;
});
// 2. API
UniversalBean response = await LikesApiMusic().likesMusic(
musicId: songs[index].id,
Authorization: AppData().currentToken,
);
// 3. API
if (response.code != 200) {
// API
setState(() {
likesnot = !likesnot;
songs[index].likes = likesnot;
});
} else {
// 4. API
downloadManager.updateSongInfo(
songs[index].id, // ID
songs[index].collection ?? false, //
likesnot //
);
}
},
icon: SizedBox(
width: 60,
height: 60,
child: Image.asset(
//
likesnot
? "assets/img/list_good.png" //
: "assets/img/list_good_un.png" //
),
),
),
const Text("点赞"),
],
),
Column(
children: [
IconButton(
onPressed: () {
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CommentView(
id: songs[index].id,
song: songs[index].title,
singer: songs[index].artist,
cover: songs[index].artistPic,
),
),
);
},
icon: Image.asset("assets/img/list_comment.png"),
iconSize: 60,
),
const Text("评论")
],
),
],
),
],
),
);
},
),
);
}
} }

@ -23,13 +23,36 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
List rankCoverPath = []; List rankCoverPath = [];
List rankMusicPath = []; List rankMusicPath = [];
List rankMid = []; List rankMid = [];
List<double> relevanceValues = [];
List<Song> songs = []; List<Song> songs = [];
final downloadManager = Get.put(DownloadManager()); final downloadManager = Get.put(DownloadManager());
late AnimationController _animationController; late AnimationController _animationController;
late List<Animation<double>> _circleFadeInAnimations; late List<Animation<double>> _circleFadeInAnimations;
late List<AnimationController> _dotAnimationControllers; late List<AnimationController> _dotAnimationControllers;
//
final circleVerticalOffset = -0.08; // 8%
final circleHorizontalOffset = 0.0;
// 线
final lineVerticalOffset = -0.06; // 6%
final lineHorizontalOffset = 0.0;
//
final refreshButtonVerticalOffset = -0.06;
final refreshButtonHorizontalOffset = 0.0;
//
final effectVerticalOffset = 0.035;
final effectHorizontalOffset = 0.09;
//
int? selectedIndex; //
late AnimationController _expandController;
late Animation<double> _expandAnimation;
//
final expandedCircleVerticalOffset = -0.08; // 8%
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -42,6 +65,23 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
_circleFadeInAnimations = []; _circleFadeInAnimations = [];
_dotAnimationControllers = []; _dotAnimationControllers = [];
//
_expandController = AnimationController(
duration: const Duration(milliseconds: 500), //
vsync: this,
);
_expandAnimation = CurvedAnimation(
parent: _expandController,
curve: Curves.easeOutQuart, // 使线
);
}
@override
void dispose() {
_expandController.dispose();
super.dispose();
} }
Future<void> _loadRecommendedSongs() async { Future<void> _loadRecommendedSongs() async {
@ -53,12 +93,6 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
RankBean bean2 = await GetRank().getRank(Authorization: AppData().currentToken); RankBean bean2 = await GetRank().getRank(Authorization: AppData().currentToken);
if (bean2.code != 200) return; if (bean2.code != 200) return;
rankNames.clear();
rankSingerName.clear();
rankCoverPath.clear();
rankMusicPath.clear();
relevanceValues.clear();
setState(() { setState(() {
List<int> ids = bean2.data!.take(6).map((data) => data.id!).toList(); List<int> ids = bean2.data!.take(6).map((data) => data.id!).toList();
rankNames = bean2.data!.take(6).map((data) => data.name!).toList(); rankNames = bean2.data!.take(6).map((data) => data.name!).toList();
@ -80,7 +114,6 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
collection: null, collection: null,
mid: rankMid[i], mid: rankMid[i],
)); ));
relevanceValues.add(0.75);
} }
}); });
} catch (e) { } catch (e) {
@ -111,7 +144,7 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
_circleFadeInAnimations.add(fadeIn); _circleFadeInAnimations.add(fadeIn);
final dotController = AnimationController( final dotController = AnimationController(
duration: Duration(milliseconds: (2000 - relevanceValues[i] * 1500).toInt()), duration: const Duration(milliseconds: 2000),
vsync: this, vsync: this,
)..repeat(reverse: true); )..repeat(reverse: true);
_dotAnimationControllers.add(dotController); _dotAnimationControllers.add(dotController);
@ -120,29 +153,47 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
_animationController.forward(from: 0); _animationController.forward(from: 0);
} }
double _generateRelevance() { double _getCircleSize(Size screenSize) {
return 0.6 + math.Random().nextDouble() * 0.4; return screenSize.width * 0.18;
} }
double _getCircleSize(double relevance, Size screenSize) {
return 0.08 * screenSize.width + (relevance * 80); //
}
//
Map<String, double> _getCirclePosition(int index, int totalItems, Size screenSize, Offset refreshButtonPosition) { Map<String, double> _getCirclePosition(int index, int totalItems, Size screenSize, Offset refreshButtonPosition) {
final radius = math.min(screenSize.width, screenSize.height) * 0.28; // final radius = screenSize.width * 0.28;
final angle = (index * 2 * math.pi / totalItems) - math.pi / 2; // final angle = (-math.pi / 2) + (index * 2 * math.pi / totalItems);
final circleSize = _getCircleSize(screenSize);
// 使
final centerX = screenSize.width / 2;
final centerY = screenSize.height / 2;
return { return {
'left': refreshButtonPosition.dx + radius * math.cos(angle), // 'left': centerX + radius * math.cos(angle) - (circleSize / 2) + (screenSize.width * circleHorizontalOffset),
'top': refreshButtonPosition.dy + radius * math.sin(angle), // 'top': centerY + radius * math.sin(angle) - (circleSize / 2) + (screenSize.height * circleVerticalOffset),
}; };
} }
//
Color _getCircleColor(double relevance) { Color _getCircleColor(double relevance) {
return Color(0xFFB2FF59).withOpacity(0.3); // 使绿 return Color(0xFFB2FF59).withOpacity(0.3);
}
Offset _getEffectPosition(Offset basePosition, double progress, double angle, double radius, Size size) {
return Offset(
basePosition.dx - progress * (radius - 60) * math.cos(angle) + (size.width * effectHorizontalOffset),
basePosition.dy - progress * (radius - 60) * math.sin(angle) + (size.height * effectVerticalOffset),
);
}
//
void _handleCircleTap(int index) {
setState(() {
if (selectedIndex == index) {
selectedIndex = null;
_expandController.reverse();
} else {
selectedIndex = index;
_expandController.forward(from: 0.0);
}
});
} }
@override @override
@ -150,7 +201,6 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
final safeAreaPadding = MediaQuery.of(context).padding; final safeAreaPadding = MediaQuery.of(context).padding;
//
final refreshButtonPosition = Offset(screenSize.width / 2, screenSize.height / 2); final refreshButtonPosition = Offset(screenSize.width / 2, screenSize.height / 2);
return Container( return Container(
@ -163,7 +213,14 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
child: Scaffold( child: Scaffold(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: SafeArea( body: SafeArea(
child: LayoutBuilder(
builder: (context, constraints) {
return SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: Container(
height: constraints.maxHeight,
child: Stack( child: Stack(
fit: StackFit.loose,
children: [ children: [
Positioned( Positioned(
top: 20, top: 20,
@ -184,44 +241,55 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
child: Stack( child: Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
// 线
CustomPaint( CustomPaint(
size: Size(screenSize.width, screenSize.height), size: Size(screenSize.width, screenSize.height),
painter: LinePainter( painter: selectedIndex == null ? LinePainter(
recommendedSongs: songs, recommendedSongs: songs,
relevanceValues: relevanceValues,
screenSize: screenSize, screenSize: screenSize,
lineAnimation: _animationController, lineAnimation: _animationController,
refreshButtonPosition: refreshButtonPosition, refreshButtonPosition: refreshButtonPosition,
verticalOffset: lineVerticalOffset,
horizontalOffset: lineHorizontalOffset,
) : null,
), ),
),
//
if (!isLoading) if (!isLoading)
Stack( Stack(
children: List.generate(6, (index) { children: List.generate(6, (index) {
final song = songs[index]; final song = songs[index];
final relevance = relevanceValues[index]; final baseSize = _getCircleSize(screenSize);
final size = _getCircleSize(relevance, screenSize);
final position = _getCirclePosition(index, songs.length, screenSize, refreshButtonPosition); final position = _getCirclePosition(index, songs.length, screenSize, refreshButtonPosition);
return AnimatedBuilder(
animation: _expandAnimation,
builder: (context, child) {
final expandedSize = selectedIndex == index
? math.min(
baseSize * (1 + _expandAnimation.value * 5.0),
screenSize.height * 0.7, // 70%
)
: baseSize;
return AnimatedPositioned( return AnimatedPositioned(
duration: Duration(milliseconds: 500), duration: Duration(milliseconds: 300),
left: position['left']! - size / 2, left: selectedIndex == index
top: position['top']! - size / 2 - safeAreaPadding.top + 1, ? (screenSize.width - expandedSize) / 2
: position['left']!,
top: selectedIndex == index
? math.max(
screenSize.height * 0.15, //
(screenSize.height - expandedSize) / 2.5 + (screenSize.height * expandedCircleVerticalOffset)
)
: position['top']!,
child: AnimatedOpacity(
duration: Duration(milliseconds: 300),
opacity: selectedIndex == null || selectedIndex == index ? 1.0 : 0.0,
child: FadeTransition( child: FadeTransition(
opacity: _circleFadeInAnimations.isNotEmpty && index < _circleFadeInAnimations.length opacity: _circleFadeInAnimations.isNotEmpty && index < _circleFadeInAnimations.length
? _circleFadeInAnimations[index] ? _circleFadeInAnimations[index]
: AlwaysStoppedAnimation(0.0), : AlwaysStoppedAnimation(1.0),
child: SongCircleButton( child: GestureDetector(
relevance: relevance, onTap: () => _handleCircleTap(index),
size: size, onDoubleTap: () {
songTitle: song.title ?? '',
artistName: song.artist ?? '',
relevancePercentage: (relevance * 100).toInt(),
songIndex: index,
songList: songs,
onPressed: () {
print("Tapped on song: ${song.title} by ${song.artist}");
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
@ -239,11 +307,24 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
), ),
); );
}, },
child: SongCircleButton(
size: expandedSize,
songTitle: song.title ?? '',
artistName: song.artist ?? '',
songIndex: index,
songList: songs,
isExpanded: selectedIndex == index,
expandProgress: _expandAnimation.value,
),
),
), ),
), ),
); );
},
);
}), }),
), ),
if (selectedIndex == null)
..._dotAnimationControllers.asMap().entries.map((entry) { ..._dotAnimationControllers.asMap().entries.map((entry) {
final index = entry.key; final index = entry.key;
final dotController = entry.value; final dotController = entry.value;
@ -253,12 +334,15 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
builder: (context, child) { builder: (context, child) {
final progress = dotController.value; final progress = dotController.value;
final position = _getCirclePosition(index, songs.length, screenSize, refreshButtonPosition); final position = _getCirclePosition(index, songs.length, screenSize, refreshButtonPosition);
final radius = math.min(screenSize.width, screenSize.height) * 0.28; final radius = screenSize.width * 0.32;
final angle = (index * 2 * math.pi / songs.length) - math.pi / 2; final angle = (index * 2 * math.pi / songs.length) - math.pi / 2;
final dotPosition = Offset( final dotPosition = _getEffectPosition(
position['left']! - progress * (radius - 60) * math.cos(angle), Offset(position['left']!, position['top']!),
position['top']! - progress * (radius - 60) * math.sin(angle), progress,
angle,
radius,
screenSize
); );
return Positioned( return Positioned(
@ -283,18 +367,23 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
}, },
); );
}).toList(), }).toList(),
// if (selectedIndex == null)
Container( Transform.translate(
width: 80, offset: Offset(
height: 80, screenSize.width * refreshButtonHorizontalOffset,
screenSize.height * refreshButtonVerticalOffset,
),
child: Container(
width: screenSize.width * 0.15,
height: screenSize.width * 0.15,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.blue, color: Colors.blue,
shape: BoxShape.circle, shape: BoxShape.circle,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.blue.withOpacity(0.3), color: Colors.blue.withOpacity(0.2),
blurRadius: 15, blurRadius: 10,
spreadRadius: 5, spreadRadius: 3,
), ),
], ],
), ),
@ -302,7 +391,7 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
icon: Icon( icon: Icon(
isLoading ? Icons.hourglass_empty : Icons.refresh, isLoading ? Icons.hourglass_empty : Icons.refresh,
color: Colors.white, color: Colors.white,
size: 30, size: screenSize.width * 0.07,
), ),
onPressed: () { onPressed: () {
if (!isLoading) { if (!isLoading) {
@ -314,12 +403,17 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
}, },
), ),
), ),
),
], ],
), ),
), ),
], ],
), ),
), ),
);
},
),
),
), ),
); );
} }
@ -327,127 +421,156 @@ class _SongRecommendationViewState extends State<SongRecommendationView> with Ti
class LinePainter extends CustomPainter { class LinePainter extends CustomPainter {
final List recommendedSongs; final List recommendedSongs;
final List<double> relevanceValues;
final Size screenSize; final Size screenSize;
final Animation<double> lineAnimation; final Animation<double> lineAnimation;
final Offset refreshButtonPosition; final Offset refreshButtonPosition;
final double verticalOffset; //
final double horizontalOffset; //
LinePainter({ LinePainter({
required this.recommendedSongs, required this.recommendedSongs,
required this.relevanceValues,
required this.screenSize, required this.screenSize,
required this.lineAnimation, required this.lineAnimation,
required this.refreshButtonPosition, required this.refreshButtonPosition,
required this.verticalOffset,
required this.horizontalOffset,
}); });
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
final center = refreshButtonPosition; // 使 final centerX = size.width / 2 + (size.width * horizontalOffset);
final centerY = size.height / 2 + (size.height * verticalOffset);
final center = Offset(centerX, centerY);
final radius = size.width * 0.28;
for (int i = 0; i < recommendedSongs.length; i++) { for (int i = 0; i < recommendedSongs.length; i++) {
final relevance = relevanceValues[i]; final angle = (-math.pi / 2) + (i * 2 * math.pi / recommendedSongs.length);
final position = _getCirclePosition(i, recommendedSongs.length, size);
final end = Offset(center.dx + position['left']!, center.dy + position['top']!); final circleCenter = Offset(
centerX + radius * math.cos(angle),
centerY + radius * math.sin(angle)
);
final paint = Paint() final paint = Paint()
..color = Colors.grey.withOpacity(0.2) // 0.5 ..color = Colors.grey.withOpacity(0.2)
..strokeWidth = 0.01 + math.pow(relevance, 2) * 10; ..strokeWidth = 1.0;
// 线 canvas.drawLine(center, circleCenter, paint);
canvas.drawLine(center, end, paint);
} }
} }
Map<String, double> _getCirclePosition(int index, int totalItems, Size size) {
final radius = math.min(size.width, size.height) * 0.28;
final angle = (index * 2 * math.pi / totalItems) - math.pi / 2;
return {
'left': radius * math.cos(angle),
'top': radius * math.sin(angle),
};
}
@override @override
bool shouldRepaint(CustomPainter oldDelegate) { bool shouldRepaint(CustomPainter oldDelegate) {
return false; return true;
} }
} }
class SongCircleButton extends StatelessWidget { class SongCircleButton extends StatelessWidget {
final double relevance;
final double size; final double size;
final String songTitle; final String songTitle;
final String artistName; final String artistName;
final int relevancePercentage;
final int songIndex; final int songIndex;
final List<Song> songList; final List<Song> songList;
final VoidCallback onPressed; final bool isExpanded;
final double expandProgress;
const SongCircleButton({ const SongCircleButton({
required this.relevance,
required this.size, required this.size,
required this.songTitle, required this.songTitle,
required this.artistName, required this.artistName,
required this.relevancePercentage,
required this.songIndex, required this.songIndex,
required this.songList, required this.songList,
required this.onPressed, this.isExpanded = false,
this.expandProgress = 0.0,
}); });
Color _getCircleColor() {
return Color(0xFFFFC1E3); //
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return AnimatedContainer(
onTap: onPressed, // duration: Duration(milliseconds: 300),
child: Container(
width: size, width: size,
height: size, height: size,
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.7, //
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: _getCircleColor(), color: Color(0xFFFFC1E3).withOpacity(isExpanded ? 1.0 : 0.95),
borderRadius: BorderRadius.circular(size / 2), // borderRadius: BorderRadius.circular(size / 2),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: _getCircleColor().withOpacity(0.6), // color: Color(0xFFFFC1E3).withOpacity(isExpanded ? 0.5 : 0.25),
blurRadius: 12, // blurRadius: isExpanded ? 40 : 12,
spreadRadius: 8, // spreadRadius: isExpanded ? 20 : 4,
), ),
], ],
), ),
child: Center( child: Center(
child: SingleChildScrollView( //
physics: NeverScrollableScrollPhysics(),
child: AnimatedPadding(
duration: Duration(milliseconds: 300),
padding: EdgeInsets.all(size * (isExpanded ? 0.1 : 0.12)),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
if (isExpanded) ...[
Text( Text(
'', '推荐歌曲',
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white.withOpacity(0.8),
fontSize: 18, fontSize: size * 0.08,
fontWeight: FontWeight.bold, height: 1.2,
), ),
), ),
const SizedBox(height: 4), SizedBox(height: size * 0.05),
],
Text( Text(
songTitle, songTitle,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: const TextStyle( maxLines: isExpanded ? null : 2,
overflow: isExpanded ? null : TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 14, fontSize: isExpanded
? size * 0.12 //
: size * 0.15,
height: 1.2,
), ),
), ),
const SizedBox(height: 2), SizedBox(height: size * (isExpanded ? 0.05 : 0.02)),
Text( Text(
artistName, artistName,
textAlign: TextAlign.center, textAlign: TextAlign.center,
maxLines: isExpanded ? null : 1,
overflow: isExpanded ? null : TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
color: Colors.white70, color: Colors.white.withOpacity(isExpanded ? 1.0 : 0.8),
fontSize: 12, fontSize: isExpanded
? size * 0.09 //
: size * 0.12,
height: 1.2,
),
), ),
if (isExpanded) ...[
SizedBox(height: size * 0.08),
Text(
'双击播放',
style: TextStyle(
color: Colors.white.withOpacity(0.7),
fontSize: size * 0.08,
height: 1.2,
),
),
SizedBox(height: size * 0.05),
Icon(
Icons.play_circle_outline,
color: Colors.white.withOpacity(0.8),
size: size * 0.15,
), ),
], ],
],
),
), ),
), ),
), ),

Loading…
Cancel
Save