yumi-flutter/lib/modules/room/music/room_music_folder_page.dart
2026-04-29 18:28:39 +08:00

144 lines
5.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yumi/modules/room/music/room_music_select_page.dart';
import 'package:yumi/modules/room/music/room_music_texts.dart';
import 'package:yumi/shared/data_sources/models/sc_music_folder_mode.dart';
class RoomMusicFolderPage extends StatelessWidget {
const RoomMusicFolderPage({super.key, required this.folders});
final List<SCMusicFolderMode> folders;
@override
Widget build(BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(
splashFactory: NoSplash.splashFactory,
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
),
child: Scaffold(
backgroundColor: const Color(0xFF071F1B),
appBar: AppBar(
backgroundColor: const Color(0xFF071F1B),
elevation: 0,
title: Text(
RoomMusicTexts.t(context, "roomMusicAddMusic", "添加音乐"),
style: TextStyle(fontSize: 17.sp, fontWeight: FontWeight.w700),
),
),
body: ListView.separated(
padding: EdgeInsets.fromLTRB(16.w, 8.w, 16.w, 20.w),
itemCount: folders.length,
separatorBuilder:
(_, __) => Divider(
color: Colors.white.withValues(alpha: 0.08),
height: 1,
),
itemBuilder: (context, index) {
final folder = folders[index];
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () async {
final changed = await Navigator.of(
context,
).push<bool>(_musicRoute(RoomMusicSelectPage(folder: folder)));
if (changed == true && context.mounted) {
Navigator.pop(context, true);
}
},
child: SizedBox(
height: 82.w,
child: Row(
children: [
Image.asset(
"sc_images/room/sc_music_material_folder.png",
width: 44.w,
height: 44.w,
),
SizedBox(width: 12.w),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
folder.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white,
fontSize: 14.sp,
fontWeight: FontWeight.w700,
),
),
),
if (folder.addedCount > 0)
Text(
RoomMusicTexts.t(
context,
"roomMusicAddedCount",
"已添加 ${folder.addedCount}",
).replaceAll(
"{1}",
folder.addedCount.toString(),
),
style: TextStyle(
color: const Color(0xFF33E6A2),
fontSize: 11.sp,
),
),
],
),
SizedBox(height: 6.w),
Text(
"${folder.musicCount} Music | ${folder.path}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
textDirection: TextDirection.ltr,
style: TextStyle(
color: Colors.white.withValues(alpha: 0.52),
fontSize: 11.sp,
),
),
],
),
),
SizedBox(width: 8.w),
Icon(
Icons.chevron_right,
color: Colors.white.withValues(alpha: 0.55),
),
],
),
),
);
},
),
),
);
}
}
Route<T> _musicRoute<T>(Widget page) {
return PageRouteBuilder<T>(
opaque: true,
barrierColor: const Color(0xFF071F1B),
transitionDuration: const Duration(milliseconds: 180),
reverseTransitionDuration: const Duration(milliseconds: 160),
pageBuilder:
(context, animation, secondaryAnimation) =>
ColoredBox(color: const Color(0xFF071F1B), child: page),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
final tween = Tween<Offset>(
begin: const Offset(1, 0),
end: Offset.zero,
).chain(CurveTween(curve: Curves.easeOutCubic));
return SlideTransition(position: animation.drive(tween), child: child);
},
);
}