// Author: fengshengxiong // Date: 2024/6/5 // Description: 我的音频item import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:tone_snap/components/my_marquee_text.dart'; import 'package:tone_snap/data/models/voice_model.dart'; import 'package:tone_snap/generated/assets.dart'; import 'package:tone_snap/utils/obj_util.dart'; class MyVoiceItem extends StatelessWidget { const MyVoiceItem({ super.key, required this.item, required this.onTapItem, required this.onReName, required this.onDelete, }); final VoiceModel item; final Function() onTapItem; final Function() onReName; final Function() onDelete; @override Widget build(BuildContext context) { return InkWell( onTap: onTapItem, child: Padding( padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 8.h), child: Row( children: [ ClipOval( child: Image.asset( ObjUtil.isNotEmpty(item.cover) ? item.cover! : Assets.sideAVoiceDefault, width: 52.w, height: 52.w, fit: BoxFit.cover, ), ), SizedBox(width: 12.w), Expanded( child: MyMarqueeText( text: item.name, textStyle: TextStyle( color: Colors.white, fontSize: 18.sp, fontWeight: FontWeight.w500, ), ), ), SizedBox(width: 12.w), PopupMenuButton( offset: Offset(0, 38.w), color: Colors.white, padding: EdgeInsets.zero, itemBuilder: (context) { return [ PopupMenuItem( onTap: onReName, child: Center( child: Text( 'Rename', style: TextStyle(fontSize: 15.sp, fontWeight: FontWeight.w500), ), ), ), PopupMenuItem( onTap: onDelete, child: Center( child: Text( 'Delete', style: TextStyle(fontSize: 15.sp, fontWeight: FontWeight.w500), ), ), ), ]; }, child: Padding( padding: const EdgeInsets.all(6).w, child: Image.asset( Assets.sideAMore, width: 32.w, height: 32.w, ), ), ), ], ), ), ); } }