Compare commits

..

No commits in common. 'master' and 'dev' have entirely different histories.
master ... dev

@ -1,2 +0,0 @@
#Mon Oct 28 21:45:22 CST 2024
java.home=C\:\\Program Files\\Android\\Android Studio\\jbr

@ -1,8 +0,0 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Oct 28 21:45:22 CST 2024
sdk.dir=C\:\\Users\\zxp\\AppData\\Local\\Android\\Sdk

@ -30,8 +30,4 @@
android:name="flutterEmbedding" android:name="flutterEmbedding"
android:value="2" /> android:value="2" />
</application> </application>
<!-- 添加存储权限 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
</manifest> </manifest>

@ -1,13 +1,6 @@
buildscript { buildscript {
ext.kotlin_version = '1.7.10' ext.kotlin_version = '1.7.10'
repositories { repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/spring/'}
maven { url 'https://maven.aliyun.com/repository/google/'}
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/'}
maven { url 'https://maven.aliyun.com/repository/spring-plugin/'}
maven { url 'https://maven.aliyun.com/repository/grails-core/'}
maven { url 'https://maven.aliyun.com/repository/apache-snapshots/'}
google() google()
mavenCentral() mavenCentral()
} }
@ -20,16 +13,8 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/spring/'}
maven { url 'https://maven.aliyun.com/repository/google/'}
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/'}
maven { url 'https://maven.aliyun.com/repository/spring-plugin/'}
maven { url 'https://maven.aliyun.com/repository/grails-core/'}
maven { url 'https://maven.aliyun.com/repository/apache-snapshots/'}
google() google()
mavenCentral() mavenCentral()
mavenCentral()
} }
} }

@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
systemProp.org.gradle.wrapper.timeout=300000

@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.5-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

Binary file not shown.

Before

Width:  |  Height:  |  Size: 749 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 589 B

@ -6,11 +6,11 @@ import 'package:music_player_miao/models/universal_bean.dart';
import '../models/getInfo_bean.dart'; import '../models/getInfo_bean.dart';
import '../models/login_bean.dart'; import '../models/login_bean.dart';
const String _LoginURL = 'http://8.210.250.29:10010/users/login'; const String _LoginURL = 'http://flyingpig.fun:10010/users/login';
const String _LogoutURL = 'http://8.210.250.29:10010/users/logout'; const String _LogoutURL = 'http://flyingpig.fun:10010/users/logout';
const String _SetupURL = 'http://8.210.250.29:10010/email/register'; const String _SetupURL = 'http://flyingpig.fun:10010/email/register';
const String _verificationURL = 'http://8.210.250.29:10010/email/verificationCode'; const String _verificationURL = 'http://flyingpig.fun:10010/email/verificationCode';
const String _GetInfoURL = 'http://8.210.250.29:10010/users/info'; const String _GetInfoURL = 'http://flyingpig.fun:10010/users/info';
/// ///
class LoginApiClient { class LoginApiClient {

@ -1,14 +1,14 @@
import 'dart:io'; import 'dart:io';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import '../models/universal_bean.dart'; import '../models/universal_bean.dart';
const String _changeNameURL = 'http://8.210.250.29:10010/users/username'; const String _changeNameURL = 'http://flyingpig.fun:10010/users/username';
const String _changeHeaderURL = 'http://8.210.250.29:10010/users/avatar'; const String _changeHeaderURL = 'http://flyingpig.fun:10010/users/avatar';
class ChangeApiClient { class ChangeApiClient {
final Dio dio = Dio(); final Dio dio = Dio();
final ValueNotifier<String> avatarUrlNotifier = ValueNotifier<String>("");
/// ///
Future<UniversalBean> changeName({ Future<UniversalBean> changeName({
required String Authorization, required String Authorization,
@ -16,19 +16,13 @@ class ChangeApiClient {
}) async { }) async {
Response response = await dio.put( Response response = await dio.put(
_changeNameURL, _changeNameURL,
// data: { data: {
// 'Authorization': Authorization, 'Authorization': Authorization,
// }, },
queryParameters: {'userName':userName}, queryParameters: {'userName':userName},
options: Options( options: Options(headers:{'Authorization':Authorization,'Content-Type':'application/json;charset=UTF-8'})
headers:{
'Authorization':Authorization,
'Content-Type':'application/json;charset=UTF-8'
}
)
); );
print(response.data); print(response.data);
return UniversalBean.formMap(response.data); return UniversalBean.formMap(response.data);
} }
/// ///
@ -38,7 +32,7 @@ class ChangeApiClient {
required File avatar, required File avatar,
}) async { }) async {
FormData formData = FormData.fromMap({ FormData formData = FormData.fromMap({
// 'Authorization': Authorization, 'Authorization': Authorization,
'avatar': await MultipartFile.fromFile(avatar.path, filename: 'avatar.jpg'), 'avatar': await MultipartFile.fromFile(avatar.path, filename: 'avatar.jpg'),
}); });
@ -52,8 +46,8 @@ class ChangeApiClient {
}, },
), ),
); );
print(response.data); print(response.data);
avatarUrlNotifier.value = avatar.path;
return UniversalBean.formMap(response.data); return UniversalBean.formMap(response.data);
} }

@ -3,7 +3,7 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:music_player_miao/models/universal_bean.dart'; import 'package:music_player_miao/models/universal_bean.dart';
const String _CollectionURL = 'http://8.210.250.29:10010/collections'; const String _CollectionURL = 'http://flyingpig.fun:10010/collections';
class CollectionApiMusic { class CollectionApiMusic {
final Dio dio = Dio(); final Dio dio = Dio();

@ -1,110 +0,0 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart' as path;
class DownloadApi {
final Dio dio = Dio();
//
Future<bool> _requestStoragePermission(BuildContext context) async {
//
PermissionStatus status = await Permission.manageExternalStorage.status;
if (status.isDenied) {
//
// PermissionStatus status1 = await Permission.storage.request();
status = await Permission.manageExternalStorage.request();
print(status);
if (status.isDenied || status.isPermanentlyDenied || status.isRestricted) {
if (context.mounted) {
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
title: const Text('需要存储权限'),
content: const Text('下载音乐需要存储权限,请在设置中允许访问存储权限。'),
actions: <Widget>[
TextButton(
child: const Text('取消'),
onPressed: () => Navigator.of(context).pop(),
),
TextButton(
child: const Text('去设置'),
onPressed: () {
Navigator.of(context).pop();
openAppSettings(); //
},
),
],
),
);
}
return false;
}
}
return status.isGranted;
}
String _getFileExtension(String url) {
// Remove query parameters
final urlWithoutQuery = url.split('?').first;
// Get the extension including the dot
final extension = path.extension(urlWithoutQuery);
return extension.isNotEmpty ? extension : '.mp3'; // Default to .mp3 if no extension found
}
Future<String?> downloadMusic({
required String musicUrl,
required String name,
required BuildContext context,
required Function(double) onProgress,
}) async {
try {
String fileExtension = _getFileExtension(musicUrl);
final fileName = '$name$fileExtension';
//
if (!await _requestStoragePermission(context)) {
throw Exception('没有存储权限');
}
//
final downloadDir = Directory('/storage/emulated/0/MTMusic');
if (!await downloadDir.exists()) {
await downloadDir.create(recursive: true);
}
//
final filePath = '${downloadDir.path}/$fileName';
print("Music URL: $musicUrl");
print("Saving as: $filePath");
//
await dio.download(
musicUrl,
filePath,
options: Options(
headers: {
//
},
),
onReceiveProgress: (received, total) {
if (total != -1) {
//
double progress = received / total;
onProgress(progress); //
}
},
);
return filePath;
} catch (e) {
print('Download error: $e');
return null;
}
}
}

@ -4,7 +4,7 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:music_player_miao/models/universal_bean.dart'; import 'package:music_player_miao/models/universal_bean.dart';
const String _LikesURL = 'http://8.210.250.29:10010/likes'; const String _LikesURL = 'http://flyingpig.fun:10010/likes';
class LikesApiMusic { class LikesApiMusic {
final Dio dio = Dio(); final Dio dio = Dio();

@ -1,34 +1,16 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import '../common_widget/Song_widegt.dart';
import '../models/getMusicList_bean.dart'; import '../models/getMusicList_bean.dart';
import '../models/getRank_bean.dart'; import '../models/getRank_bean.dart';
const String _getMusic = 'http://8.210.250.29:10010/musics/'; const String _getMusic1 = 'http://flyingpig.fun:10010/musics/1';
const String _getMusic1 = 'http://8.210.250.29:10010/musics/1'; const String _getMusic2 = 'http://flyingpig.fun:10010/musics/2';
const String _getMusic2 = 'http://8.210.250.29:10010/musics/2'; const String _getMusic3 = 'http://flyingpig.fun:10010/musics/3';
const String _getMusic3 = 'http://8.210.250.29:10010/musics/3';
const String _getSongDetail = 'http://8.210.250.29:10010/musics';
/// ///
class GetMusic { class GetMusic {
final Dio dio = Dio(); final Dio dio = Dio();
Future<MusicListBean> getMusicById({required int id, required String Authorization}) async {
print(_getMusic + id.toString());
Response response = await dio.get(
_getMusic + id.toString(),
data: {
'Authorization': Authorization,
},
options: Options(headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8'
}));
print(response.data);
return MusicListBean.formMap(response.data);
}
Future<MusicListBean> getMusic1({required String Authorization}) async { Future<MusicListBean> getMusic1({required String Authorization}) async {
Response response = await dio.get( Response response = await dio.get(
_getMusic1, _getMusic1,
@ -69,40 +51,3 @@ class GetMusic {
return MusicListBean.formMap(response.data); return MusicListBean.formMap(response.data);
} }
} }
//
class GetMusicDetail {
final Dio dio = Dio();
// ID
Future<Song> getMusicDetail({required int songId, required String Authorization}) async {
try {
// songId URL
final String url = 'http://8.210.250.29:10010/musics/$songId'; // API
// GET
Response response = await dio.get(
url,
options: Options(
headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8',
},
),
);
print("Song detail response: ${response.data}");
//
if (response.statusCode == 200) {
// Song
return Song.fromMap(response.data['data']);
} else {
throw Exception("Failed to load song details");
}
} catch (e) {
print("Error occurred while fetching song details: $e");
rethrow; //
}
}
}

@ -2,7 +2,7 @@ import 'package:dio/dio.dart';
import '../models/getRank_bean.dart'; import '../models/getRank_bean.dart';
const String _getRank = 'http://8.210.250.29:10010/musics/rank-list'; const String _getRank = 'http://flyingpig.fun:10010/musics/rank-list';
/// ///
class GetRank { class GetRank {
final Dio dio = Dio(); final Dio dio = Dio();

@ -6,30 +6,21 @@ import 'package:music_player_miao/models/universal_bean.dart';
import '../models/getComment_bean.dart'; import '../models/getComment_bean.dart';
import '../models/search_bean.dart'; import '../models/search_bean.dart';
const String _SearchURL = 'http://8.210.250.29:10010/musics/search'; const String _SearchURL = 'http://flyingpig.fun:10010/musics/search';
const String _postComment = 'http://8.210.250.29:10010/comments'; const String _postComment = 'http://flyingpig.fun:10010/comments';
/// ///
class SearchMusic { class SearchMusic{
final Dio dio = Dio(); final Dio dio = Dio();
Future<SearchBean> search({required String keyword,}) async {
Future<SearchBean> search({
required String keyword,
required String Authorization,
}) async {
Response response = await dio.get( Response response = await dio.get(
_SearchURL, _SearchURL,
queryParameters: {'keyword': keyword}, queryParameters: {'keyword':keyword}
options: Options(headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8',
}),
); );
print(response.data); print(response.data);
return SearchBean.formMap(response.data); return SearchBean.formMap(response.data);
} }
} }
/// ///
class commentMusic { class commentMusic {
final Dio dio = Dio(); final Dio dio = Dio();
@ -42,7 +33,7 @@ class commentMusic {
_postComment, _postComment,
data: { data: {
'content': content, 'content': content,
'musicId': musicId, 'MusicId': musicId,
'Authorization':Authorization 'Authorization':Authorization
}, },
@ -57,9 +48,9 @@ class commentMusic {
class getCommentApi { class getCommentApi {
final Dio dio = Dio(); final Dio dio = Dio();
Future<GetCommentBean> getComment({ Future<GetCommentBean> getComment({
required int musicId, required String musicId,
required int pageNo, required String pageNo,
required int pageSize, required String pageSize,
required String Authorization, required String Authorization,
}) async { }) async {
Response response = await dio.get( Response response = await dio.get(

@ -7,7 +7,7 @@ import 'dart:io';
import 'package:path/path.dart'; import 'package:path/path.dart';
const String _ReleaseURL = 'http://8.210.250.29:10010/musics'; const String _ReleaseURL = 'http://flyingpig.fun:10010/musics';
/// ///
class ReleaseApi { class ReleaseApi {

@ -2,41 +2,13 @@ import 'package:dio/dio.dart';
import 'package:music_player_miao/models/search_bean.dart'; import 'package:music_player_miao/models/search_bean.dart';
import 'package:music_player_miao/models/songlist_bean.dart'; import 'package:music_player_miao/models/songlist_bean.dart';
import '../models/getAllSongs_bean.dart';
import '../models/universal_bean.dart'; import '../models/universal_bean.dart';
import 'package:music_player_miao/models/getMyWorks.dart';
const String _SonglistURL = 'http://8.210.250.29:10010/songlists';
const String _MyWorksURL = 'http://8.210.250.29:10010/musics/upload-music';
const String _SonglistURL = 'http://flyingpig.fun:10010/songlists';
///
class SonglistApi { class SonglistApi {
final Dio dio = Dio(); final Dio dio = Dio();
///
Future<MyMusicListBean> getAllSongs({required int id, required String Authorization}) async {
String urlWithId = 'http://8.210.250.29:10010/songlist-musics/$id/music-list';
Response response = await dio.get(urlWithId,
options: Options(headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8'
}));
print(response.data);
return MyMusicListBean.formMap(response.data);
}
///
Future<MyWorks> getMyworks({required String Authorization}) async {
Response response = await dio.get(_MyWorksURL,
data: {
'Authorization': Authorization,
},
options: Options(headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8'
}));
print(response.data);
return MyWorks.formMap(response.data);
}
///
Future<SearchBean> getSonglist({required String Authorization}) async { Future<SearchBean> getSonglist({required String Authorization}) async {
Response response = await dio.get(_SonglistURL, Response response = await dio.get(_SonglistURL,
data: { data: {

@ -1,201 +0,0 @@
// audio_player_controller.dart
import 'dart:async';
import 'package:get/get.dart';
import 'package:just_audio/just_audio.dart';
import '../common_widget/Song_widegt.dart';
import '../models/getMusicList_bean.dart';
import '../common/download_manager.dart';
import '../common_widget/app_data.dart';
import '../api/api_music_list.dart';
class AudioPlayerController extends GetxController {
final audioPlayer = AudioPlayer();
final downloadManager = Get.find<DownloadManager>();
final appData = AppData();
// Observable values
final currentSongIndex = 0.obs;
final duration = Duration.zero.obs;
final position = Duration.zero.obs;
final isPlaying = false.obs;
final isLoading = false.obs;
final isRotating = false.obs;
final isDisposed = false.obs;
// Current song info
final artistName = ''.obs;
final musicName = ''.obs;
final likesStatus = false.obs;
final collectionsStatus = false.obs;
// Song lists
final songList = <Song>[].obs;
final ids = <int>[].obs;
final songUrls = <String>[].obs;
final artists = <String>[].obs;
final musicNames = <String>[].obs;
final likes = <bool>[].obs;
final collections = <bool>[].obs;
StreamSubscription? _positionSubscription;
StreamSubscription? _durationSubscription;
StreamSubscription? _playerStateSubscription;
void initWithSongs(List<Song> songs, int initialIndex) {
songList.value = songs;
currentSongIndex.value = initialIndex;
_initializeSongLists();
_initializePlayer();
}
void _initializeSongLists() {
for (int i = 0; i < songList.length; i++) {
ids.add(songList[i].id);
songUrls.add(songList[i].musicurl ?? '');
artists.add(songList[i].artist);
musicNames.add(songList[i].title);
likes.add(songList[i].likes ?? false);
collections.add(songList[i].collection ?? false);
}
_updateCurrentSongInfo();
}
void _initializePlayer() {
// Position updates
_positionSubscription = audioPlayer.positionStream.listen((pos) {
position.value = pos;
});
// Duration updates
_durationSubscription = audioPlayer.durationStream.listen((dur) {
duration.value = dur ?? Duration.zero;
});
// Player state updates
_playerStateSubscription = audioPlayer.playerStateStream.listen((state) {
// isPlaying.value = state.playing;
if (state.processingState == ProcessingState.completed) {
playNext();
}
});
// Initial load
_loadAndPlayCurrentSong();
}
void _updateCurrentSongInfo() {
artistName.value = artists[currentSongIndex.value];
musicName.value = musicNames[currentSongIndex.value];
likesStatus.value = likes[currentSongIndex.value];
collectionsStatus.value = collections[currentSongIndex.value];
}
Future<void> toggleLike() async {
final currentIndex = currentSongIndex.value;
likesStatus.value = !likesStatus.value;
likes[currentIndex] = likesStatus.value;
}
Future<void> toggleCollection() async {
final currentIndex = currentSongIndex.value;
collectionsStatus.value = !collectionsStatus.value;
collections[currentIndex] = collectionsStatus.value;
}
Future<void> _loadAndPlayCurrentSong() async {
isLoading.value = true;
position.value = Duration.zero;
duration.value = Duration.zero;
_updateCurrentSongInfo();
await _checkAndUpdateSongStatus(currentSongIndex.value);
try {
await audioPlayer.stop();
final localSong = downloadManager.getLocalSong(currentSongIndex.value);
final audioSource = localSong != null
? AudioSource.file(localSong.musicurl!)
: AudioSource.uri(Uri.parse(songUrls[currentSongIndex.value]));
await audioPlayer.setAudioSource(audioSource, preload: true);
duration.value = await audioPlayer.duration ?? Duration.zero;
await audioPlayer.play();
} catch (e) {
print('Error loading audio source: $e');
} finally {
isLoading.value = false;
}
}
Future<void> _checkAndUpdateSongStatus(int index) async {
if (songList[index].likes == null || songList[index].collection == null) {
try {
MusicListBean musicListBean = await GetMusic().getMusicById(
id: ids[index],
Authorization: appData.currentToken,
);
if (musicListBean.code == 200) {
likes[index] = musicListBean.likeOrNot!;
collections[index] = musicListBean.collectOrNot!;
if (index == currentSongIndex.value) {
likesStatus.value = musicListBean.likeOrNot!;
collectionsStatus.value = musicListBean.collectOrNot!;
}
}
} catch (e) {
print('Error fetching song status: $e');
}
}
}
void playOrPause() async {
if (audioPlayer.playing) {
isPlaying.value = false;
await audioPlayer.pause();
} else {
await audioPlayer.play();
isPlaying.value = true;
}
}
void playNext() {
if (currentSongIndex.value < songList.length - 1) {
currentSongIndex.value++;
} else {
currentSongIndex.value = 0;
}
_loadAndPlayCurrentSong();
}
void playPrevious() {
if (currentSongIndex.value > 0) {
currentSongIndex.value--;
} else {
currentSongIndex.value = songList.length - 1;
}
_loadAndPlayCurrentSong();
}
void seekTo(Duration position) async {
await audioPlayer.seek(position);
}
void changeSong(int index) {
currentSongIndex.value = index;
_loadAndPlayCurrentSong();
}
@override
void onClose() {
isDisposed.value = true;
_positionSubscription?.cancel();
_durationSubscription?.cancel();
_playerStateSubscription?.cancel();
audioPlayer.dispose();
super.onClose();
}
}

@ -1,213 +0,0 @@
import 'dart:convert';
import 'dart:io';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../api/api_download.dart';
import '../common_widget/Song_widegt.dart';
import 'package:path/path.dart' as path;
class DownloadItem {
final Song song;
double progress;
bool isCompleted;
bool isDownloading;
DownloadItem({
required this.song,
this.progress = 0.0,
this.isCompleted = false,
this.isDownloading = false,
});
Map<String, dynamic> toJson() {
return {
'song': {
'pic': song.pic,
'artistPic': song.artistPic,
'title': song.title,
'artist': song.artist,
'musicurl': song.musicurl,
'id': song.id,
'likes': song.likes,
'collection': song.collection
},
'progress': progress,
'isCompleted': isCompleted,
'isDownloading': isDownloading,
};
}
// JSONDownloadItem
factory DownloadItem.fromJson(Map<String, dynamic> json) {
return DownloadItem(
song: Song(
pic: json['song']['pic'],
artistPic: json['song']['artistPic'],
title: json['song']['title'],
artist: json['song']['artist'],
musicurl: json['song']['musicurl'],
id: json['song']['id'],
likes: json['song']['likes'],
collection: json['song']['collection'],
),
progress: json['progress'],
isCompleted: json['isCompleted'],
isDownloading: json['isDownloading'],
);
}
}
class DownloadManager extends GetxController {
static const String PREFS_KEY = 'downloads_data';
final _downloads = <String, DownloadItem>{}.obs;
final downloadApi = DownloadApi();
late SharedPreferences _prefs;
@override
void onInit() async {
super.onInit();
await _initPrefs();
}
Future<void> _initPrefs() async {
_prefs = await SharedPreferences.getInstance();
await _loadDownloadsFromPrefs();
}
// SharedPreferences
Future<void> _loadDownloadsFromPrefs() async {
final String? downloadsJson = _prefs.getString(PREFS_KEY);
if (downloadsJson != null) {
final Map<String, dynamic> downloadsMap = json.decode(downloadsJson);
downloadsMap.forEach((key, value) {
_downloads[key] = DownloadItem.fromJson(value);
});
}
}
// SharedPreferences
Future<void> _saveDownloadsToPrefs() async {
final Map<String, dynamic> downloadsMap = {};
_downloads.forEach((key, value) {
downloadsMap[key] = value.toJson();
});
await _prefs.setString(PREFS_KEY, json.encode(downloadsMap));
}
List<Song> getLocalSongs() {
final localSongs = <Song>[];
_downloads.forEach((key, value) {
if (value.isCompleted) {
localSongs.add(value.song);
}
});
return localSongs;
}
Map<String, DownloadItem> get downloads => _downloads;
bool isDownloading(int id) => _downloads[id.toString()]?.isDownloading ?? false;
bool isCompleted(int id) => _downloads[id.toString()]?.isCompleted ?? false;
double getProgress(int id) => _downloads[id.toString()]?.progress ?? 0.0;
Song? getLocalSong(int id) {
final downloadItem = _downloads[id.toString()];
if (downloadItem?.isCompleted ?? false) {
return downloadItem!.song;
}
return null;
}
bool removeSong(int id) {
if (_downloads[id.toString()]?.isCompleted ?? false) {
File file = File.fromUri(Uri.parse(_downloads[id.toString()]!.song.musicurl!));
file.deleteSync();
_downloads.remove(id.toString());
_saveDownloadsToPrefs();
return true;
}
return false;
}
int completedNumber() {
int count = 0;
_downloads.forEach((key, value) {
if (value.isCompleted) {
count++;
}
});
return count;
}
Future<void> startDownload({
required Song song,
required context,
}) async {
if (_downloads[song.id.toString()]?.isDownloading ?? false) return;
final fileName = '${song.id}_${song.title}_${song.artist}';
final downloadItem = DownloadItem(
song: song,
isDownloading: true,
);
_downloads[song.id.toString()] = downloadItem;
try {
final filePath = await downloadApi.downloadMusic(
musicUrl: song.musicurl!,
name: fileName,
context: context,
onProgress: (progress) {
downloadItem.progress = progress;
_downloads[song.id.toString()] = downloadItem;
},
);
if (filePath != null) {
downloadItem.isCompleted = true;
downloadItem.isDownloading = false;
downloadItem.progress = 1.0;
song.musicurl = _getLocalAudioPath(fileName, song.musicurl!);
print(song.musicurl);
} else {
downloadItem.isDownloading = false;
downloadItem.progress = 0.0;
}
} catch (e) {
print('Download error: $e');
downloadItem.isDownloading = false;
downloadItem.progress = 0.0;
}
_downloads[song.id.toString()] = downloadItem;
await _saveDownloadsToPrefs();
}
bool updateSongInfo(int id, bool isCollected, bool isLiked) {
final downloadItem = _downloads[id.toString()];
if (downloadItem != null) {
downloadItem.song.collection = isCollected;
downloadItem.song.likes = isLiked;
_downloads[id.toString()] = downloadItem;
_saveDownloadsToPrefs();
return true;
}
return false;
}
String _getFileExtension(String url) {
// Remove query parameters
final urlWithoutQuery = url.split('?').first;
// Get the extension including the dot
final extension = path.extension(urlWithoutQuery);
return extension.isNotEmpty ? extension : '.mp3'; // Default to .mp3 if no extension found
}
String _getLocalAudioPath(String fileName, String url) {
final extension = _getFileExtension(url);
final fullFileName = '$fileName$extension';
return path.join('/storage/emulated/0/MTMusic', fullFileName);
}
}

@ -1,36 +1,12 @@
class Song { class Song {
String pic; final String pic;
String artistPic; final String artistPic;
String title; final String title;
String artist; final String artist;
String? musicurl; final String musicurl;
int id; final int id;
bool? likes; final bool likes;
bool? collection; final bool collection;
// Song({required this.pic,required this.artistPic,required this.title, required this.artist, required this.musicurl,required this.id,required this.likes,required this.collection});
Song({
required this.pic,
required this.artistPic,
required this.title,
required this.artist,
required this.musicurl,
required this.id,
required this.likes,
required this.collection,
});
// 使 Map Song
factory Song.fromMap(Map<String, dynamic> map) {
return Song(
pic: map['coverPath'] ?? '', // coverPath
artistPic: map['coverPath'] ?? '', // artistPic
title: map['name'] ?? '', // name
artist: map['singerName'] ?? '', // singerName
musicurl: map['musicPath'] ?? '', // musicPath
id: map['id'] ?? 0, // ID id
likes: map['likeOrNot'] ?? false, // likeOrNot
collection: map['collectOrNot'] ?? false, // collectOrNot
);
}
} }

@ -7,7 +7,5 @@ class AppData extends GetxController{
String get currentToken => box.read('currentToken'); String get currentToken => box.read('currentToken');
String get currentUsername => box.read('currentUsername') ?? '游客'; String get currentUsername => box.read('currentUsername') ?? '游客';
String get currentAvatar=> box.read('currentAvatar') ?? 'http://b.hiphotos.baidu.com/image/pic/item/e824b899a9014c08878b2c4c0e7b02087af4f4a3.jpg'; String get currentAvatar=> box.read('currentAvatar') ?? 'http://b.hiphotos.baidu.com/image/pic/item/e824b899a9014c08878b2c4c0e7b02087af4f4a3.jpg';
set currentToken(String token) => box.write('currentToken', token);
set currentUsername(String username) => box.write('currentUsername', username);
set currentAvatar(String avatar) => box.write('currentAvatar', avatar);
} }

@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../api/api_music_likes.dart'; // API import '../api/api_music_likes.dart'; // API
import '../api/api_collection.dart'; // API import '../api/api_collection.dart'; // API
import '../view_model/comment_page.dart'; // //
class RankSongsRow extends StatelessWidget { class RankSongsRow extends StatelessWidget {
final Map sObj; final Map sObj;
@ -174,12 +174,7 @@ class RankSongsRow extends StatelessWidget {
IconButton( IconButton(
onPressed: () { onPressed: () {
// //
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const CommentPage(),
),
);
}, },
icon: Image.asset("assets/img/list_comment.png"), icon: Image.asset("assets/img/list_comment.png"),
iconSize: 60, iconSize: 60,

@ -1,13 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:music_player_miao/common_widget/app_data.dart'; import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/view/begin/begin_view.dart';
import 'package:music_player_miao/view/begin/login_v.dart';
import 'package:music_player_miao/view/home_view.dart';
import 'package:music_player_miao/view/splash_view.dart'; import 'package:music_player_miao/view/splash_view.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'dart:io'; import 'dart:io';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:music_player_miao/view/user/user_view.dart';
void main(){ void main(){
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -24,14 +20,9 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetMaterialApp( return const GetMaterialApp(
title: 'Flutter Demo', debugShowCheckedModeBanner: false,
initialRoute: '/login', // home: SplashView(),
routes: {
'/': (context) => HomeView(), //
'/user': (context) => UserView(),
'/login' : (context) => BeginView()// UserView
},
); );
} }
} }

@ -1,43 +0,0 @@
class MyMusicListBean {
int? code;
String? msg;
List<DataBean>? data;
MyMusicListBean.formMap(Map map) {
code = map['code'];
msg = map['msg'];
if (map['data'] is! List) return;
data = (map['data'] as List)
.map((item) => DataBean._formMap(item))
.toList();
}
}
class DataBean {
int? songlistId;
SongDetails? musicDetail; // SongDetails
DataBean._formMap(Map map) {
songlistId = map['songlistId'];
musicDetail = SongDetails._formMap(map['musicDetail']); //
}
}
class SongDetails {
int? id;
String? name;
String? coverPath;
String? musicPath;
String? singerName;
String? uploadUserName;
SongDetails._formMap(Map map) {
id = map['id'];
name = map['name'];
coverPath = map['coverPath'];
musicPath = map['musicPath'];
singerName = map['singerName'];
uploadUserName = map['uploadUserName'];
}
}

@ -9,8 +9,6 @@ class MusicListBean {
String? uploadUserName; String? uploadUserName;
bool? likeOrNot; bool? likeOrNot;
bool? collectOrNot; bool? collectOrNot;
MusicListBean.formMap(Map map){ MusicListBean.formMap(Map map){
code = map['code']; code = map['code'];
msg= map['msg']; msg= map['msg'];

@ -1,34 +0,0 @@
class MyWorks {
int? code;
String? msg;
List<DataBean>? data;
MyWorks.formMap(Map map) {
code = map['code'];
msg = map['msg'];
if (map['data'] == null) return;
List<dynamic>? dataList = map['data'];
if (dataList == null) return;
data = dataList
.map((item) => DataBean._formMap(item))
.toList();
}
}
class DataBean {
int? id;
String? name;
String? coverPath;
String? musicPath;
String? singerName;
DataBean._formMap(Map map) {
id = map['id'];
name = map['name'];
coverPath = map['coverPath'];
musicPath = map['musicPath'];
singerName = map['singerName'];
}
}

@ -24,6 +24,8 @@ class DataBean {
String? musicPath; String? musicPath;
String? name; String? name;
DataBean._formMap(Map map) { DataBean._formMap(Map map) {
id = map['id']; id = map['id'];
singerName = map['singerName']; singerName = map['singerName'];

@ -8,12 +8,7 @@ class UniversalBean {
msg = map['msg']; msg = map['msg'];
if (map['data'] is String) {
data = map['data']; data = map['data'];
} else if (map['data'] is bool) {
data = map['data'].toString(); }}
} else {
data = null;
}
}
}

@ -17,144 +17,138 @@ class _BeginViewState extends State<BeginView> with TickerProviderStateMixin {
@override @override
void initState() { void initState() {
tabController = TabController(initialIndex: 0, length: 2, vsync: this); tabController = TabController(
tabController.addListener(() { initialIndex: 0,
if (!tabController.indexIsChanging) { length: 2,
FocusScope.of(context).unfocus(); vsync: this
} );
});
super.initState(); super.initState();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return Container(
onTap: () { decoration: BoxDecoration(
FocusScope.of(context).unfocus(); image: DecorationImage(
}, image: AssetImage("assets/img/app_bg.png"),
child: Container( fit: BoxFit.cover,
decoration: const BoxDecoration( ),
image: DecorationImage( ),
image: AssetImage("assets/img/app_bg.png"), child: Scaffold(
fit: BoxFit.cover, backgroundColor: Colors.transparent,
), body: SingleChildScrollView(
), child: Column(
child: Scaffold( children: [
backgroundColor: Colors.transparent, Padding(
resizeToAvoidBottomInset: false, padding: const EdgeInsets.only(top: 110,left: 40,right: 40),
body: ScrollConfiguration( child: Row(
behavior: const ScrollBehavior().copyWith( children: [
physics: const NeverScrollableScrollPhysics(), const Column(
),
child: Column(
children: [
//
Padding(
padding:
const EdgeInsets.only(top: 110, left: 40, right: 40),
child: Row(
children: [ children: [
const Column( Text(
"你好吖喵星来客,",
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontWeight: FontWeight.w500
),
),
Row(
children: [ children: [
Text( Text(
"你好吖喵星来客,", "欢迎来到",
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.w500), fontWeight: FontWeight.w500
),
), ),
Row( Text(
children: [ "喵听",
Text( style: TextStyle(
"欢迎来到", color: Colors.black,
style: TextStyle( fontSize: 32,
color: Colors.black, fontWeight: FontWeight.w800
fontSize: 20, ),
fontWeight: FontWeight.w500),
),
Text(
"喵听",
style: TextStyle(
color: Colors.black,
fontSize: 32,
fontWeight: FontWeight.w800),
),
],
), ),
], ],
), ),
const SizedBox(width: 25),
Image.asset("assets/img/app_logo.png", width: 80),
], ],
), ),
), const SizedBox(width: 25,),
Image.asset("assets/img/app_logo.png", width: 80),
const SizedBox(height: 20), // ],
),
// 使 Expanded ),
Expanded( SizedBox(
child: Column( height: MediaQuery.of(context).size.height,
children: [ child: Stack(
// TabBar children: [
Padding( Align(
padding: const EdgeInsets.symmetric(horizontal: 30.0), child: SizedBox(
child: Material( height: MediaQuery.of(context).size.height/1.06,
color: Colors.white, child: Column(
elevation: 3, children: [
borderRadius: BorderRadius.circular(10), Padding(
child: TabBar( padding: const EdgeInsets.symmetric(horizontal: 30.0),
controller: tabController, child: Material(
unselectedLabelColor: const Color(0xffCDCDCD), color: Colors.white,
// onTap: (_) { elevation: 3,
// FocusScope.of(context).unfocus(); borderRadius: BorderRadius.circular(10),
// }, child: TabBar(
labelColor: Colors.black, controller: tabController,
indicatorSize: TabBarIndicatorSize.tab, unselectedLabelColor: Color(0xffCDCDCD),
indicator: BoxDecoration( labelColor: Colors.black,
borderRadius: BorderRadius.circular(10), indicator:BoxDecoration(
color: MColor.LGreen), borderRadius: BorderRadius.circular(10),
tabs: [ color: MColor.LGreen
Container(
padding: const EdgeInsets.all(8.0),
child: const Text(
'登录',
style: TextStyle(
fontSize: 20,
), ),
), tabs: [
), Container(
Container( padding: EdgeInsets.all(8.0),
padding: const EdgeInsets.all(8.0), // color: Colors.pink,
child: const Text( child: Text(
'注册', '登录',
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
),
),
),
Container(
padding: EdgeInsets.all(8.0),
child: Text(
'注册',
style: TextStyle(
fontSize: 20,
),
),
), ),
), ],
), ),
], ),
), ),
), Expanded(
child: TabBarView(
controller: tabController,
children: [
LoginV(),
SignUpView(),
],
)
)
],
), ),
),
// TabBarView )
Expanded( ],
child: TabBarView( ),
controller: tabController,
physics: const NeverScrollableScrollPhysics(),
children: const [
LoginV(),
SignUpView(),
],
),
)
],
),
),
],
), ),
), ],
), ),
)); ),
),
);
} }
} }

@ -4,12 +4,15 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:music_player_miao/common_widget/app_data.dart'; import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/search_bean.dart';
import 'package:music_player_miao/view/main_tab_view/main_tab_view.dart'; import 'package:music_player_miao/view/main_tab_view/main_tab_view.dart';
import '../../api/api_client.dart'; import '../../api/api_client.dart';
import '../../api/api_songlist.dart';
import '../../common/color_extension.dart'; import '../../common/color_extension.dart';
import '../../models/getInfo_bean.dart'; import '../../models/getInfo_bean.dart';
import '../../models/login_bean.dart'; import '../../models/login_bean.dart';
import '../../models/songlist_bean.dart';
import '../../widget/my_text_field.dart'; import '../../widget/my_text_field.dart';
class LoginV extends StatefulWidget { class LoginV extends StatefulWidget {
@ -27,16 +30,6 @@ class _LoginVState extends State<LoginV> {
IconData iconPassword = CupertinoIcons.eye_fill; IconData iconPassword = CupertinoIcons.eye_fill;
bool obscurePassword = true; bool obscurePassword = true;
final _passwordFocusNode = FocusNode();
final _nameFocusNode = FocusNode();
@override
void dispose() {
_passwordFocusNode.dispose();
_nameFocusNode.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Form( return Form(
@ -49,7 +42,6 @@ class _LoginVState extends State<LoginV> {
child: MyTextField( child: MyTextField(
controller: nameController, controller: nameController,
hintText: '请输入账号', hintText: '请输入账号',
focusNode: _nameFocusNode,
obscureText: false, obscureText: false,
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
prefixIcon: Image.asset("assets/img/login_user.png"))), prefixIcon: Image.asset("assets/img/login_user.png"))),
@ -60,7 +52,6 @@ class _LoginVState extends State<LoginV> {
child: MyTextField( child: MyTextField(
controller: passwordController, controller: passwordController,
hintText: '请输入密码', hintText: '请输入密码',
focusNode: _passwordFocusNode,
obscureText: obscurePassword, obscureText: obscurePassword,
keyboardType: TextInputType.visiblePassword, keyboardType: TextInputType.visiblePassword,
prefixIcon: Image.asset("assets/img/login_lock.png"), prefixIcon: Image.asset("assets/img/login_lock.png"),
@ -90,81 +81,24 @@ class _LoginVState extends State<LoginV> {
child: TextButton( child: TextButton(
onPressed: () async { onPressed: () async {
try { try {
_nameFocusNode.unfocus();
_passwordFocusNode.unfocus();
Get.dialog(
Center(
child: CircularProgressIndicator(
color: const Color(0xff429482),
backgroundColor: Colors.grey[200],
),
),
barrierDismissible: false, //
);
LoginBean bean = await LoginApiClient().login( LoginBean bean = await LoginApiClient().login(
email: nameController.text, email: nameController.text,
password: passwordController.text, password: passwordController.text,
); );
if (bean.code == 200) { if (bean.code == 200) {
Get.back(); Get.to(() => const MainTabView());
Get.off(() => const MainTabView()); _showDialog(context,
ScaffoldMessenger.of(context).showSnackBar( title: 'assets/img/correct.png',
SnackBar( message: '登录成功!');
content: const Center(
child: Text(
'登录成功',
style: TextStyle(
color: Colors.black,
fontSize: 16.0, //
),
),
),
duration: const Duration(seconds: 3),
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.white,
elevation: 3,
width: 200,
//
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
GetInfoBean bean1 = await GetInfoApiClient() GetInfoBean bean1 = await GetInfoApiClient()
.getInfo( .getInfo(
Authorization: AppData().currentToken); Authorization: AppData().currentToken);
} else {
throw Exception("账号或密码错误");
} }
} catch (error) { } catch (error) {
Get.back(); String errorMessage = error.toString();
print(error.toString()); _showDialog(context,
ScaffoldMessenger.of(context).showSnackBar( title: 'assets/img/warning.png',
SnackBar( message: errorMessage);
content: Center(
child: Text(
error.toString().replaceAll ('Exception: ', ''),
style: const TextStyle(
color: Colors.black,
fontSize: 16.0, //
),
),
),
duration: const Duration(seconds: 3),
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.white,
elevation: 3,
margin: EdgeInsets.only(
bottom: 50, // 50
right: (MediaQuery.of(context).size.width - 200) / 2, //
left: (MediaQuery.of(context).size.width - 200) / 2,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
} }
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(

@ -1,7 +1,5 @@
// ignore_for_file: use_build_context_synchronously // ignore_for_file: use_build_context_synchronously
import 'dart:async';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -30,44 +28,6 @@ class _SignUpViewState extends State<SignUpView> {
bool obscurePassword = true; bool obscurePassword = true;
bool signUpRequired = false; bool signUpRequired = false;
final _nameFocusNode = FocusNode();
final _passwordFocusNode = FocusNode();
final _emailFocusNode = FocusNode();
final _confirmPSWFocusNode = FocusNode();
final _confirmFocusNode = FocusNode();
//
Timer? _timer;
int _countDown = 60;
bool _canSendCode = true;
@override
void dispose() {
_timer?.cancel(); //
super.dispose();
}
//
void startTimer() {
setState(() {
_canSendCode = false;
_countDown = 60;
});
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (_countDown == 0) {
setState(() {
_canSendCode = true;
timer.cancel();
});
} else {
setState(() {
_countDown--;
});
}
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Form( return Form(
@ -81,7 +41,6 @@ class _SignUpViewState extends State<SignUpView> {
child: MyTextField( child: MyTextField(
controller: nameController, controller: nameController,
hintText: '请输入用户名', hintText: '请输入用户名',
focusNode: _nameFocusNode,
obscureText: false, obscureText: false,
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
prefixIcon: Image.asset("assets/img/login_user.png"), prefixIcon: Image.asset("assets/img/login_user.png"),
@ -101,7 +60,6 @@ class _SignUpViewState extends State<SignUpView> {
controller: emailController, controller: emailController,
hintText: '请输入邮箱名', hintText: '请输入邮箱名',
obscureText: false, obscureText: false,
focusNode: _emailFocusNode,
keyboardType: TextInputType.name, keyboardType: TextInputType.name,
prefixIcon: Image.asset("assets/img/setup_email.png"), prefixIcon: Image.asset("assets/img/setup_email.png"),
validator: (val) { validator: (val) {
@ -118,7 +76,6 @@ class _SignUpViewState extends State<SignUpView> {
controller: passwordController, controller: passwordController,
hintText: '请输入密码', hintText: '请输入密码',
obscureText: obscurePassword, obscureText: obscurePassword,
focusNode: _passwordFocusNode,
keyboardType: TextInputType.visiblePassword, keyboardType: TextInputType.visiblePassword,
prefixIcon: Image.asset("assets/img/login_lock.png"), prefixIcon: Image.asset("assets/img/login_lock.png"),
suffixIcon: IconButton( suffixIcon: IconButton(
@ -153,7 +110,6 @@ class _SignUpViewState extends State<SignUpView> {
controller: confirmPSWController, controller: confirmPSWController,
hintText: '请确认密码', hintText: '请确认密码',
obscureText: obscurePassword, obscureText: obscurePassword,
focusNode: _confirmPSWFocusNode,
keyboardType: TextInputType.visiblePassword, keyboardType: TextInputType.visiblePassword,
prefixIcon: Image.asset("assets/img/login_lock.png"), prefixIcon: Image.asset("assets/img/login_lock.png"),
suffixIcon: IconButton( suffixIcon: IconButton(
@ -194,7 +150,6 @@ class _SignUpViewState extends State<SignUpView> {
controller: confirmController, controller: confirmController,
hintText: '请输入验证码', hintText: '请输入验证码',
obscureText: false, obscureText: false,
focusNode: _confirmFocusNode,
keyboardType: TextInputType.name, keyboardType: TextInputType.name,
prefixIcon: Image.asset("assets/img/setup_confirm.png"), prefixIcon: Image.asset("assets/img/setup_confirm.png"),
validator: (val) { validator: (val) {
@ -205,88 +160,27 @@ class _SignUpViewState extends State<SignUpView> {
}), }),
), ),
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width * 0.313, width: MediaQuery.of(context).size.width * 0.3,
height: MediaQuery.of(context).size.width * 0.13, height: MediaQuery.of(context).size.width * 0.13,
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: _canSendCode ? MColor.LGreen : Colors.grey[300], backgroundColor: MColor.LGreen),
shape: RoundedRectangleBorder( onPressed: () async {
borderRadius: BorderRadius.circular(8.0), UniversalBean bean =
), await SetupApiClient().verification(
), email: emailController.text,
onPressed: _canSendCode
? () async {
_nameFocusNode.unfocus();
_emailFocusNode.unfocus();
_passwordFocusNode.unfocus();
_confirmPSWFocusNode.unfocus();
_confirmFocusNode.unfocus();
UniversalBean bean = await SetupApiClient().verification(
email: emailController.text,
);
if (bean.code == 200) {
startTimer(); //
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Center(
child: Text(
'验证码发送成功',
style: TextStyle(color: Colors.black),
),
),
duration: const Duration(seconds: 2),
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.white,
elevation: 3,
margin: EdgeInsets.only(
bottom: 50, // 50
right: (MediaQuery.of(context).size.width - 200) / 2, //
left: (MediaQuery.of(context).size.width - 200) / 2,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Center(
child: Text(
'请检查邮箱',
style: TextStyle(
color: Colors.black,
fontSize: 16.0, //
),
),
),
duration: const Duration(seconds: 2),
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.white,
elevation: 3,
// width: 220,
margin: EdgeInsets.only(
bottom: 50, // 50
right: (MediaQuery.of(context).size.width - 200) / 2, //
left: (MediaQuery.of(context).size.width - 200) / 2,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
); );
} _showSuccessDialog(context,
} title: bean.code == 200
: null, ? 'assets/img/correct.png'
child: Text( : 'assets/img/warning.png',
_canSendCode ? "获取验证码" : "${_countDown}s后重试", errorMessage:
style: TextStyle( bean.code == 200 ? '验证码已成功发送!' : '邮箱格式不正确!');
color: _canSendCode ? Colors.black45 : Colors.grey, },
fontSize: 16, child: const Text(
), "获取验证码",
), style: TextStyle(color: Colors.black45, fontSize: 16),
), )),
), ),
], ],
), ),
@ -295,11 +189,6 @@ class _SignUpViewState extends State<SignUpView> {
width: MediaQuery.of(context).size.width * 0.85, width: MediaQuery.of(context).size.width * 0.85,
child: TextButton( child: TextButton(
onPressed: () async { onPressed: () async {
_nameFocusNode.unfocus();
_emailFocusNode.unfocus();
_passwordFocusNode.unfocus();
_confirmPSWFocusNode.unfocus();
_confirmFocusNode.unfocus();
if (_formKey.currentState?.validate() == false) { if (_formKey.currentState?.validate() == false) {
const Text( const Text(
'', '',
@ -309,26 +198,18 @@ class _SignUpViewState extends State<SignUpView> {
), ),
); );
} }
if (nameController.text.isNotEmpty && UniversalBean bean = await SetupApiClient().register(
emailController.text.isNotEmpty && email: emailController.text,
passwordController.text.isNotEmpty && password: passwordController.text,
confirmPSWController.text.isNotEmpty && username: nameController.text,
confirmController.text.isNotEmpty) { verificationCode: confirmController.text);
UniversalBean bean = await SetupApiClient().register( _showSuccessDialog(context,
email: emailController.text, title: bean.code == 200
password: passwordController.text, ? 'assets/img/correct.png'
username: nameController.text, : 'assets/img/warning.png',
verificationCode: confirmController.text); errorMessage:
_showSuccessDialog(context, bean.code == 200 ? '注册成功,一键登录' : '登录失败,验证码错误');
title: bean.code == 200 if (bean.code == 200) Get.to(const MainTabView());
? 'assets/img/correct.png'
: 'assets/img/warning.png',
errorMessage:
bean.code == 200
? '注册成功,一键登录'
: '注册失败,验证码错误');
if (bean.code == 200) Get.to(const MainTabView());
}
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
elevation: 3.0, elevation: 3.0,

@ -0,0 +1,329 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:music_player_miao/api/api_music_return.dart';
import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/getComment_bean.dart';
import 'package:music_player_miao/models/universal_bean.dart';
import 'package:music_player_miao/widget/text_field.dart';
class CommentView extends StatefulWidget {
@override
_CommentViewState createState() => _CommentViewState();
CommentView({super.key, required this.initialSongIndex});
late final int initialSongIndex;
}
class _CommentViewState extends State<CommentView> {
List comments = [];
TextEditingController commentController = TextEditingController();
FocusNode commentFocusNode = FocusNode();
List commentTimes = [];
List commentHeader = [];
List commentName = [];
bool ascendingOrder = true;
int playlistCount = 0;
@override
void initState() {
super.initState();
_fetchSonglistData();
}
Future<void> _fetchSonglistData() async {
try {
GetCommentBean bean1 = await getCommentApi().getComment(
musicId: '1',
pageNo: '0',
pageSize: '10',
Authorization: AppData().currentToken,
);
// rows
if (bean1.rows == null) {
print('No comments found');
return;
}
setState(() {
comments = bean1.rows!.map((rows) => rows.content ?? 'No content').toList();
commentTimes = bean1.rows!.map((rows) => rows.time ?? 'Unknown time').toList();
commentHeader = bean1.rows!.map((rows) => rows.avatar ?? 'Default avatar').toList();
commentName = bean1.rows!.map((rows) => rows.username ?? 'Anonymous').toList();
playlistCount = comments.length;
});
} catch (error) {
print('Error fetching songlist data: $error');
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
// backgroundColor: Colors.transparent,
appBar: AppBar(
centerTitle: true,
backgroundColor: const Color(0xffF6FFD1),
title: const Text(
'评论(200)',
style: TextStyle(
color: Colors.black,
fontSize: 22
),
),
elevation: 0,
leading: IconButton(
onPressed: () {
Get.back();
},
icon: Image.asset(
"assets/img/back.png",
width: 25,
height: 25,
fit: BoxFit.contain,
),
),
),
body: Column(
children: [
Container(
height: 80,
padding: const EdgeInsets.only(left: 20, right: 10),
decoration: BoxDecoration(
color: const Color(0xffF9F2AF),
borderRadius: BorderRadius.circular(20)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.asset(
"assets/img/artist_pic.png",
width: 60,
height: 60,
fit: BoxFit.cover,
),
),
const SizedBox(width: 20,),
const Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"背对背拥抱",
maxLines: 1,
style: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.w400),
),
Text(
"林俊杰",
maxLines: 1,
style: TextStyle(color: Colors.black, fontSize: 14),
)
],
),
],
),
IconButton(
onPressed: () {},
icon: Image.asset(
"assets/img/music_pause.png",
width: 25,
height: 25,
fit: BoxFit.contain,
),
),
],
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"评论区",
style: TextStyle(
fontSize: 18
),
),
Row(
children: [
const Text(
"时间",
style: TextStyle(
fontSize: 16
),
),
IconButton(
onPressed: () {
setState(() {
ascendingOrder = !ascendingOrder;
// 使
List<int> sortedIndexes = List<int>.generate(comments.length, (i) => i);
sortedIndexes.sort((a, b) {
DateTime timeA = DateTime.parse(commentTimes[a]);
DateTime timeB = DateTime.parse(commentTimes[b]);
return ascendingOrder ? timeA.compareTo(timeB) : timeB.compareTo(timeA);
});
comments = [for (var i in sortedIndexes) comments[i]];
commentTimes = [for (var i in sortedIndexes) commentTimes[i]];
commentHeader = [for (var i in sortedIndexes) commentHeader[i]];
commentName = [for (var i in sortedIndexes) commentName[i]];
});
},
icon: Image.asset(
ascendingOrder
? "assets/img/commend_up.png"
: "assets/img/commend_down.png",
fit: BoxFit.contain,
),
),
],
)
],
),
),
///
Expanded(
child:
ListView.builder(
itemCount: comments.length,
itemBuilder: (context, index) {
return ListTile(
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
CircleAvatar(
backgroundImage: NetworkImage(commentHeader[index])
),
const SizedBox(width: 10,),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(commentName[index],
style: const TextStyle(fontSize: 18)),
const SizedBox(width: 8),
// Adjust the spacing between elements
Text(commentTimes[index],
style: const TextStyle(fontSize: 14),),
// Add the timestamp
],
),
],
), // Ad
Padding(
padding: const EdgeInsets.only(
left: 50, top: 10, bottom: 20),
child: Text(
comments[index],
style: const TextStyle(
fontSize: 18), // Customize the font size if needed
),
),
Container(
width: 560,
height: 2,
color: const Color(0xffE3F0ED),
)
],
),
);
},
),
),
///
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: TextFieldColor(
controller: commentController,
hintText: '来发表你的评论吧!',
)
),
const SizedBox(width: 8.0),
ElevatedButton(
onPressed: () async {
submitComment();
UniversalBean bean = await commentMusic().comment(
musicId: widget.initialSongIndex,
content: commentController.text,
Authorization: AppData().currentToken);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
// Change Colors.blue to your desired background color
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
10), // Adjust the radius as needed
),
minimumSize: const Size(30, 44),
),
child: const Text(
'提交',
style: TextStyle(
fontSize: 16
),
),
),
],
),
),
],
),
);
}
void submitComment() async {
String comment = commentController.text.trim();
if (comment.isEmpty) {
print('Comment cannot be empty');
Get.snackbar('错误', '评论不能为空');
return;
}
print('Submitting comment with content: $comment');
try {
UniversalBean bean = await commentMusic().comment(
musicId: widget.initialSongIndex,
content: comment,
Authorization: AppData().currentToken,
);
//
if (bean.code == 200) {
print('Comment submitted successfully');
commentController.clear();
_fetchSonglistData(); //
} else {
print('Failed to submit comment: ${bean.msg}');
Get.snackbar('错误', bean.msg ?? '评论提交失败');
}
} catch (error) {
print('Error submitting comment: $error');
}
}
}

@ -1,436 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:music_player_miao/api/api_music_return.dart';
import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/getComment_bean.dart';
import 'package:music_player_miao/models/universal_bean.dart';
import 'package:music_player_miao/widget/text_field.dart';
class CommentView extends StatefulWidget {
final int id;
final String song;
final String singer;
final String cover;
const CommentView({
super.key,
required this.id,
required this.song,
required this.singer,
required this.cover,
});
@override
_CommentViewState createState() => _CommentViewState();
}
class _CommentViewState extends State<CommentView> {
List comments = [];
ScrollController _scrollController = ScrollController();
TextEditingController commentController = TextEditingController();
FocusNode commentFocusNode = FocusNode();
List commentTimes = [];
List commentHeader = [];
List commentName = [];
bool ascendingOrder = true;
int _page = 1;
int _pageSize = 10;
int _total = 0;
bool _isLoading = false;
bool _hasMoreData = true;
bool _isSendingComment = false;
String avatar = AppData().currentAvatar;
String username = AppData().currentUsername;
bool _isInitialLoading = true;
@override
void initState() {
super.initState();
_scrollController.addListener(_scrollListener);
_fetchCommentData();
commentController.addListener(() {
setState(() {});
});
}
@override
void dispose() {
_scrollController.dispose();
commentController.dispose();
super.dispose();
}
void _scrollListener() {
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
if (!_isLoading && _hasMoreData) {
_loadMoreData();
}
}
}
Future<void> _loadMoreData() async {
if (_isLoading || !_hasMoreData) return;
setState(() {
_isLoading = true;
});
_page++;
await _fetchCommentData();
setState(() {
_isLoading = false;
});
}
String formatDateTime(String dateTimeStr) {
try {
DateTime dateTime = DateTime.parse(dateTimeStr);
//
return "${dateTime.year}-${dateTime.month.toString().padLeft(2, '0')}-${dateTime.day.toString().padLeft(2, '0')} ${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}";
} catch (e) {
return dateTimeStr; //
}
}
Future<void> _fetchCommentData() async {
print('Fetching page $_page');
try {
GetCommentBean bean1 = await getCommentApi().getComment(
musicId: widget.id,
pageNo: _page,
pageSize: _pageSize,
Authorization: AppData().currentToken,
);
if (bean1.rows == null || bean1.rows!.isEmpty) {
setState(() {
_hasMoreData = false;
_isInitialLoading = false;
});
return;
}
_total = bean1.total!;
setState(() {
if (_page == 1) {
comments =
bean1.rows!.map((rows) => rows.content ?? 'No content').toList();
commentTimes = bean1.rows!
.map((rows) => formatDateTime(rows.time ?? 'Unknown time'))
.toList();
commentHeader = bean1.rows!
.map((rows) => rows.avatar ?? 'Default avatar')
.toList();
commentName =
bean1.rows!.map((rows) => rows.username ?? 'Anonymous').toList();
} else {
comments.addAll(
bean1.rows!.map((rows) => rows.content ?? 'No content').toList());
commentTimes.addAll(bean1.rows!
.map((rows) => formatDateTime(rows.time ?? 'Unknown time'))
.toList());
commentHeader.addAll(bean1.rows!
.map((rows) => rows.avatar ?? 'Default avatar')
.toList());
commentName.addAll(
bean1.rows!.map((rows) => rows.username ?? 'Anonymous').toList());
}
_hasMoreData = comments.length < _total;
_isInitialLoading = false;
});
} catch (error) {
print('Error fetching comment data: $error');
setState(() {
_isLoading = false;
_isInitialLoading = false;
});
}
}
void _sortComments() {
setState(() {
comments = comments.reversed.toList();
commentTimes = commentTimes.reversed.toList();
commentHeader = commentHeader.reversed.toList();
commentName = commentName.reversed.toList();
});
}
//
bool isCommentValid() {
String comment = commentController.text.trim();
return comment.isNotEmpty;
}
void submitComment() async {
String comment = commentController.text.trim();
if (!isCommentValid()) {
return; //
}
setState(() {
_isSendingComment = true;
});
try {
UniversalBean bean = await commentMusic().comment(
musicId: widget.id,
content: comment,
Authorization: AppData().currentToken,
);
if (bean.code == 200) {
commentController.clear();
setState(() {
comments = [comment, ...comments];
commentTimes = [
formatDateTime(DateTime.now().toString()),
...commentTimes
];
commentHeader = [avatar, ...commentHeader];
commentName = [username, ...commentName];
_total++;
});
}
} catch (error) {
print('Error submitting comment: $error');
} finally {
setState(() {
_isSendingComment = false;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: const Color(0xffF6FFD1),
title: Text(
'评论($_total)',
style: TextStyle(color: Colors.black, fontSize: 22),
),
elevation: 0,
leading: IconButton(
onPressed: () {
Get.back();
},
icon: Image.asset(
"assets/img/back.png",
width: 25,
height: 25,
fit: BoxFit.contain,
),
),
),
body: Column(
children: [
// ... ...
Container(
height: 80,
padding: const EdgeInsets.only(left: 20, right: 10),
decoration: BoxDecoration(
color: const Color(0xffF9F2AF),
borderRadius: BorderRadius.circular(20)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.network(
widget.cover,
width: 60,
height: 60,
fit: BoxFit.cover,
),
),
const SizedBox(width: 20),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
widget.song,
maxLines: 1,
style: const TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.w400),
),
Text(
widget.singer,
maxLines: 1,
style: const TextStyle(
color: Colors.black, fontSize: 14),
)
],
),
],
),
],
),
),
//
Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"评论区",
style: TextStyle(fontSize: 18),
),
Row(
children: [
const Text(
"时间",
style: TextStyle(fontSize: 16),
),
IconButton(
onPressed: () {
setState(() {
ascendingOrder = !ascendingOrder;
_sortComments();
});
},
icon: Image.asset(
ascendingOrder
? "assets/img/commend_up.png"
: "assets/img/commend_down.png",
fit: BoxFit.contain,
),
),
],
)
],
),
),
//
Expanded(
child: _isInitialLoading
? const Center(
child: CircularProgressIndicator(
color: Color(0xff429482),
),
)
: ListView.builder(
controller: _scrollController,
itemCount: comments.length + 1, // +1
itemBuilder: (context, index) {
if (index == comments.length) {
// "没有更多数据"
return Container(
padding: const EdgeInsets.all(16.0),
alignment: Alignment.center,
child: _isLoading
? const CircularProgressIndicator(
color: Color(0xff429482),
)
: _hasMoreData
? const Text('上拉加载更多')
: const Text('没有更多评论了'),
);
}
return ListTile(
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
CircleAvatar(
backgroundImage:
NetworkImage(commentHeader[index])),
const SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(commentName[index],
style: const TextStyle(fontSize: 18)),
Text(
commentTimes[index],
style: const TextStyle(fontSize: 14),
),
],
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 50, top: 10, bottom: 20),
child: Text(
comments[index],
style: const TextStyle(fontSize: 18),
),
),
Container(
width: 560,
height: 2,
color: const Color(0xffE3F0ED),
)
],
),
);
},
),
),
//
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: TextFieldColor(
controller: commentController,
hintText: '来发表你的评论吧!',
enabled: !_isSendingComment,
),
),
const SizedBox(width: 8.0),
ElevatedButton(
onPressed: isCommentValid() && !_isSendingComment
? submitComment
: null,
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
foregroundColor: Colors.black45,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
minimumSize: const Size(30, 44),
disabledBackgroundColor: Colors.grey,
),
child: _isSendingComment
? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
)
: const Text(
'发送',
style: TextStyle(fontSize: 16),
),
),
],
),
),
],
),
);
}
}

@ -4,10 +4,9 @@ import 'package:get/get.dart';
import 'package:music_player_miao/api/api_music_return.dart'; import 'package:music_player_miao/api/api_music_return.dart';
import 'package:music_player_miao/common_widget/app_data.dart'; import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/search_bean.dart'; import 'package:music_player_miao/models/search_bean.dart';
import 'package:music_player_miao/view/comment_view.dart'; import 'package:music_player_miao/view/commend_view.dart';
import '../../view_model/home_view_model.dart'; import '../../view_model/home_view_model.dart';
import '../api/api_music_list.dart'; import '../api/api_music_list.dart';
import '../common/download_manager.dart';
import '../common_widget/Song_widegt.dart'; import '../common_widget/Song_widegt.dart';
import '../common_widget/list_cell.dart'; import '../common_widget/list_cell.dart';
import '../models/getMusicList_bean.dart'; import '../models/getMusicList_bean.dart';
@ -20,78 +19,59 @@ class HomeView extends StatefulWidget {
State<HomeView> createState() => _HomeViewState(); State<HomeView> createState() => _HomeViewState();
} }
class _HomeViewState extends State<HomeView> class _HomeViewState extends State<HomeView> {
with AutomaticKeepAliveClientMixin {
final homeVM = Get.put(HomeViewModel()); final homeVM = Get.put(HomeViewModel());
final TextEditingController _controller = TextEditingController(); final TextEditingController _controller = TextEditingController();
bool _isSearching = false; bool _isSearching = false;
final downloadManager = Get.put(DownloadManager());
List<Song> selectedSongs = [];
@override
bool get wantKeepAlive => true;
@override
void initState() { void initState() {
super.initState(); super.initState();
_fetchSonglistData(); _fetchSonglistData();
} }
List<Song> songs = [];
Future<void> _onRefresh() async {
try {
//
await _fetchSonglistData();
} catch (e) {
print('Refresh error: $e');
//
}
}
Future<void> _fetchSonglistData() async { Future<void> _fetchSonglistData() async {
try { MusicListBean bean1 =
MusicListBean bean1 = await GetMusic().getMusic1(Authorization: AppData().currentToken);
await GetMusic().getMusic1(Authorization: AppData().currentToken); MusicListBean bean2 =
MusicListBean bean2 = await GetMusic().getMusic2(Authorization: AppData().currentToken);
await GetMusic().getMusic2(Authorization: AppData().currentToken); MusicListBean bean3 =
MusicListBean bean3 = await GetMusic().getMusic3(Authorization: AppData().currentToken);
await GetMusic().getMusic3(Authorization: AppData().currentToken);
setState(() { setState(() {
selectedSongs = [ songs = [
Song( Song(
artistPic: bean1.coverPath!, artistPic: bean1.coverPath!,
title: bean1.name!, title: bean1.name!,
artist: bean1.singerName!, artist: bean1.singerName!,
musicurl: bean1.musicPath!, musicurl: bean1.musicPath!,
pic: bean1.coverPath!, pic: bean1.coverPath!,
id: bean1.id!, id: bean1.id!,
likes: bean1.likeOrNot!, likes: bean1.likeOrNot!,
collection: bean1.collectOrNot!), collection: bean1.collectOrNot!),
Song( Song(
artistPic: bean2.coverPath!, artistPic: bean2.coverPath!,
title: bean2.name!, title: bean2.name!,
artist: bean2.singerName!, artist: bean2.singerName!,
musicurl: bean2.musicPath!, musicurl: bean2.musicPath!,
pic: bean2.coverPath!, pic: bean2.coverPath!,
id: bean2.id!, id: bean2.id!,
likes: bean2.likeOrNot!, likes: bean2.likeOrNot!,
collection: bean2.collectOrNot!), collection: bean2.collectOrNot!),
Song( Song(
artistPic: bean3.coverPath!, artistPic: bean3.coverPath!,
title: bean3.name!, title: bean3.name!,
artist: bean3.singerName!, artist: bean3.singerName!,
musicurl: bean3.musicPath!, musicurl: bean3.musicPath!,
pic: bean3.coverPath!, pic: bean3.coverPath!,
id: bean3.id!, id: bean3.id!,
likes: bean3.likeOrNot!, likes: bean3.likeOrNot!,
collection: bean3.collectOrNot!), collection: bean3.collectOrNot!),
]; ];
}); });
} catch (e) {
print('Error occurred while fetching song list: $e');
}
} }
/// ///
List<Map> imgList = [ List<Map> imgList = [
{"image": "assets/img/banner.png"}, {"image": "assets/img/banner.png"},
@ -99,96 +79,23 @@ class _HomeViewState extends State<HomeView>
{"image": "assets/img/banner.png"}, {"image": "assets/img/banner.png"},
]; ];
List<Song> _filteredData = []; List<String> _filteredData = [];
Future<void> _filterData(String query) async { Future<void> _filterData(String query) async {
if (query.isNotEmpty) { if (query.isNotEmpty) {
try { SearchBean bean = await SearchMusic().search(keyword: query);
// if (bean.code == 200) {
SearchBean bean = await SearchMusic().search(
keyword: query,
Authorization: AppData().currentToken,
);
//
if (bean.code == 200 && bean.data != null) {
//
List<Future<Song?>> songDetailsFutures = [];
// id
for (var data in bean.data!) {
if (data.id != null) {
// id null
// 使 id Future
songDetailsFutures.add(GetMusicDetail()
.getMusicDetail(
songId: data.id!,
Authorization: AppData().currentToken,
)
.then((details) {
if (details != null) {
// Song
return Song(
artistPic: details.artistPic ?? '',
//
title: data.name ?? '',
//
artist: details.artist ?? '',
//
musicurl: details.musicurl ?? '',
//
pic: details.pic ?? '',
//
id: details.id,
// ID
likes: details.likes,
//
collection: details.collection, //
);
}
return null; // null
}).catchError((error) {
print("Error occurred while fetching song details: $error");
return null; // null
}));
} else {
print("Song ID is null for song: ${data.name}");
}
}
// 使 Future.wait
List<Song?> songDetailsList = await Future.wait(songDetailsFutures);
// null
List<Song> validSongDetails = songDetailsList
.where((song) => song != null)
.cast<Song>()
.toList();
// UI _filteredData
setState(() {
_filteredData = validSongDetails; //
_isSearching = true; //
});
//
print("Filtered Data: $_filteredData");
} else {
setState(() {
_filteredData = [];
_isSearching = false;
});
}
} catch (error) {
print("Error occurred during search: $error");
setState(() { setState(() {
_filteredData = []; _filteredData = bean.data
_isSearching = false; ?.map((data) =>
"${data.name} ") // Adjust this based on your data structure
.toList() ??
[];
_isSearching = true;
}); });
} }
} else { } else {
setState(() { setState(() {
_filteredData = [];
_isSearching = false; _isSearching = false;
}); });
} }
@ -196,8 +103,6 @@ class _HomeViewState extends State<HomeView>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context);
/// ///
var MySwiperWidget = Swiper( var MySwiperWidget = Swiper(
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
@ -228,265 +133,193 @@ class _HomeViewState extends State<HomeView>
child: Scaffold( child: Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: Column( body: SingleChildScrollView(
children: [ child: Column(
/// crossAxisAlignment: CrossAxisAlignment.start,
Container( children: [
padding: const EdgeInsets.only(left: 20, top: 50), ///
child: const Row( Container(
crossAxisAlignment: CrossAxisAlignment.end, padding: const EdgeInsets.only(left: 20, top: 50),
children: [ child: const Row(
Text( crossAxisAlignment: CrossAxisAlignment.end,
'喵听', children: [
style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold), Text(
), '喵听',
SizedBox(width: 10), style:
Text( TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
'你的云端音乐库',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
],
),
),
const SizedBox(height: 10),
///
Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
child: Column(
children: [
Container(
height: 38,
decoration: BoxDecoration(
color: const Color(0xffF9F2AF),
borderRadius: BorderRadius.circular(19),
boxShadow: const [
BoxShadow(
color: Colors.black26,
offset: Offset(0, 1),
blurRadius: 0.1,
)
],
), ),
child: TextField( SizedBox(
controller: _controller, width: 10,
onChanged: (query) {
setState(() async {
_filterData(query);
});
},
decoration: InputDecoration(
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(
vertical: 4,
horizontal: 20,
),
prefixIcon: Container(
margin: const EdgeInsets.only(left: 20),
alignment: Alignment.centerLeft,
width: 30,
child: Image.asset(
"assets/img/home_search.png",
width: 20,
height: 20,
fit: BoxFit.contain,
),
),
hintText: "大家都在搜《背对背拥抱》",
hintStyle: const TextStyle(
color: Color(0xffA5A5A5),
fontSize: 13,
),
),
), ),
), Text(
if (_isSearching) '你的云端音乐库',
style:
TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
],
),
),
///
Container(
padding: const EdgeInsets.only(left: 20, right: 20, top: 10),
child: Column(
children: [
Container( Container(
height: 150, height: 38,
width: 345,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color(0xffF9F2AF).withOpacity(0.7), color: const Color(0xffF9F2AF),
borderRadius: BorderRadius.circular(19),
boxShadow: const [
BoxShadow(
color: Colors.black26,
offset: Offset(0, 1),
blurRadius: 0.1,
)
],
), ),
child: ListView.builder( child: TextField(
padding: EdgeInsets.zero, controller: _controller,
itemCount: _filteredData.length, onChanged: (query) {
itemBuilder: (context, index) { setState(() async {
return ListTile( _filterData(query);
title: Text(_filteredData[index].title), });
onTap: () {
//
Navigator.push(
// 使 Navigator
context,
MaterialPageRoute(
// MusicView
builder: (context) => MusicView(
songList: _filteredData,
//
initialSongIndex:
index, //
),
),
);
},
);
}, },
decoration: InputDecoration(
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(
vertical: 4,
horizontal: 20,
),
prefixIcon: Container(
margin: const EdgeInsets.only(left: 20),
alignment: Alignment.centerLeft,
width: 30,
child: Image.asset(
"assets/img/home_search.png",
width: 20,
height: 20,
fit: BoxFit.contain,
),
),
hintText: "大家都在搜《背对背拥抱》",
hintStyle: const TextStyle(
color: Color(0xffA5A5A5),
fontSize: 13,
),
),
), ),
), ),
], if (_isSearching)
),
),
const SizedBox(
height: 10,
),
///+
Expanded(
child: RefreshIndicator(
onRefresh: _onRefresh,
color: const Color(0xff429482),
backgroundColor: Colors.white,
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
///+
Container( Container(
padding: height: 150,
const EdgeInsets.only(left: 20, right: 20, top: 10), width: 345,
child: const Text( decoration: BoxDecoration(
'每日推荐', color: const Color(0xffF9F2AF).withOpacity(0.7),
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.w500),
), ),
), child: ListView.builder(
const SizedBox(height: 5), padding: EdgeInsets.zero,
Container( itemCount: _filteredData.length,
padding: const EdgeInsets.symmetric( itemBuilder: (context, index) {
horizontal: 20, vertical: 5), return ListTile(
height: 186, title: Text(_filteredData[index]),
width: double.infinity, );
child: MySwiperWidget, },
),
const SizedBox(height: 10),
///
Container(
alignment: Alignment.topLeft,
padding:
const EdgeInsets.only(left: 20, right: 20, top: 5),
child: const Text(
'精选歌曲',
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.w500),
), ),
), ),
const SizedBox( ],
height: 5, ),
), ),
ListView.builder(
padding: EdgeInsets.zero,
itemCount: selectedSongs.length,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return ListTile(
leading: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.network(
selectedSongs[index].pic,
width: 60,
height: 60,
fit: BoxFit.cover,
),
),
title: Text(
selectedSongs[index].title,
style: const TextStyle(
fontSize: 18, color: Colors.black),
),
subtitle: Text(
selectedSongs[index].artist,
style: const TextStyle(
fontSize: 16, color: Colors.black),
),
trailing: InkWell(
onTap: () {
_bottomSheet(context, index);
},
child: Image.asset('assets/img/More.png'),
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MusicView(
songList: selectedSongs,
initialSongIndex: index,
onSongStatusChanged:
(index, isCollected, isLiked) {
setState(() {
selectedSongs[index].collection =
isCollected;
selectedSongs[index].likes = isLiked;
downloadManager.updateSongInfo(
selectedSongs[index].id,
isCollected,
isLiked);
});
},
),
),
);
},
);
},
),
const SizedBox( ///+
height: 10, Container(
), padding: const EdgeInsets.only(left: 20, right: 20, top: 10),
child: const Text(
'每日推荐',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.w500),
),
),
Container(
padding: const EdgeInsets.only(left: 20, right: 20, top: 5),
height: 186,
width: double.infinity,
child: MySwiperWidget,
),
/// ///
Container( Container(
padding: alignment: Alignment.topLeft,
const EdgeInsets.only(left: 20, right: 20, top: 5), padding: const EdgeInsets.only(left: 20, right: 20, top: 5),
child: const Text( child: const Text(
'精选歌单', '精选歌曲',
style: TextStyle( style: TextStyle(fontSize: 22, fontWeight: FontWeight.w500),
fontSize: 20, fontWeight: FontWeight.w500), ),
),
ListView.builder(
padding: EdgeInsets.zero,
itemCount: songs.length,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return ListTile(
leading: Image.network(songs[index].pic),
title: Text(
songs[index].title,
style: const TextStyle(fontSize: 18, color: Colors.black),
),
subtitle: Text(
songs[index].artist,
style: const TextStyle(fontSize: 16, color: Colors.black),
),
trailing: InkWell(
onTap: () {
_bottomSheet(context, index);
},
child: Image.asset('assets/img/More.png'),
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MusicView(
song: songs[index],
initialSongIndex: index,
),
), ),
), );
const SizedBox( },
height: 5, );
), },
SizedBox( ),
height: 180,
child: ListView.builder( ///
scrollDirection: Axis.horizontal, Container(
shrinkWrap: true, padding: const EdgeInsets.only(left: 20, right: 20, top: 5),
padding: const EdgeInsets.only(left: 20), child: const Text(
itemCount: homeVM.listArr.length, '精选歌单',
itemBuilder: (context, index) { style: TextStyle(fontSize: 22, fontWeight: FontWeight.w500),
var sObj = homeVM.listArr[index];
return ListRow(
sObj: sObj,
onPressed: () {},
onPressedPlay: () {},
);
}),
),
],
),
), ),
), ),
), SizedBox(
], height: 180,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
padding: const EdgeInsets.only(left: 20),
itemCount: homeVM.listArr.length,
itemBuilder: (context, index) {
var sObj = homeVM.listArr[index];
return ListRow(
sObj: sObj,
onPressed: () {},
onPressedPlay: () {},
);
}),
),
],
),
), ),
), ),
); );
@ -494,90 +327,110 @@ class _HomeViewState extends State<HomeView>
Future _bottomSheet(BuildContext context, int index) { Future _bottomSheet(BuildContext context, int index) {
return showModalBottomSheet( return showModalBottomSheet(
context: context, context: context,
backgroundColor: Colors.white, backgroundColor: Colors.white,
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30)), borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
), builder: (context) => Container(
builder: (context) => StatefulBuilder( height: 210,
// 使StatefulBuilder便 padding: const EdgeInsets.only(top: 20),
builder: (context, setState) { child: Column(
bool likesnot = false; // crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
return Container( Row(
height: 150, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
padding: const EdgeInsets.only(top: 20), children: [
child: Column( Column(
crossAxisAlignment: CrossAxisAlignment.stretch, children: [
children: [ IconButton(
Row( onPressed: () {},
mainAxisAlignment: MainAxisAlignment.spaceEvenly, icon: Image.asset("assets/img/list_add.png"),
children: [ iconSize: 60,
Column( ),
children: [ const Text("加入歌单")
IconButton( ],
onPressed: () {}, ),
icon: Image.asset("assets/img/list_add.png"), Column(
iconSize: 60, children: [
), IconButton(
const Text("加入歌单"), onPressed: () {},
], icon: Image.asset("assets/img/list_download.png"),
), iconSize: 60,
Column( ),
children: [ const Text("下载")
IconButton( ],
onPressed: () {}, ),
icon: Image.asset("assets/img/list_download.png"), Column(
iconSize: 60, children: [
), IconButton(
const Text("下载"), onPressed: () {},
], icon: Image.asset("assets/img/list_collection.png"),
), iconSize: 60,
Column( ),
children: [ const Text("收藏")
IconButton( ],
onPressed: () {}, ),
icon: Image.asset("assets/img/list_collection.png"), Column(
iconSize: 60, children: [
), IconButton(
const Text("收藏"), onPressed: () {},
], icon: Image.asset("assets/img/list_good.png"),
), iconSize: 60,
Column( ),
children: [ const Text("点赞")
IconButton( ],
onPressed: () {}, ),
icon: Image.asset("assets/img/list_good.png"), Column(
iconSize: 60, children: [
), IconButton(
const Text("点赞") onPressed: () {
], Get.to(() => CommentView(
), initialSongIndex: index,
Column( ));
children: [ },
IconButton( icon: Image.asset("assets/img/list_comment.png"),
onPressed: () { iconSize: 60,
Navigator.pop(context); ),
// Get.to(() => const Text("评论")
// CommentView( ],
// id:, ),
// song:, ],
// singer:, ),
// )); const SizedBox(
}, height: 10,
icon: Image.asset("assets/img/list_comment.png"), ),
iconSize: 60, ElevatedButton(
), onPressed: () {},
const Text("评论"), child: const Text(
], "查看详情页",
), style: TextStyle(color: Colors.black, fontSize: 18),
],
), ),
], style: ElevatedButton.styleFrom(
), backgroundColor: const Color(0xffE6F4F1),
); padding: const EdgeInsets.symmetric(vertical: 8),
}, tapTargetSize: MaterialTapTargetSize.shrinkWrap,
), shape: const RoundedRectangleBorder(
); borderRadius: BorderRadius.zero,
),
),
),
ElevatedButton(
onPressed: () => Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 8),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
"取消",
style: TextStyle(color: Colors.black, fontSize: 18),
),
),
],
),
));
} }
} }

@ -5,100 +5,6 @@ import 'package:music_player_miao/view/user/user_view.dart';
import '../home_view.dart'; import '../home_view.dart';
import '../release_view.dart'; import '../release_view.dart';
//
class MiniPlayer extends StatelessWidget {
const MiniPlayer({super.key});
@override
Widget build(BuildContext context) {
return Container(
height: 50, //
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 4,
offset: const Offset(0, -1),
),
],
),
child: Row(
children: [
//
Container(
width: 50,
height: 50,
color: Colors.grey[200],
child: Image.asset(
'assets/img/artist_pic.png',
fit: BoxFit.cover,
),
),
//
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'背对背拥抱',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
'林俊杰',
style: TextStyle(
fontSize: 12,
color: Colors.grey[600],
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
//
Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(Icons.play_arrow),
onPressed: () {},
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
iconSize: 24,
),
const SizedBox(width: 16),
IconButton(
icon: const Icon(Icons.playlist_play),
onPressed: () {},
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
iconSize: 24,
),
const SizedBox(width: 8),
],
),
],
),
),
),
],
),
);
}
}
class MainTabView extends StatefulWidget { class MainTabView extends StatefulWidget {
const MainTabView({super.key}); const MainTabView({super.key});
@ -106,113 +12,93 @@ class MainTabView extends StatefulWidget {
State<MainTabView> createState() => _MainTabViewState(); State<MainTabView> createState() => _MainTabViewState();
} }
class _MainTabViewState extends State<MainTabView> with SingleTickerProviderStateMixin { class _MainTabViewState extends State<MainTabView> with SingleTickerProviderStateMixin{
TabController? controller; TabController? controller;
int selectTab = 0; int selectTab = 0;
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
@override @override
void initState() { void initState() {
// TODO: implement initState
super.initState(); super.initState();
controller = TabController(length: 4, vsync: this); controller = TabController(length: 4, vsync: this);
controller?.addListener(() { controller?.addListener(() {
selectTab = controller?.index ?? 0; selectTab = controller?.index ?? 0;
setState(() {}); setState(() {
});
}); });
} }
@override @override
void dispose() { void dispose() {
// TODO: implement dispose
super.dispose(); super.dispose();
controller?.dispose(); controller?.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
key: scaffoldKey, key: scaffoldKey,
body: Stack( body: TabBarView(
children: [ controller: controller,
// TabBarView children: const [
Column( HomeView(),
children: [ RankView(),
Expanded( ReleaseView(),
child: TabBarView( UserView()
controller: controller, ],
children: const [ ),
HomeView(), bottomNavigationBar: BottomAppBar(
RankView(), color: Colors.white,
ReleaseView(), elevation: 0,
UserView() child: TabBar(
], controller: controller,
), indicatorColor: Colors.transparent,
), indicatorWeight: 3,
], labelColor: Colors.black,
labelStyle: const TextStyle(
fontSize: 12
), ),
// unselectedLabelColor: const Color(0xffCDCDCD),
Positioned( unselectedLabelStyle: const TextStyle(
left: 0, fontSize: 12
right: 0,
bottom: 0,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const MiniPlayer(),
Container(
color: Colors.white,
child: TabBar(
controller: controller,
indicatorColor: Colors.transparent,
labelColor: Colors.black,
labelStyle: const TextStyle(fontSize: 12),
unselectedLabelColor: const Color(0xffCDCDCD),
unselectedLabelStyle: const TextStyle(fontSize: 12),
tabs: [
Tab(
height: 60,
icon: Image.asset(
selectTab == 0 ? "assets/img/home_tab.png" : "assets/img/home_tab_un.png",
width: 32,
height: 32,
),
text: "首页",
),
Tab(
height: 60,
icon: Image.asset(
selectTab == 1 ? "assets/img/list_tab.png" : "assets/img/list_tab_un.png",
width: 32,
height: 32,
),
text: "排行榜",
),
Tab(
height: 60,
icon: Image.asset(
selectTab == 2 ? "assets/img/music_tab.png" : "assets/img/music_tab_un.png",
width: 32,
height: 32,
),
text: "发布",
),
Tab(
height: 60,
icon: Image.asset(
selectTab == 3 ? "assets/img/user_tab.png" : "assets/img/user_tab_un.png",
width: 32,
height: 32,
),
text: "我的",
),
],
),
),
],
),
), ),
], tabs: [
Tab(
text:
"首页",
icon:Image.asset(
selectTab == 0?"assets/img/home_tab.png":"assets/img/home_tab_un.png",
width: 45,height: 45,),
),
Tab(
text:
"排行榜",
icon:Image.asset(
selectTab == 1?"assets/img/list_tab.png":"assets/img/list_tab_un.png",
width: 45,height: 45,),
),
Tab(
text:
"发布",
icon:Image.asset(selectTab == 2?"assets/img/music_tab.png":"assets/img/music_tab_un.png",
width: 45,height: 45,),
),
Tab(
text:
"个人",
icon:Image.asset(selectTab == 3?"assets/img/user_tab.png":"assets/img/user_tab_un.png",
width: 45,height: 45,),
),
],
),
), ),
); );
} }

@ -1,405 +1,153 @@
import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:just_audio/just_audio.dart';
import 'package:music_player_miao/common_widget/app_data.dart'; import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/universal_bean.dart';
import '../../view_model/home_view_model.dart'; import '../../view_model/home_view_model.dart';
import 'package:audioplayers/audioplayers.dart';
import '../api/api_music_likes.dart'; import '../api/api_music_likes.dart';
import '../api/api_collection.dart';
import '../api/api_music_list.dart'; import '../api/api_music_list.dart';
import '../common/download_manager.dart'; import '../api/api_collection.dart';
import '../common_widget/Song_widegt.dart'; import '../common_widget/Song_widegt.dart';
import '../models/getMusicList_bean.dart'; import '../models/getMusicList_bean.dart';
import '../view/comment_view.dart'; import '../view/commend_view.dart';
import '../models/universal_bean.dart';
class MusicView extends StatefulWidget { class MusicView extends StatefulWidget {
final List<Song> songList; final Song song;
final int initialSongIndex; final int initialSongIndex;
final Function(int index, bool isCollected, bool isLiked)? onSongStatusChanged; const MusicView({super.key, required this.song, required this.initialSongIndex});
const MusicView({
super.key,
required this.songList,
required this.initialSongIndex,
this.onSongStatusChanged,
});
@override @override
State<MusicView> createState() => _MusicViewState(); State<MusicView> createState() => _MusicViewState();
} }
class _MusicViewState extends State<MusicView> with SingleTickerProviderStateMixin { class _MusicViewState extends State<MusicView> {
final homeVM = Get.put(HomeViewModel()); final homeVM = Get.put(HomeViewModel());
bool _isDisposed = false; bool _isDisposed = false;
AppData appData = AppData(); AppData appData = AppData();
late int currentSongIndex; late int currentSongIndex;
late AudioPlayer _audioPlayer;
StreamSubscription? _playerStateSubscription;
final downloadManager = Get.put(DownloadManager());
// Stream values
Duration _duration = Duration.zero;
Duration _position = Duration.zero;
// Current song info
late String artistName;
late String musicName;
late bool likesnot;
late bool collectionsnot;
// Song lists
List<int> id = [];
List<String> song2 = [];
List<String> artist = [];
List<String> music = [];
List<bool> likes = [];
List<bool> collection = [];
late AnimationController _rotationController; List song2 = [];
List artist = [];
bool _isLoading = false; List music = [];
List likes = [];
@override List collection = [];
void initState() {
super.initState();
currentSongIndex = widget.initialSongIndex;
// _initializeAsync();
_fetchSonglistData();
_updateCurrentSong();
playerInit();
_rotationController = AnimationController(
duration: const Duration(seconds: 20),
vsync: this,
);
_playerStateSubscription = _audioPlayer.playerStateStream.listen((state) {
if (!_isDisposed) {
if (state.playing) {
_rotationController.repeat();
} else {
_rotationController.stop();
}
}
});
}
@override
void dispose() {
_isDisposed = true;
_playerStateSubscription?.cancel();
_rotationController.stop();
_rotationController.dispose();
_audioPlayer.dispose();
super.dispose();
}
Future<void> _fetchSonglistData() async { Future<void> _fetchSonglistData() async {
setState(() { MusicListBean bean1 =
for (int i = 0; i < widget.songList.length; i++) { await GetMusic().getMusic1(Authorization: AppData().currentToken);
id.add(widget.songList[i].id); MusicListBean bean2 =
// TODO musicurl , await GetMusic().getMusic2(Authorization: AppData().currentToken);
if (widget.songList[i].musicurl == null) { MusicListBean bean3 =
song2.add(""); await GetMusic().getMusic3(Authorization: AppData().currentToken);
} else {
song2.add(widget.songList[i].musicurl!);
}
artist.add(widget.songList[i].artist);
music.add(widget.songList[i].title);
//
likes.add(widget.songList[i].likes ?? false);
collection.add(widget.songList[i].collection ?? false);
}
});
}
//
Future<void> _checkAndUpdateSongStatus(int index) async {
// likescollectionnull
if (widget.songList[index].likes == null || widget.songList[index].collection == null) {
try {
MusicListBean musicListBean = await GetMusic().getMusicById(
id: id[index],
Authorization: AppData().currentToken,
);
if (!_isDisposed && musicListBean.code == 200) {
setState(() {
likes[index] = musicListBean.likeOrNot!;
collection[index] = musicListBean.collectOrNot!;
//
if (index == currentSongIndex) {
likesnot = musicListBean.likeOrNot!;
collectionsnot = musicListBean.collectOrNot!;
}
widget.onSongStatusChanged?.call(
index,
musicListBean.collectOrNot!,
musicListBean.likeOrNot!,
);
});
}
} catch (e) {
print('Error fetching song status: $e');
}
}
}
Future<void> _updateCurrentSong() async {
if (_isDisposed) return;
setState(() { setState(() {
_isLoading = true; song2 = [bean1.musicPath,bean2.musicPath,bean3.musicPath];
_position = Duration.zero; artist = [bean1.singerName,bean2.singerName,bean3.singerName];
_duration = Duration.zero; music = [bean1.name,bean2.name,bean3.name];
artistName = artist[currentSongIndex]; likes = [bean1.likeOrNot,bean2.likeOrNot,bean3.likeOrNot];
musicName = music[currentSongIndex]; collection = [bean1.collectOrNot,bean2.collectOrNot,bean3.collectOrNot];
likesnot = likes[currentSongIndex];
collectionsnot = collection[currentSongIndex];
}); });
await _checkAndUpdateSongStatus(currentSongIndex);
try {
await _audioPlayer.stop();
_rotationController.reset();
//
final localSong = downloadManager.getLocalSong(currentSongIndex);
final audioSource = localSong != null
? AudioSource.file(localSong.musicurl!)
: AudioSource.uri(Uri.parse(song2[currentSongIndex]));
//
await _audioPlayer.setAudioSource(audioSource, preload: true);
//
final duration = await _audioPlayer.duration;
if (!_isDisposed) {
setState(() {
_duration = duration ?? Duration.zero;
_isLoading = false;
});
}
//
await _audioPlayer.play();
} catch (e) {
print('Error loading audio source: $e');
if (!_isDisposed) {
setState(() {
_isLoading = false;
});
}
}
} }
void playerInit() async {
_audioPlayer = AudioPlayer();
await _checkAndUpdateSongStatus(widget.initialSongIndex);
//
artistName = widget.songList[widget.initialSongIndex].artist;
musicName = widget.songList[widget.initialSongIndex].title;
likesnot = widget.songList[widget.initialSongIndex].likes!;
collectionsnot = widget.songList[widget.initialSongIndex].collection!;
//
_audioPlayer.positionStream.listen((position) {
if (!_isDisposed) {
setState(() => _position = position);
}
});
//
_audioPlayer.durationStream.listen((duration) {
if (!_isDisposed) {
setState(() => _duration = duration ?? Duration.zero);
}
});
// late AudioPlayer _audioPlayer;
_audioPlayer.playerStateStream.listen((state) { late Duration _duration;
if (_isDisposed) return; late Duration _position; late String artistName;
late String musicName;
late bool likesnot;
late bool collectionsnot;
if (state.processingState == ProcessingState.completed) { void playerInit() {
// Stream _audioPlayer = AudioPlayer()..setSourceUrl('${widget.song.musicurl}');
_handleSongCompletion(); _duration = const Duration();
} _position = const Duration();
artistName = '${widget.song.artist}';
musicName = '${widget.song.title}';
likesnot = widget.song.likes;
collectionsnot = widget.song.collection;
_audioPlayer.onDurationChanged.listen((Duration d) {
_duration = d;
setState(() {});
}); });
}
//
void _handleSongCompletion() {
if (_isDisposed) return;
setState(() { _audioPlayer.onPositionChanged.listen((Duration p) {
_position = Duration.zero; _position = p;
_duration = Duration.zero; setState(() {});
}); });
// 使 Future.microtask _audioPlayer.onPlayerComplete.listen((event) {
Future.microtask(() { setState(() {
if (!_isDisposed) { _position = _duration;
playNextSong(); });
}
}); });
} }
// Slider void playOrPause() {
Widget _buildProgressSlider() { if (_audioPlayer.state == PlayerState.playing) {
// 0.1 _audioPlayer.pause();
final max = _duration.inSeconds.toDouble() == 0 ? 0.1 : _duration.inSeconds.toDouble();
//
final current = _position.inSeconds.toDouble().clamp(0, max);
return SliderTheme(
data: const SliderThemeData(
trackHeight: 3.0,
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 7.0),
overlayShape: RoundSliderOverlayShape(overlayRadius: 12.0),
),
child: Slider(
min: 0,
max: max,
value: current.toDouble(),
onChanged: (value) async {
if (!_isDisposed && _duration.inSeconds > 0) {
await _audioPlayer.seek(Duration(seconds: value.toInt()));
setState(() {});
}
},
activeColor: const Color(0xff429482),
inactiveColor: const Color(0xffE3F0ED),
),
);
}
Widget _buildPlayButton() {
return SizedBox(
width: 52,
height: 52,
child: Center(
child: _isLoading
? const CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Color(0xff429482)),
strokeWidth: 3.0,
)
: IconButton(
padding: EdgeInsets.zero, //
constraints: const BoxConstraints(
minWidth: 52,
minHeight: 52,
maxWidth: 52,
maxHeight: 52,
),
onPressed: playOrPause,
icon: _audioPlayer.playing
? Image.asset(
"assets/img/music_play.png",
width: 52,
height: 52,
)
: Image.asset(
"assets/img/music_pause.png",
width: 52,
height: 52,
),
),
),
);
}
void playOrPause() async {
if (_isDisposed) return; //
if (_audioPlayer.playing) {
await _audioPlayer.pause();
if (!_isDisposed) { //
_rotationController.stop();
}
} else { } else {
await _audioPlayer.play(); _audioPlayer.resume();
if (!_isDisposed) { //
_rotationController.repeat();
}
}
if (!_isDisposed) {
setState(() {});
} }
setState(() {});
} }
void playNextSong() { void playNextSong() {
if (currentSongIndex < widget.songList.length - 1) { if (currentSongIndex < 2) {
currentSongIndex++; currentSongIndex++;
} else { } else {
currentSongIndex = 0; currentSongIndex = 0;
} }
_updateCurrentSong(); _audioPlayer.setSourceUrl(song2[currentSongIndex]);
artistName = artist[currentSongIndex];
musicName = music[currentSongIndex];
likesnot = likes[currentSongIndex];
collectionsnot = collection[currentSongIndex];
_audioPlayer.resume();
} }
void playPreviousSong() { void playPreviousSong() {
if (currentSongIndex > 0) { if (currentSongIndex > 0) {
currentSongIndex--; currentSongIndex--;
} else { } else {
currentSongIndex = widget.songList.length - 1; currentSongIndex = 2;
} }
_updateCurrentSong();
_audioPlayer.setSourceUrl(song2[currentSongIndex]);
artistName = artist[currentSongIndex];
musicName = music[currentSongIndex];
likesnot = likes[currentSongIndex];
collectionsnot = collection[currentSongIndex];
_audioPlayer.resume();
} }
String formatDuration(Duration duration) { String formatDuration(Duration duration) {
String twoDigits(int n) => n.toString().padLeft(2, "0"); String twoDigits(int n) => n.toString().padLeft(2, "0");
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60)); String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60)); String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));
return "$twoDigitMinutes:$twoDigitSeconds"; return "${twoDigits(duration.inMinutes)}:$twoDigitSeconds";
}
Future<void> _initializeAsync() async {
await _fetchSonglistData();
await _updateCurrentSong();
} }
void _changeCurrentSong(int index) { @override
if (!_isDisposed) { void initState() {
setState(() { playerInit();
currentSongIndex = index; currentSongIndex = widget.initialSongIndex;
_updateCurrentSong(); _fetchSonglistData();
}); super.initState();
}
} }
Widget _buildRotatingAlbumCover() { @override
return RotationTransition( void dispose() {
turns: _rotationController, _isDisposed = true;
child: Stack( _audioPlayer.release();
alignment: Alignment.center, _audioPlayer.dispose();
children: [ super.dispose();
Positioned(
child: ClipRRect(
child: Image.network(
widget.songList[currentSongIndex].artistPic,
width: 225,
height: 225,
fit: BoxFit.cover,
),
),
),
ClipRRect(
child: Image.asset(
"assets/img/music_Ellipse.png",
width: 350,
height: 350,
fit: BoxFit.cover,
),
),
],
),
);
} }
@override @override
@ -444,45 +192,12 @@ class _MusicViewState extends State<MusicView> with SingleTickerProviderStateMix
), ),
), ),
IconButton( IconButton(
onPressed: downloadManager.isDownloading(id[currentSongIndex]) || onPressed: () {},
downloadManager.isCompleted(id[currentSongIndex]) icon: Image.asset(
? null "assets/img/music_download.png",
: () async { width: 30,
await downloadManager.startDownload( height: 30,
song: widget.songList[currentSongIndex], ),
context: context,
);
},
icon: Obx(() {
if (downloadManager.isDownloading(id[currentSongIndex])) {
return Stack(
alignment: Alignment.center,
children: [
SizedBox(
width: 32,
height: 32,
child: CircularProgressIndicator(
value: downloadManager.getProgress(id[currentSongIndex]),
backgroundColor: Colors.grey[200],
valueColor: const AlwaysStoppedAnimation<Color>(Color(0xff429482)),
strokeWidth: 3.0,
),
),
Text(
'${(downloadManager.getProgress(id[currentSongIndex]) * 100).toInt()}',
style: const TextStyle(fontSize: 12),
),
],
);
}
return Image.asset(
downloadManager.isCompleted(id[currentSongIndex])
? "assets/img/music_download_completed.png"
: "assets/img/music_download.png",
width: 30,
height: 30,
);
}),
), ),
], ],
) )
@ -492,7 +207,31 @@ class _MusicViewState extends State<MusicView> with SingleTickerProviderStateMix
height: 80, height: 80,
), ),
Center( Center(
child: _buildRotatingAlbumCover(), child: Stack(
alignment: Alignment.center,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.asset(
"assets/img/music_Ellipse.png",
width: 320,
height: 320,
fit: BoxFit.cover,
),
),
Positioned(
child: ClipRRect(
borderRadius: BorderRadius.circular(80),
child: Image.network(
'${widget.song.artistPic}',
width: 230,
height: 230,
fit: BoxFit.cover,
),
),
)
],
),
), ),
const SizedBox( const SizedBox(
height: 60, height: 60,
@ -519,22 +258,11 @@ class _MusicViewState extends State<MusicView> with SingleTickerProviderStateMix
children: [ children: [
IconButton( IconButton(
onPressed: () async{ onPressed: () async{
UniversalBean bean1 =
await LikesApiMusic().likesMusic(musicId: currentSongIndex+1, Authorization: AppData().currentToken);
setState(() { setState(() {
likesnot = !likesnot; likesnot = !likesnot;
likes[currentSongIndex] = !likes[currentSongIndex];
}); });
UniversalBean response = await LikesApiMusic().likesMusic(musicId: id[currentSongIndex], Authorization: AppData().currentToken);
if (response.code != 200) {
likesnot = !likesnot;
likes[currentSongIndex] = !likes[currentSongIndex];
}
widget.onSongStatusChanged?.call(
currentSongIndex,
collection[currentSongIndex], //
likes[currentSongIndex]
);
}, },
icon: Image.asset( icon: Image.asset(
likesnot likesnot
@ -545,23 +273,12 @@ class _MusicViewState extends State<MusicView> with SingleTickerProviderStateMix
), ),
), ),
IconButton( IconButton(
onPressed: () async { onPressed: () async{
UniversalBean bean1 =
await CollectionApiMusic().addCollection(musicId: currentSongIndex+1, Authorization: AppData().currentToken);
setState(() { setState(() {
collectionsnot = !collectionsnot; collectionsnot = !collectionsnot;
collection[currentSongIndex] = !collection[currentSongIndex];
}); });
UniversalBean response = await CollectionApiMusic().addCollection(musicId: id[currentSongIndex], Authorization: AppData().currentToken);
if (response.code != 200) {
collectionsnot = !collectionsnot;
collection[currentSongIndex] = !collection[currentSongIndex];
}
widget.onSongStatusChanged?.call(
currentSongIndex,
collection[currentSongIndex],
likes[currentSongIndex] //
);
}, },
icon: Image.asset( icon: Image.asset(
collectionsnot collectionsnot
@ -576,12 +293,7 @@ class _MusicViewState extends State<MusicView> with SingleTickerProviderStateMix
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => CommentView( builder: (context) => CommentView(initialSongIndex: widget.initialSongIndex),
id: id[currentSongIndex],
song: musicName,
singer: artistName,
cover: widget.songList[currentSongIndex].artistPic,
),
), ),
); );
}, },
@ -596,21 +308,45 @@ class _MusicViewState extends State<MusicView> with SingleTickerProviderStateMix
], ],
), ),
const SizedBox( const SizedBox(
height: 80, height: 60,
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
formatDuration(_position), "${formatDuration(_position)}",
style: const TextStyle(color: Colors.black), style: const TextStyle(
color: Colors.black,
),
), ),
Expanded( Expanded(
child: _buildProgressSlider(), child: SliderTheme(
data: const SliderThemeData(
trackHeight: 3.0, //
thumbShape: RoundSliderThumbShape(
enabledThumbRadius: 7.0), //
overlayShape:
RoundSliderOverlayShape(overlayRadius: 12.0),
),
child: Slider(
min: 0,
max: _duration.inSeconds.toDouble(),
value: _position.inSeconds.toDouble(),
onChanged: (value) async {
await _audioPlayer
.seek(Duration(seconds: value.toInt()));
setState(() {});
},
activeColor: const Color(0xff429482),
inactiveColor: const Color(0xffE3F0ED),
),
),
), ),
Text( Text(
formatDuration(_duration), "${formatDuration(_duration)}",
style: const TextStyle(color: Colors.black), style: const TextStyle(
color: Colors.black,
),
), ),
], ],
), ),
@ -641,7 +377,15 @@ class _MusicViewState extends State<MusicView> with SingleTickerProviderStateMix
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
_buildPlayButton(), // 使IconButton IconButton(
onPressed: playOrPause,
icon: _audioPlayer.state == PlayerState.playing
? Image.asset(
"assets/img/music_play.png",
)
: Image.asset(
"assets/img/music_pause.png",
)),
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
@ -694,12 +438,9 @@ class _MusicViewState extends State<MusicView> with SingleTickerProviderStateMix
), ),
), ),
), ),
const SizedBox(
height: 10,
),
Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: music.length, itemCount: 3,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
bool isCurrentlyPlaying = currentSongIndex == index; bool isCurrentlyPlaying = currentSongIndex == index;
return ListTile( return ListTile(
@ -733,10 +474,40 @@ class _MusicViewState extends State<MusicView> with SingleTickerProviderStateMix
}, },
), ),
), ),
ElevatedButton(
onPressed: () => Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 14),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
"关闭",
style: TextStyle(color: Colors.black, fontSize: 20),
),
),
], ],
), ),
); );
}, },
); );
} }
void _changeCurrentSong(int index) {
if (!_isDisposed) { // Check the flag before using the player
setState(() {
currentSongIndex = index;
_audioPlayer.setSourceUrl(song2[currentSongIndex]);
artistName = artist[currentSongIndex];
musicName = music[currentSongIndex];
likesnot = likes[currentSongIndex];
collectionsnot = collection[currentSongIndex];
_audioPlayer.resume();
});
}
}
} }

@ -1,507 +0,0 @@
// music_view_test.dart
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../common/audio_player_controller.dart';
import '../common/download_manager.dart';
import '../common_widget/Song_widegt.dart';
import '../common_widget/app_data.dart';
import 'comment_view.dart';
class MusicView extends StatefulWidget {
final List<Song> songList;
final int initialSongIndex;
final Function(int index, bool isCollected, bool isLiked)?
onSongStatusChanged;
const MusicView({
super.key,
required this.songList,
required this.initialSongIndex,
this.onSongStatusChanged,
});
@override
State<MusicView> createState() => _MusicViewState();
}
class _MusicViewState extends State<MusicView>
with SingleTickerProviderStateMixin {
// late AnimationController _rotationController;
final AudioPlayerController playerController =
Get.put(AudioPlayerController());
final downloadManager = Get.find<DownloadManager>();
final AppData appData = AppData();
@override
void initState() {
super.initState();
playerController.initWithSongs(widget.songList, widget.initialSongIndex);
}
@override
void dispose() {
super.dispose();
}
String formatDuration(Duration duration) {
String twoDigits(int n) => n.toString().padLeft(2, "0");
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));
return "$twoDigitMinutes:$twoDigitSeconds";
}
Widget _buildProgressSlider() {
return Obx(() {
final max = playerController.duration.value.inSeconds.toDouble() == 0
? 0.1
: playerController.duration.value.inSeconds.toDouble();
final current =
playerController.position.value.inSeconds.toDouble().clamp(0, max);
return SliderTheme(
data: const SliderThemeData(
trackHeight: 3.0,
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 7.0),
overlayShape: RoundSliderOverlayShape(overlayRadius: 12.0),
),
child: Slider(
min: 0,
max: max,
value: current.toDouble(),
onChanged: (value) {
playerController.seekTo(Duration(seconds: value.toInt()));
},
activeColor: const Color(0xff429482),
inactiveColor: const Color(0xffE3F0ED),
),
);
});
}
Widget _buildPlayButton() {
return Obx(() {
return SizedBox(
width: 52,
height: 52,
child: Center(
child: playerController.isLoading.value
? const CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Color(0xff429482)),
strokeWidth: 3.0,
)
: IconButton(
padding: EdgeInsets.zero,
constraints: const BoxConstraints(
minWidth: 52,
minHeight: 52,
maxWidth: 52,
maxHeight: 52,
),
onPressed: playerController.playOrPause,
icon: !playerController.isPlaying.value
? Image.asset(
"assets/img/music_play.png",
width: 52,
height: 52,
)
: Image.asset(
"assets/img/music_pause.png",
width: 52,
height: 52,
),
),
),
);
});
}
// Widget _buildRotatingAlbumCover() {
// return Obx(() {
// final currentSong =
// widget.songList[playerController.currentSongIndex.value];
// return RotationTransition(
// turns: _rotationController,
// child: Stack(
// alignment: Alignment.center,
// children: [
// Positioned(
// child: ClipRRect(
// child: Image.network(
// currentSong.artistPic,
// width: 225,
// height: 225,
// fit: BoxFit.cover,
// ),
// ),
// ),
// ClipRRect(
// child: Image.asset(
// "assets/img/music_Ellipse.png",
// width: 350,
// height: 350,
// fit: BoxFit.cover,
// ),
// ),
// ],
// ),
// );
// });
// }
Widget _buildRotatingAlbumCover() {
return Obx(() {
final currentSong =
widget.songList[playerController.currentSongIndex.value];
// RotationTransition
return Stack(
alignment: Alignment.center,
children: [
Positioned(
child: ClipRRect(
child: Image.network(
currentSong.artistPic,
width: 225,
height: 225,
fit: BoxFit.cover,
),
),
),
ClipRRect(
child: Image.asset(
"assets/img/music_Ellipse.png",
width: 350,
height: 350,
fit: BoxFit.cover,
),
),
],
);
});
}
void _showPlaylist() {
showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
),
builder: (BuildContext context) {
return Container(
padding: const EdgeInsets.only(top: 15),
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.45,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Center(
child: Text(
"播放列表",
style: TextStyle(fontSize: 20),
),
),
const SizedBox(height: 10),
Expanded(
child: Obx(() => ListView.builder(
itemCount: playerController.musicNames.length,
itemBuilder: (BuildContext context, int index) {
final isCurrentlyPlaying =
playerController.currentSongIndex.value == index;
return ListTile(
tileColor: isCurrentlyPlaying
? const Color(0xffE3F0ED)
: null,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(
playerController.musicNames[index],
style: const TextStyle(fontSize: 18),
),
),
Padding(
padding: const EdgeInsets.only(right: 20),
child: Image.asset(
"assets/img/songs_run.png",
width: 25,
),
),
],
),
onTap: () {
playerController.changeSong(index);
Navigator.pop(context);
},
);
},
)),
),
],
),
);
},
);
}
@override
Widget build(BuildContext context) {
return Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/img/app_bg.png"),
fit: BoxFit.cover,
),
),
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(top: 45, left: 10, right: 10),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
onPressed: () {
Get.back();
},
icon: Image.asset(
"assets/img/back.png",
width: 25,
height: 25,
fit: BoxFit.contain,
),
),
Row(
children: [
IconButton(
onPressed: () {},
icon: Image.asset(
"assets/img/music_add.png",
width: 30,
height: 30,
),
),
Obx(() => IconButton(
onPressed: downloadManager.isDownloading(
playerController.ids[playerController
.currentSongIndex.value]) ||
downloadManager.isCompleted(
playerController.ids[playerController
.currentSongIndex.value])
? null
: () async {
await downloadManager.startDownload(
song: widget.songList[playerController
.currentSongIndex.value],
context: context,
);
},
icon: Obx(() {
if (downloadManager.isDownloading(
playerController.ids[playerController
.currentSongIndex.value])) {
return Stack(
alignment: Alignment.center,
children: [
SizedBox(
width: 32,
height: 32,
child: CircularProgressIndicator(
value: downloadManager.getProgress(
playerController.ids[
playerController
.currentSongIndex.value]),
backgroundColor: Colors.grey[200],
valueColor:
const AlwaysStoppedAnimation<
Color>(Color(0xff429482)),
strokeWidth: 3.0,
),
),
Text(
'${(downloadManager.getProgress(playerController.ids[playerController.currentSongIndex.value]) * 100).toInt()}',
style: const TextStyle(fontSize: 12),
),
],
);
}
return Image.asset(
downloadManager.isCompleted(
playerController.ids[playerController
.currentSongIndex.value])
? "assets/img/music_download_completed.png"
: "assets/img/music_download.png",
width: 30,
height: 30,
);
}),
)),
],
),
],
),
const SizedBox(height: 80),
Center(child: _buildRotatingAlbumCover()),
const SizedBox(height: 60),
Obx(() => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
playerController.musicName.value,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
Text(
playerController.artistName.value,
style: const TextStyle(fontSize: 20),
),
],
),
Row(
children: [
IconButton(
onPressed: () async {
playerController.toggleLike();
final currentIndex =
playerController.currentSongIndex.value;
widget.onSongStatusChanged?.call(
currentIndex,
playerController.collections[currentIndex],
playerController.likes[currentIndex],
);
},
icon: Image.asset(
playerController.likesStatus.value
? "assets/img/music_good.png"
: "assets/img/music_good_un.png",
width: 29,
height: 29,
),
),
IconButton(
onPressed: () async {
playerController.toggleCollection();
final currentIndex =
playerController.currentSongIndex.value;
widget.onSongStatusChanged?.call(
currentIndex,
playerController.collections[currentIndex],
playerController.likes[currentIndex],
);
},
icon: Image.asset(
playerController.collectionsStatus.value
? "assets/img/music_star.png"
: "assets/img/music_star_un.png",
width: 29,
height: 29,
),
),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CommentView(
id: playerController.ids[playerController
.currentSongIndex.value],
song: playerController.musicName.value,
singer: playerController.artistName.value,
cover: widget
.songList[playerController
.currentSongIndex.value]
.artistPic,
),
),
);
},
icon: Image.asset(
"assets/img/music_commend_un.png",
width: 29,
height: 29,
),
),
],
),
],
)),
const SizedBox(height: 80),
Obx(() => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
formatDuration(playerController.position.value),
style: const TextStyle(color: Colors.black),
),
Expanded(child: _buildProgressSlider()),
Text(
formatDuration(playerController.duration.value),
style: const TextStyle(color: Colors.black),
),
],
)),
const SizedBox(height: 30),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
onPressed: () {},
icon: Image.asset(
"assets/img/music_random.png",
width: 35,
height: 35,
),
),
Row(
children: [
IconButton(
onPressed: playerController.playPrevious,
icon: Image.asset(
"assets/img/music_back.png",
width: 42,
height: 42,
),
),
const SizedBox(width: 10),
_buildPlayButton(),
const SizedBox(width: 10),
IconButton(
onPressed: playerController.playNext,
icon: Image.asset(
"assets/img/music_next.png",
width: 42,
height: 42,
),
),
],
),
IconButton(
onPressed: _showPlaylist,
icon: Image.asset(
"assets/img/music_more.png",
width: 35,
height: 35,
),
),
],
),
],
),
),
),
),
);
}
}

@ -2,11 +2,9 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:music_player_miao/common_widget/app_data.dart'; import 'package:music_player_miao/common_widget/app_data.dart';
import '../api/api_music_rank.dart'; import '../api/api_music_rank.dart';
import '../common/download_manager.dart'; import '../common_widget/rank_song_row.dart';
import '../models/getRank_bean.dart'; import '../models/getRank_bean.dart';
import '../view_model/rank_view_model.dart'; import '../view_model/rank_view_model.dart';
import 'music_view.dart';
import '../common_widget/Song_widegt.dart';
class RankView extends StatefulWidget { class RankView extends StatefulWidget {
const RankView({super.key}); const RankView({super.key});
@ -15,78 +13,30 @@ class RankView extends StatefulWidget {
State<RankView> createState() => _RankViewState(); State<RankView> createState() => _RankViewState();
} }
class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin { class _RankViewState extends State<RankView> {
final rankVM = Get.put(RankViewModel()); final rankVM = Get.put(RankViewModel());
List rankNames = []; List rankNames = [];
List rankSingerName = []; List rankSingerName = [];
List rankCoverPath = []; List rankCoverPath = [];
List rankMusicPath = []; List rankMusicPath = [];
List<Song> songs = [];
final downloadManager = Get.put(DownloadManager());
@override
bool get wantKeepAlive => true;
@override
void initState() { void initState() {
super.initState(); super.initState();
_fetchTop50Data(); _fetchSonglistData();
} }
Future<void> _onRefresh() async { Future<void> _fetchSonglistData() async {
await _fetchTop50Data(); RankBean bean2 = await GetRank().getRank(Authorization: AppData().currentToken);
} setState(() {
rankNames = bean2.data!.map((data) => data.name!).toList();
Future<void> _fetchTop50Data() async { rankSingerName = bean2.data!.map((data) => data.singerName!).toList();
try { rankCoverPath = bean2.data!.map((data) => data.coverPath!).toList();
RankBean bean2 = await GetRank().getRank(Authorization: AppData().currentToken); rankMusicPath = bean2.data!.map((data) => data.musicPath!).toList();
if (bean2.code != 200) return; });
rankNames.clear();
rankSingerName.clear();
rankCoverPath.clear();
rankMusicPath.clear();
setState(() {
List<int> ids = bean2.data!.map((data) => data.id!).toList();
rankNames = bean2.data!.map((data) => data.name!).toList();
rankSingerName = bean2.data!.map((data) => data.singerName!).toList();
rankCoverPath = bean2.data!.map((data) => data.coverPath!).toList();
rankMusicPath = bean2.data!.map((data) => data.musicPath!).toList();
for (int i = 0; i < ids.length; i++) {
print(ids[i]);
}
songs.clear();
if (rankNames.isNotEmpty &&
rankNames.length == rankSingerName.length &&
rankNames.length == rankCoverPath.length &&
rankNames.length == rankMusicPath.length) {
for (int i = 0; i < rankNames.length; i++) {
songs.add(Song(
artistPic: rankCoverPath[i],
title: rankNames[i],
artist: rankSingerName[i],
musicurl: rankMusicPath[i],
pic: rankCoverPath[i],
id: ids[i],
likes: null,
collection: null,
));
}
}
});
} catch (e) {
//
print('Error fetching data: $e');
}
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context);
return Container( return Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
image: DecorationImage( image: DecorationImage(
@ -100,19 +50,20 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
body: Column( body: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const SizedBox(height: 40), const SizedBox(
height: 40,
),
// //
const Center( const Center(
child: Column( child: Column(
children: [ children: [
SizedBox(
height: 10,
),
Text( Text(
'喵听排行榜', '喵听排行榜',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.w400), style: TextStyle(fontSize: 22, fontWeight: FontWeight.w400),
), ),
SizedBox(height: 10), SizedBox(
height: 10,
),
Text( Text(
'Top50', 'Top50',
style: TextStyle( style: TextStyle(
@ -120,15 +71,19 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
fontSize: 40, fontSize: 40,
fontWeight: FontWeight.w500), fontWeight: FontWeight.w500),
), ),
// SizedBox(height: 10), SizedBox(
// Text( height: 10,
// '2023/12/12更新 1期', ),
// style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500), Text(
// ), '2023/12/12更新 1期',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
),
], ],
), ),
), ),
const SizedBox(height: 10), const SizedBox(
height: 10,
),
Container( Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
color: Colors.white, color: Colors.white,
@ -140,25 +95,7 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
child: Row( child: Row(
children: [ children: [
IconButton( IconButton(
onPressed: () { onPressed: () {},
//
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MusicView(
songList: songs,
initialSongIndex: 0,
onSongStatusChanged: (index, isCollected, isLiked) {
setState(() {
songs[index].collection = isCollected;
songs[index].likes = isLiked;
downloadManager.updateSongInfo(songs[index].id, isCollected, isLiked);
});
},
),
),
);
},
icon: Image.asset( icon: Image.asset(
"assets/img/button_play.png", "assets/img/button_play.png",
width: 20, width: 20,
@ -169,7 +106,9 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
'播放全部', '播放全部',
style: TextStyle(fontSize: 16), style: TextStyle(fontSize: 16),
), ),
const SizedBox(width: 5), const SizedBox(
width: 5,
),
const Text( const Text(
'50', '50',
style: TextStyle(fontSize: 16), style: TextStyle(fontSize: 16),
@ -178,16 +117,13 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
), ),
), ),
Expanded( Expanded(
child: RefreshIndicator( child: SingleChildScrollView(
onRefresh: _onRefresh, physics: const BouncingScrollPhysics(),
color: const Color(0xff429482), child: Container(
child: SingleChildScrollView( color: Colors.white,
physics: const AlwaysScrollableScrollPhysics(), // child: Column(
child: Container( children: [
color: Colors.white, ListView.builder(
child: Column(
children: [
ListView.builder(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
@ -196,107 +132,96 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
itemBuilder: (context, index) { itemBuilder: (context, index) {
int rankNum = index + 1; int rankNum = index + 1;
return ListTile( return ListTile(
onTap: () { title: Column(
Navigator.push( children: [
context, Row(
MaterialPageRoute( children: [
builder: (context) => MusicView( Row(
songList: songs, mainAxisAlignment:
initialSongIndex: index, MainAxisAlignment.center,
onSongStatusChanged: (index, isCollected, isLiked) { children: [
setState(() { SizedBox(
songs[index].collection = isCollected; width: 25,
songs[index].likes = isLiked; child: RichText(
downloadManager.updateSongInfo(songs[index].id, isCollected, isLiked); text: TextSpan(
}); text: rankNum.toString(),
}, style: TextStyle(
), fontSize: 20,
), fontWeight: FontWeight.w700,
); color: Color(0xffCE0000),
},
title: Column(
children: [
Row(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 25,
child: RichText(
text: TextSpan(
text: rankNum.toString(),
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: Color(0xffCE0000),
),
), ),
), ),
), ),
const SizedBox(width: 10), ),
ClipRRect( const SizedBox(
borderRadius: BorderRadius.circular(10), width: 10,
child: Image.network( ),
rankCoverPath[index], ClipRRect(
width: 60, borderRadius:
height: 60, BorderRadius.circular(10),
fit: BoxFit.cover, child: Image.network(
), rankCoverPath[index],
width: 60,
height: 60,
fit: BoxFit.cover,
), ),
const SizedBox(width: 20), ),
SizedBox( const SizedBox(
width: 170, width: 20,
child: Column( ),
crossAxisAlignment: CrossAxisAlignment.start, SizedBox(
children: [ width: 170,
Text( child: Column(
rankNames[index], crossAxisAlignment:
maxLines: 1, CrossAxisAlignment.start,
style: const TextStyle( children: [
color: Colors.black, Text(
fontSize: 16, rankNames[index],
fontWeight: FontWeight.w400 maxLines: 1,
), style: TextStyle(
), color: Colors.black,
Text( fontSize: 16,
rankSingerName[index], fontWeight:
maxLines: 1, FontWeight.w400),
style: const TextStyle( ),
color: Colors.black, Text(
fontSize: 14 rankSingerName[index],
), maxLines: 1,
) style: TextStyle(
], color: Colors.black,
), fontSize: 14),
)
],
), ),
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(
width: 20,
),
],
),
IconButton(
onPressed: () {
_bottomSheet(context);
},
icon: Image.asset(
"assets/img/More.png",
width: 25,
height: 25,
), ),
], ),
), const SizedBox(
const SizedBox(height: 10) height: 20,
], )
), ],
); ),
}, const SizedBox(
), height: 10,
], )
), ],
));
}),
],
), ),
), ),
), ),
@ -306,16 +231,13 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
), ),
); );
} }
Future _bottomSheet(BuildContext context){
Future _bottomSheet(BuildContext context, int index) {
return showModalBottomSheet( return showModalBottomSheet(
context: context, context: context,
backgroundColor: Colors.white, backgroundColor: Colors.white,
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
borderRadius: BorderRadius.vertical(top: Radius.circular(30)) builder: (context) =>Container(
), height: 210,
builder: (context) => Container(
height: 150,
padding: const EdgeInsets.only(top: 20), padding: const EdgeInsets.only(top: 20),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@ -330,7 +252,7 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
icon: Image.asset("assets/img/list_add.png"), icon: Image.asset("assets/img/list_add.png"),
iconSize: 60, iconSize: 60,
), ),
const Text("加入歌单") Text("加入歌单")
], ],
), ),
Column( Column(
@ -340,7 +262,7 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
icon: Image.asset("assets/img/list_download.png"), icon: Image.asset("assets/img/list_download.png"),
iconSize: 60, iconSize: 60,
), ),
const Text("下载") Text("下载")
], ],
), ),
Column( Column(
@ -350,7 +272,7 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
icon: Image.asset("assets/img/list_collection.png"), icon: Image.asset("assets/img/list_collection.png"),
iconSize: 60, iconSize: 60,
), ),
const Text("收藏") Text("收藏")
], ],
), ),
Column( Column(
@ -360,26 +282,60 @@ class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin
icon: Image.asset("assets/img/list_good.png"), icon: Image.asset("assets/img/list_good.png"),
iconSize: 60, iconSize: 60,
), ),
const Text("点赞") Text("点赞")
], ],
), ),
Column( Column(
children: [ children: [
IconButton( IconButton(
onPressed: (){ onPressed: (){},
Navigator.pop(context);
},
icon: Image.asset("assets/img/list_comment.png"), icon: Image.asset("assets/img/list_comment.png"),
iconSize: 60, iconSize: 60,
), ),
const Text("评论") Text("评论")
], ],
), ),
], ],
), ),
const SizedBox(height: 10,),
ElevatedButton(
onPressed: () {
// Get.to(()=>const MainTabView());
},
child: Text(
"查看详情页",
style: const TextStyle(color:Colors.black,fontSize: 18),
),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffE6F4F1),
padding: const EdgeInsets.symmetric(vertical: 8),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
),
ElevatedButton(
onPressed: () =>Navigator.pop(context),
child: Text(
"取消",
style: const TextStyle(color:Colors.black,fontSize: 18),
),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 8),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
),
], ],
), ),
) )
); );
} }
} }

@ -23,19 +23,17 @@ class SongInfo {
SongInfo({required this.songName, required this.artistName}); SongInfo({required this.songName, required this.artistName});
} }
class _ReleaseViewState extends State<ReleaseView> with AutomaticKeepAliveClientMixin { class _ReleaseViewState extends State<ReleaseView> {
List<File> coverImages = []; List<File> coverImages = [];
List<SongInfo> songInfoList = []; List<SongInfo> songInfoList = [];
late File selectedMp3File; late File selectedMp3File;
@override
bool get wantKeepAlive => true;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context);
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,

@ -1,516 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:music_player_miao/common_widget/Song_widegt.dart';
import '../../common/download_manager.dart';
import '../../view_model/home_view_model.dart';
import '../music_view.dart';
class MyDownloadView extends StatefulWidget {
const MyDownloadView({super.key});
@override
State<MyDownloadView> createState() => _MyDownloadViewState();
}
class _MyDownloadViewState extends State<MyDownloadView> {
final listVM = Get.put(HomeViewModel());
bool _isSelectMode = false;
final List<bool> _mySongListSelections = List.generate(2, (index) => false);
List<bool> _selectedItems = [];
List<Song> _songs = [];
final downloadManager = Get.put(DownloadManager());
@override
void initState() {
super.initState();
_getSongs();
}
void _toggleSelectMode() {
setState(() {
_isSelectMode = !_isSelectMode;
if (!_isSelectMode) {
_selectedItems = List.generate(_songs.length, (index) => false);
}
});
}
void _getSongs() async {
setState(() {
_songs = downloadManager.getLocalSongs();
_selectedItems = List.generate(_songs.length, (index) => false);
});
}
void _selectAll() {
setState(() {
_selectedItems = List.generate(_songs.length, (index) => true);
});
}
void _deleteSongs(List<bool> selectedItems) {
// List<Song> songsToDelete = [];
for (int i = 0; i < selectedItems.length; i++) {
if (selectedItems[i]) {
// songsToDelete.add(_songs[i]);
downloadManager.removeSong(_songs[i].id);
}
}
//
_getSongs();
}
void _deleteSong(int index) {
downloadManager.removeSong(_songs[index].id);
_getSongs();
}
void _showSelectionDialog() {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
title: Row(
children: [
const Text(
"添加到",
),
Text(
'(${_selectedItems.where((item) => item).length} 首)',
style: const TextStyle(color: Color(0xff429482), fontSize: 16),
)
],
),
content: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Column(
children: [
for (int i = 0; i < _mySongListSelections.length; i++)
_buildSongListTile(i),
],
),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
),
child: const Text(
"取消",
style: TextStyle(color: Colors.white),
),
),
TextButton(
onPressed: () {},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
),
child: const Text(
"保存",
style: TextStyle(color: Colors.white),
),
),
],
);
},
);
}
Widget _buildSongListTile(int index) {
return ListTile(
title: Text("我的歌单 $index"),
trailing: Checkbox(
value: _mySongListSelections[index],
onChanged: (value) {
setState(() {
_mySongListSelections[index] = value ?? false;
});
},
shape: const CircleBorder(),
activeColor: const Color(0xff429482),
),
onTap: () {
setState(() {
_mySongListSelections[index] = !_mySongListSelections[index];
});
},
);
}
@override
Widget build(BuildContext context) {
return Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/img/app_bg.png"),
fit: BoxFit.cover,
),
),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
backgroundColor: Colors.transparent,
centerTitle: true,
elevation: 0,
leading: !_isSelectMode
? IconButton(
onPressed: () {
Get.back(result: true);
},
icon: Image.asset(
"assets/img/back.png",
width: 25,
height: 25,
fit: BoxFit.contain,
),
)
: TextButton(
onPressed: _selectAll,
style: TextButton.styleFrom(
foregroundColor: Colors.black,
minimumSize: const Size(50, 40), //
padding:
const EdgeInsets.symmetric(horizontal: 8), //
),
child: const Text(
'全选',
style: TextStyle(fontSize: 18),
),
),
title: _isSelectMode
? Text(
'已选中 ${_selectedItems.where((item) => item).length} 首歌曲',
style: const TextStyle(
color: Colors.black,
),
)
: const Text(
'本地下载',
style: TextStyle(color: Colors.black),
),
actions: [
if (_isSelectMode)
TextButton(
onPressed: () {
setState(() {
_isSelectMode = false;
_selectedItems =
List.generate(_songs.length, (index) => false);
});
},
child: const Text(
"完成",
style: TextStyle(color: Colors.black, fontSize: 18),
))
],
),
body: Container(
padding: const EdgeInsets.only(left: 10),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
IconButton(
onPressed: _songs.isEmpty
? null
: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MusicView(
songList: _songs,
initialSongIndex: 0,
onSongStatusChanged:
(index, isCollected, isLiked) {
setState(() {
//
_songs[index].collection =
isCollected;
_songs[index].likes = isLiked;
downloadManager.updateSongInfo(
_songs[index].id,
isCollected,
isLiked);
});
},
),
),
);
},
icon: Image.asset(
"assets/img/button_play.png",
width: 20,
height: 20,
),
),
const Text(
'播放全部',
style: TextStyle(fontSize: 16),
),
const SizedBox(
width: 5,
),
Text(
'${_songs.length}',
style: TextStyle(fontSize: 16),
),
],
),
IconButton(
onPressed: _songs.isEmpty ? null : _toggleSelectMode,
icon: Image.asset(
"assets/img/list_op.png",
width: 20,
height: 20,
),
),
],
),
Expanded(
child: ListView.builder(
itemCount: _songs.length,
itemBuilder: (BuildContext context, int index) {
final song = _songs[index];
return Container(
padding: const EdgeInsets.symmetric(vertical: 5.0),
child: ListTile(
leading: _isSelectMode
? Checkbox(
value: _selectedItems[index],
onChanged: (value) {
setState(() {
_selectedItems[index] = value!;
});
},
shape: const CircleBorder(),
activeColor: const Color(0xff429482),
)
: null,
title: Text('${song.title} - ${song.artist}'),
trailing: _isSelectMode
? null
: IconButton(
icon: const Icon(Icons.more_vert),
onPressed: () {
_bottomSheet(context, index);
},
),
//
onTap: _isSelectMode
? () {
//
setState(() {
_selectedItems[index] =
!_selectedItems[index];
});
}
: () {
//
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MusicView(
songList: _songs,
initialSongIndex: index,
onSongStatusChanged:
(index, isCollected, isLiked) {
setState(() {
//
_songs[index].collection =
isCollected;
_songs[index].likes = isLiked;
});
},
),
),
);
},
),
);
},
),
),
],
),
),
bottomNavigationBar: _isSelectMode
? BottomAppBar(
height: 140, // BottomAppBar
child: SingleChildScrollView(
// 使 SingleChildScrollView
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
// "添加到"
Expanded(
child: InkWell(
onTap: () {
_showSelectionDialog();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 25,
height: 25,
child: Image.asset("assets/img/add.png"),
),
const SizedBox(width: 4),
const Text("添加到"),
],
),
),
),
// 线
Container(
height: 50,
width: 2,
color: const Color(0xff429482),
),
// "删除"
Expanded(
child: InkWell(
onTap: () {
_deleteSongs(_selectedItems);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 22,
height: 22,
child:
Image.asset("assets/img/delete.png"),
),
const SizedBox(width: 4),
const Text("删除"),
],
),
),
),
],
),
),
ElevatedButton(
onPressed: () {
setState(() {
_isSelectMode = false;
_selectedItems =
List.generate(_songs.length, (index) => false);
});
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 14),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
'取消',
style: TextStyle(color: Colors.black, fontSize: 16),
),
),
],
),
),
)
: null,
),
);
}
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) => Container(
height: 150,
padding: const EdgeInsets.only(top: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
IconButton(
onPressed: () {
_deleteSong(index);
Navigator.pop(context);
},
icon: Image.asset("assets/img/list_remove.png"),
iconSize: 60,
),
const Text("删除")
],
),
Column(
children: [
IconButton(
onPressed: () {},
icon: Image.asset("assets/img/list_collection.png"),
iconSize: 60,
),
const Text("收藏")
],
),
Column(
children: [
IconButton(
onPressed: () {},
icon: Image.asset("assets/img/list_good.png"),
iconSize: 60,
),
const Text("点赞")
],
),
Column(
children: [
IconButton(
onPressed: () {},
icon: Image.asset("assets/img/list_comment.png"),
iconSize: 60,
),
const Text("评论")
],
),
],
),
],
),
));
}
}

@ -1,93 +1,22 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../common_widget/app_data.dart';
import '../../models/getAllSongs_bean.dart';
import '../../view_model/home_view_model.dart'; import '../../view_model/home_view_model.dart';
import '../../api/api_songlist.dart';
import '../../api/api_songlist.dart';
List<T> flatten<T>(Iterable<Iterable<T>> iterable) {
return iterable.expand((inner) => inner).toList();
}
class MyMusicView extends StatefulWidget { class MyMusicView extends StatefulWidget {
final int? songlistIdd; const MyMusicView({super.key});
const MyMusicView({Key? key, this.songlistIdd}) : super(key: key);
@override @override
State<MyMusicView> createState() => _MyMusicViewState(); State<MyMusicView> createState() => _MyMusicViewState();
} }
class _MyMusicViewState extends State<MyMusicView> { class _MyMusicViewState extends State<MyMusicView> {
int songsNum = 0;
List songlistId = [];
List musicDetail = [];
List name = [];
List coverPath = [];
List musicPath = [];
List singerName = [];
List uploadUserName = [];
final listVM = Get.put(HomeViewModel()); final listVM = Get.put(HomeViewModel());
bool _isSelectMode = false; bool _isSelectMode = false;
final List<bool> _mySongListSelections = List.generate(2, (index) => false); final List<bool> _mySongListSelections = List.generate(2, (index) => false);
List<bool> _selectedItems = List.generate(10, (index) => false); List<bool> _selectedItems = List.generate(10, (index) => false);
//
@override
void initState() {
super.initState();
if (widget.songlistIdd != null) {
_fetchMyWorksData();
} else {
// songlistIdd null
print('Songlist ID is null, cannot fetch data.');
}
}
///
Future<void> _fetchMyWorksData() async {
try {
MyMusicListBean bean2 = await SonglistApi().getAllSongs(
id: widget.songlistIdd!,
Authorization: AppData().currentToken,
);
setState(() {
//
name = [];
coverPath = [];
musicPath = [];
singerName = [];
songlistId = [];
// DataBean
bean2.data?.forEach((dataBean) {
// songlistId
songlistId.add(dataBean.songlistId);
// musicDetail
SongDetails songDetails = dataBean.musicDetail!;
//
name.add(songDetails.name);
coverPath.add(songDetails.coverPath);
musicPath.add(songDetails.musicPath);
singerName.add(songDetails.singerName);
});
songsNum = name.length; //
print('赋值开始');
print('赋值结束');
});
} catch (error) {
print('Error fetching myworks data: $error');
}
}
//
void _toggleSelectMode() { void _toggleSelectMode() {
setState(() { setState(() {
_isSelectMode = !_isSelectMode; _isSelectMode = !_isSelectMode;
@ -109,20 +38,21 @@ class _MyMusicViewState extends State<MyMusicView> {
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10), borderRadius:BorderRadius.circular(10),
), ),
title: Row( title: Row(
children: [ children: [
const Text( const Text("添加到",),
"添加到",
),
Text( Text(
'(${_selectedItems.where((item) => item).length} 首)', '(${_selectedItems.where((item) => item).length} 首)',
style: const TextStyle(color: Color(0xff429482), fontSize: 16), style: const TextStyle(
color: Color(0xff429482),
fontSize: 16
),
) )
], ],
), ),
content: SingleChildScrollView( content:SingleChildScrollView(
physics: const BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
child: Column( child: Column(
children: [ children: [
@ -149,7 +79,8 @@ class _MyMusicViewState extends State<MyMusicView> {
), ),
), ),
TextButton( TextButton(
onPressed: () {}, onPressed: () {
},
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482), backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50), minimumSize: const Size(130, 50),
@ -189,6 +120,7 @@ class _MyMusicViewState extends State<MyMusicView> {
); );
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
@ -205,54 +137,52 @@ class _MyMusicViewState extends State<MyMusicView> {
centerTitle: true, centerTitle: true,
elevation: 0, elevation: 0,
leading: !_isSelectMode leading: !_isSelectMode
? IconButton( ?IconButton(
onPressed: () { onPressed: () {
Get.back(result: true); Get.back();
}, },
icon: Image.asset( icon: Image.asset(
"assets/img/back.png", "assets/img/back.png",
width: 25, width: 25,
height: 25, height: 25,
fit: BoxFit.contain, fit: BoxFit.contain,
), ),
) )
: TextButton( : TextButton(
onPressed: _selectAll, onPressed: _selectAll,
style: TextButton.styleFrom( style: TextButton.styleFrom(
foregroundColor: Colors.black, foregroundColor: Colors.black,
minimumSize: const Size(50, 40), // ),
padding: child: const Text('全选',style: TextStyle(fontSize: 18),),
const EdgeInsets.symmetric(horizontal: 8), // ),
),
child: const Text(
'全选',
style: TextStyle(fontSize: 18),
),
),
title: _isSelectMode title: _isSelectMode
? Text( ? Text(
'已选中 ${_selectedItems.where((item) => item).length} 首歌曲', '已选中 ${_selectedItems.where((item) => item).length} 首歌曲',
style: const TextStyle( style: const TextStyle(
color: Colors.black, color: Colors.black,
),
)
: const Text(
'我的歌单',
style: TextStyle(color: Colors.black),
), ),
)
: const Text(
'我的歌单',
style: TextStyle(color: Colors.black),
),
actions: [ actions: [
if (_isSelectMode) if (_isSelectMode)
TextButton( TextButton(
onPressed: () { onPressed: (){
setState(() { setState(() {
_isSelectMode = false; _isSelectMode = false;
_selectedItems = List.generate(10, (index) => false); _selectedItems = List.generate(10, (index) => false);
}); });
}, },
child: const Text( child: const Text(
"完成", "完成",
style: TextStyle(color: Colors.black, fontSize: 18), style: TextStyle(
)) color: Colors.black,
fontSize: 18
),
)
)
], ],
), ),
body: Container( body: Container(
@ -269,7 +199,7 @@ class _MyMusicViewState extends State<MyMusicView> {
Row( Row(
children: [ children: [
IconButton( IconButton(
onPressed: () {}, onPressed: (){},
icon: Image.asset( icon: Image.asset(
"assets/img/button_play.png", "assets/img/button_play.png",
width: 20, width: 20,
@ -278,14 +208,16 @@ class _MyMusicViewState extends State<MyMusicView> {
), ),
const Text( const Text(
'播放全部', '播放全部',
style: TextStyle(fontSize: 16), style: TextStyle(
), fontSize: 16
const SizedBox( ),
width: 5,
), ),
const SizedBox(width: 5,),
const Text( const Text(
'50', '50',
style: TextStyle(fontSize: 16), style: TextStyle(
fontSize: 16
),
), ),
], ],
), ),
@ -300,224 +232,215 @@ class _MyMusicViewState extends State<MyMusicView> {
], ],
), ),
Expanded( Expanded(
child: songsNum == 0 child: ListView.builder(
? Center(child: Text('该歌单为空')) // itemCount: 10,
: ListView.builder( itemBuilder: (BuildContext context, int index) {
itemCount: songsNum, return Container(
itemBuilder: (BuildContext context, int index) { padding: const EdgeInsets.symmetric(vertical: 5.0),
return Container( child: ListTile(
padding: const EdgeInsets.symmetric(vertical: 5.0), leading: _isSelectMode
child: ListTile( ? Checkbox(
leading: _isSelectMode value: _selectedItems[index],
? Checkbox( onChanged: (value) {
value: _selectedItems[index], setState(() {
onChanged: (value) { _selectedItems[index] = value!;
setState(() { });
_selectedItems[index] = value!; },
}); shape: const CircleBorder(),
}, activeColor: const Color(0xff429482),
shape: const CircleBorder(), )
activeColor: const Color(0xff429482), : null,
) title: Text('歌曲名 $index - 歌手'),
: CircleAvatar( trailing: _isSelectMode
backgroundImage: ? null
NetworkImage(coverPath[index]), : IconButton(
// icon: const Icon(Icons.more_vert),
radius: 25, onPressed: () {
), _bottomSheet(context);
title: },
Text('${name[index]} - ${singerName[index]}'), ),
//
trailing: _isSelectMode
? null
: IconButton(
icon: const Icon(Icons.more_vert),
onPressed: () {
_bottomSheet(context);
},
),
),
);
},
), ),
);
},
),
), ),
], ],
), ),
), ),
bottomNavigationBar: _isSelectMode bottomNavigationBar: _isSelectMode
? BottomAppBar( ? BottomAppBar(
child: SizedBox( child: SizedBox(
height: 127.0, height: 127.0,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
Row( Row(
children: [ children: [
IconButton( IconButton(
onPressed: () { onPressed: (){
_showSelectionDialog(); _showSelectionDialog();
}, },
icon: Image.asset("assets/img/list_add.png"), icon: Image.asset("assets/img/list_add.png"),
iconSize: 60, iconSize: 60,
),
const Text("添加到"),
],
),
Container(
height: 50,
width: 2,
color: const Color(0xff429482),
),
Row(
children: [
IconButton(
onPressed: () {},
icon:
Image.asset("assets/img/list_download.png"),
iconSize: 60,
),
const Text("下载"),
],
),
],
),
ElevatedButton(
onPressed: () {
setState(() {
_isSelectMode = false;
_selectedItems =
List.generate(10, (index) => false);
});
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 14),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
), ),
child: const Text( const Text("添加到"),
'取消', ],
style: TextStyle(color: Colors.black, fontSize: 16), ),
Container(
height: 50,
width: 2,
color: const Color(0xff429482),
),
Row(
children: [
IconButton(
onPressed: (){},
icon: Image.asset("assets/img/list_download.png"),
iconSize: 60,
), ),
), const Text("下载"),
], ],
),
],
),
ElevatedButton(
onPressed: () {
setState(() {
_isSelectMode = false;
_selectedItems = List.generate(10, (index) => false);
});
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 14),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
), ),
child: const Text('取消',
style: TextStyle(
color: Colors.black,
fontSize: 16
),),
), ),
) ],
),
),
)
: null, : null,
), ),
); );
} }
Future _bottomSheet(BuildContext context){
Future _bottomSheet(BuildContext context) {
return showModalBottomSheet( return showModalBottomSheet(
context: context, context: context,
backgroundColor: Colors.white, backgroundColor: Colors.white,
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
borderRadius: BorderRadius.vertical(top: Radius.circular(30))), builder: (context) =>Container(
builder: (context) => Container( height: 210,
height: 210, padding: const EdgeInsets.only(top: 20),
padding: const EdgeInsets.only(top: 20), child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.stretch,
crossAxisAlignment: CrossAxisAlignment.stretch, children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Row( Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Column( IconButton(
children: [ onPressed: (){},
IconButton( icon: Image.asset("assets/img/list_remove.png"),
onPressed: () {}, iconSize: 60,
icon: Image.asset("assets/img/list_remove.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: () {},
icon: Image.asset("assets/img/list_collection.png"),
iconSize: 60,
),
const Text("收藏")
],
),
Column(
children: [
IconButton(
onPressed: () {},
icon: Image.asset("assets/img/list_good.png"),
iconSize: 60,
),
const Text("点赞")
],
), ),
Column( const Text("从歌单移除")
children: [ ],
IconButton( ),
onPressed: () {}, Column(
icon: Image.asset("assets/img/list_comment.png"), children: [
iconSize: 60, IconButton(
), onPressed: (){},
const Text("评论") icon: Image.asset("assets/img/list_download.png"),
], iconSize: 60,
), ),
const Text("下载")
], ],
), ),
const SizedBox( Column(
height: 10, children: [
IconButton(
onPressed: (){},
icon: Image.asset("assets/img/list_collection.png"),
iconSize: 60,
),
const Text("收藏")
],
), ),
ElevatedButton( Column(
onPressed: () { children: [
// Get.to(()=>const MusicView()); IconButton(
}, onPressed: (){},
style: ElevatedButton.styleFrom( icon: Image.asset("assets/img/list_good.png"),
backgroundColor: const Color(0xffE6F4F1), iconSize: 60,
padding: const EdgeInsets.symmetric(vertical: 8),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
), ),
), const Text("点赞")
child: const Text( ],
"查看详情页",
style: TextStyle(color: Colors.black, fontSize: 18),
),
), ),
ElevatedButton( Column(
onPressed: () => Navigator.pop(context), children: [
style: ElevatedButton.styleFrom( IconButton(
backgroundColor: const Color(0xff429482), onPressed: (){},
padding: const EdgeInsets.symmetric(vertical: 8), icon: Image.asset("assets/img/list_comment.png"),
tapTargetSize: MaterialTapTargetSize.shrinkWrap, iconSize: 60,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
), ),
), const Text("评论")
child: const Text( ],
"取消",
style: TextStyle(color: Colors.black, fontSize: 18),
),
), ),
], ],
), ),
)); const SizedBox(height: 10,),
ElevatedButton(
onPressed: () {
// Get.to(()=>const MusicView());
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffE6F4F1),
padding: const EdgeInsets.symmetric(vertical: 8),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
"查看详情页",
style: TextStyle(color:Colors.black,fontSize: 18),
),
),
ElevatedButton(
onPressed: () =>Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 8),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
"取消",
style: TextStyle(color:Colors.black,fontSize: 18),
),
),
],
),
)
);
} }
} }

@ -1,9 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:music_player_miao/common_widget/Song_widegt.dart';
import '../../api/api_songlist.dart';
import '../../common_widget/app_data.dart';
import '../../models/getMyWorks.dart';
import '../../view_model/home_view_model.dart'; import '../../view_model/home_view_model.dart';
class MyWorkView extends StatefulWidget { class MyWorkView extends StatefulWidget {
@ -14,12 +11,6 @@ class MyWorkView extends StatefulWidget {
} }
class _MyWorkViewState extends State<MyWorkView> { class _MyWorkViewState extends State<MyWorkView> {
int MyWorkCount = 0;
List MyWorkNames = [];
List Songid = [];
List coverPath = [];
List musicPath = [];
List singerName = [];
final listVM = Get.put(HomeViewModel()); final listVM = Get.put(HomeViewModel());
bool _isSelectMode = false; bool _isSelectMode = false;
@ -27,37 +18,6 @@ class _MyWorkViewState extends State<MyWorkView> {
List<bool> _mySongListSelections = List.generate(2, (index) => false); List<bool> _mySongListSelections = List.generate(2, (index) => false);
List<bool> _selectedItems = List.generate(10, (index) => false); List<bool> _selectedItems = List.generate(10, (index) => false);
//
@override
void initState() {
super.initState();
print('初始化正常');
_fetchMyWorksData();
}
///
Future<void> _fetchMyWorksData() async {
try {
MyWorks bean2 = await SonglistApi().getMyworks(
Authorization: AppData().currentToken,
);
setState(() {
MyWorkNames = bean2.data!.map((data) => data.name!).toList();
Songid = bean2.data!.map((data) => data.id!).toList();
coverPath = bean2.data!.map((data) => data.coverPath!).toList();
musicPath = bean2.data!.map((data) => data.musicPath!).toList();
singerName = bean2.data!.map((data) => data.singerName!).toList();
print('赋值开始');
MyWorkCount = MyWorkNames.length;
print('赋值结束');
});
} catch (error) {
print('Error fetching myworks data: $error');
}
}
//
void _toggleSelectMode() { void _toggleSelectMode() {
setState(() { setState(() {
_isSelectMode = !_isSelectMode; _isSelectMode = !_isSelectMode;
@ -288,10 +248,8 @@ class _MyWorkViewState extends State<MyWorkView> {
], ],
), ),
Expanded( Expanded(
child: MyWorkCount == 0 child: ListView.builder(
? Center(child: Text('你还没有作品')) // itemCount: 10,
: ListView.builder(
itemCount: MyWorkCount,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Container( return Container(
padding: const EdgeInsets.symmetric(vertical: 5.0), padding: const EdgeInsets.symmetric(vertical: 5.0),
@ -307,11 +265,8 @@ class _MyWorkViewState extends State<MyWorkView> {
shape: const CircleBorder(), shape: const CircleBorder(),
activeColor: const Color(0xff429482), activeColor: const Color(0xff429482),
) )
: CircleAvatar( : null,
backgroundImage: NetworkImage(coverPath[index]), // title: Text('歌曲名 $index - 歌手'),
radius: 25,
),
title: Text('${MyWorkNames[index]} - ${singerName[index]}'), //
trailing: _isSelectMode trailing: _isSelectMode
? null ? null
: IconButton( : IconButton(

@ -1,11 +1,17 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart'; import 'package:music_player_miao/widget/text_field.dart';
import '../../api/api_client.dart'; import '../../api/api_client.dart';
import '../../api/api_client_info.dart'; import '../../api/api_client_info.dart';
import '../../common_widget/app_data.dart'; import '../../common_widget/app_data.dart';
import '../../models/getInfo_bean.dart';
import '../../models/universal_bean.dart';
import '../../view_model/home_view_model.dart'; import '../../view_model/home_view_model.dart';
import 'package:image_picker/image_picker.dart';
class UserInfo extends StatefulWidget { class UserInfo extends StatefulWidget {
const UserInfo({super.key}); const UserInfo({super.key});
@ -17,7 +23,7 @@ class UserInfo extends StatefulWidget {
class _UserInfoState extends State<UserInfo> { class _UserInfoState extends State<UserInfo> {
final listVM = Get.put(HomeViewModel()); final listVM = Get.put(HomeViewModel());
final TextEditingController _controller = TextEditingController(); final TextEditingController _controller = TextEditingController();
File? _selectedImage; late File _selectedImage;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -36,7 +42,7 @@ class _UserInfoState extends State<UserInfo> {
elevation: 0, elevation: 0,
leading: IconButton( leading: IconButton(
onPressed: () { onPressed: () {
Get.back(result: true); Get.back();
}, },
icon: Image.asset( icon: Image.asset(
"assets/img/back.png", "assets/img/back.png",
@ -54,153 +60,146 @@ class _UserInfoState extends State<UserInfo> {
body: SingleChildScrollView( body: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
_buildAvatarRow(), Container(
_buildNicknameRow(), height: 80,
], color: Colors.white.withOpacity(0.6),
), padding: const EdgeInsets.only(left: 48, right: 25),
), child: InkWell(
), onTap: () {
); _bottomSheet(context);
} },
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
Widget _buildAvatarRow() { children: [
return Container( const Text(
height: 80, "头像",
color: Colors.white.withOpacity(0.6), style: TextStyle(fontSize: 20),
padding: const EdgeInsets.only(left: 48, right: 25), ),
child: InkWell( Row(
onTap: () { children: [
_bottomSheet(context); Image.network(
}, AppData().currentAvatar,
child: Row( width: 64,
mainAxisAlignment: MainAxisAlignment.spaceBetween, height: 64,
children: [ ),
const Text( const SizedBox(
"头像", width: 20,
style: TextStyle(fontSize: 20), ),
), Image.asset(
Row( "assets/img/user_next.png",
children: [ width: 25,
_buildAvatarImage(), height: 25,
const SizedBox(width: 20), )
Image.asset( ],
"assets/img/user_next.png", )
width: 25, ],
height: 25, ),
),
],
),
],
),
),
);
}
//
Widget _buildNicknameRow() {
return Container(
height: 80,
color: Colors.white.withOpacity(0.6),
padding: const EdgeInsets.only(left: 48, right: 25),
child: InkWell(
onTap: () {
_showNicknameDialog();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"昵称",
style: TextStyle(fontSize: 20),
),
Row(
children: [
Text(
AppData().currentUsername,
style: const TextStyle(fontSize: 20),
), ),
const SizedBox(width: 15), ),
Image.asset( Container(
"assets/img/user_next.png", height: 80,
width: 25, color: Colors.white.withOpacity(0.6),
height: 25, padding: const EdgeInsets.only(left: 48, right: 25),
child: InkWell(
onTap: () {
_showNicknameDialog();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"昵称",
style: TextStyle(fontSize: 20),
),
Row(
children: [
Text(
AppData().currentUsername,
style: const TextStyle(fontSize: 20),
),
const SizedBox(
width: 15,
),
Image.asset(
"assets/img/user_next.png",
width: 25,
height: 25,
)
],
)
],
),
), ),
], )
), ],
], ),
), ),
), ),
); );
} }
// Widget URL
Widget _buildAvatarImage() {
final avatarPath = AppData().currentAvatar;
if (avatarPath.startsWith('http')) {
return Image.network(
avatarPath,
width: 64,
height: 64,
);
} else {
return Image.file(
File(avatarPath),
width: 64,
height: 64,
);
}
}
Future _bottomSheet(BuildContext context) async { Future _bottomSheet(BuildContext context) async {
final picker = ImagePicker(); final picker = ImagePicker();
await showModalBottomSheet( await showModalBottomSheet(
context: context, context: context,
backgroundColor: Colors.white, backgroundColor: Colors.white,
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30))), borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
builder: (context) => Container( builder: (context) => Container(
height: 80, height: 132,
padding: const EdgeInsets.only(top: 20), padding: const EdgeInsets.only(top: 20),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () async {
Navigator.pop(context); Navigator.pop(context);
final pickedFile = final pickedFile =
await picker.pickImage(source: ImageSource.gallery); await picker.pickImage(source: ImageSource.gallery);
if (pickedFile != null) { if (pickedFile != null) {
_selectedImage = File(pickedFile.path); _selectedImage=File('assets/images/bg.png');
setState(() {}); // UI setState(() {
_selectedImage = File(pickedFile.path);
// print(_selectedImage);
await ChangeApiClient().changeHeader( });
Authorization: AppData().currentToken, UniversalBean bean = await ChangeApiClient().changeHeader(
avatar: _selectedImage!); Authorization: AppData().currentToken,
avatar: _selectedImage);
// GetInfoBean bean1 = await GetInfoApiClient().getInfo(
_updatetouxiang(_selectedImage!.path); Authorization: AppData().currentToken);
// AppData appData = AppData();
await GetInfoApiClient().getInfo( appData.box.write('currentAvatar', AppData().currentAvatar);
Authorization: AppData().currentToken); }
} },
}, style: ElevatedButton.styleFrom(
style: ElevatedButton.styleFrom( backgroundColor: Colors.transparent,
backgroundColor: Colors.transparent, elevation: 0,
elevation: 0, padding: const EdgeInsets.symmetric(vertical: 12),
padding: const EdgeInsets.symmetric(vertical: 12), tapTargetSize: MaterialTapTargetSize.shrinkWrap,
tapTargetSize: MaterialTapTargetSize.shrinkWrap, ),
), child: const Text(
child: const Text( "从相册上传头像",
"从相册上传头像", style: TextStyle(color: Colors.black, fontSize: 18),
style: TextStyle(color: Colors.black, fontSize: 18), ),
),
ElevatedButton(
onPressed: () => Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 18),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
"取消",
style: TextStyle(color: Colors.black, fontSize: 18),
),
),
],
), ),
), ));
],
),
),
);
} }
void _showNicknameDialog() { void _showNicknameDialog() {
@ -210,47 +209,49 @@ class _UserInfoState extends State<UserInfo> {
return AlertDialog( return AlertDialog(
title: const Center( title: const Center(
child: Text( child: Text(
"修改昵称", "修改昵称",
style: TextStyle(fontSize: 20), style: TextStyle(fontSize: 20),
)), )),
content: TextField( content: TextFieldColor(
controller: _controller, controller: _controller,
decoration: const InputDecoration(hintText: '请输入新昵称'), hintText: '请输入新昵称',
), ),
actions: <Widget>[ actions: <Widget>[
TextButton( TextButton(
onPressed: () async { onPressed: () {
_updateNickname();
await ChangeApiClient().changeName(
Authorization: AppData().currentToken,
userName: AppData().currentUsername);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482), backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50), minimumSize: const Size(130, 50),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0), borderRadius:
BorderRadius.circular(5.0), // Adjust the radius as needed
), ),
), ),
child: const Text( child: const Text(
"保存", "取消",
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
), ),
TextButton( TextButton(
onPressed: () { onPressed: () async {
_updateNickname();
UniversalBean bean = await ChangeApiClient().changeName(
Authorization: AppData().currentToken,
userName: AppData().currentUsername);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482), backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50), minimumSize: const Size(130, 50),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0), borderRadius:
BorderRadius.circular(5.0), // Adjust the radius as needed
), ),
), ),
child: const Text( child: const Text(
"取消", "保存",
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
), ),
@ -266,14 +267,4 @@ class _UserInfoState extends State<UserInfo> {
appData.box.write('currentUsername', _controller.text); appData.box.write('currentUsername', _controller.text);
}); });
} }
void _updatetouxiang(String path) {
setState(() {
AppData appData = AppData();
appData.box.write('currentAvatar', path); //
});
}
} }

@ -1,5 +1,3 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:music_player_miao/api/api_songlist.dart'; import 'package:music_player_miao/api/api_songlist.dart';
@ -7,13 +5,11 @@ import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/songlist_bean.dart'; import 'package:music_player_miao/models/songlist_bean.dart';
import 'package:music_player_miao/models/universal_bean.dart'; import 'package:music_player_miao/models/universal_bean.dart';
import 'package:music_player_miao/view/begin/begin_view.dart'; import 'package:music_player_miao/view/begin/begin_view.dart';
import 'package:music_player_miao/view/user/my_download_view.dart';
import 'package:music_player_miao/view/user/my_music_view.dart'; import 'package:music_player_miao/view/user/my_music_view.dart';
import 'package:music_player_miao/view/user/user_info.dart'; import 'package:music_player_miao/view/user/user_info.dart';
import 'package:music_player_miao/widget/text_field.dart'; import 'package:music_player_miao/widget/text_field.dart';
import '../../../view_model/home_view_model.dart'; import '../../../view_model/home_view_model.dart';
import '../../api/api_client.dart'; import '../../api/api_client.dart';
import '../../common/download_manager.dart';
import '../../models/search_bean.dart'; import '../../models/search_bean.dart';
import 'my_work_view.dart'; import 'my_work_view.dart';
@ -24,28 +20,20 @@ class UserView extends StatefulWidget {
State<UserView> createState() => _UserViewState(); State<UserView> createState() => _UserViewState();
} }
class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin { class _UserViewState extends State<UserView> {
final homeVM = Get.put(HomeViewModel()); final homeVM = Get.put(HomeViewModel());
final TextEditingController _controller = TextEditingController(); final TextEditingController _controller = TextEditingController();
int playlistCount = 0; int playlistCount = 2;
List playlistNames = []; List playlistNames = [];
List<int> playlistid = []; List playlistid = [];
int downloadCount = 0;
String avatar = AppData().currentAvatar;
String username = AppData().currentUsername;
final downloadManager = Get.put(DownloadManager());
@override
bool get wantKeepAlive => true;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_fetchSonglistData(); _fetchSonglistData();
downloadCount = downloadManager.completedNumber();
} }
///getSonglist
Future<void> _fetchSonglistData() async { Future<void> _fetchSonglistData() async {
try { try {
SearchBean bean2 = await SonglistApi().getSonglist( SearchBean bean2 = await SonglistApi().getSonglist(
@ -54,7 +42,7 @@ class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin
setState(() { setState(() {
playlistNames = bean2.data!.map((data) => data.name!).toList(); playlistNames = bean2.data!.map((data) => data.name!).toList();
playlistid = bean2.data!.map((data) => data.id!).toList(); // idint playlistid = bean2.data!.map((data) => data.id!).toList();
playlistCount = playlistNames.length; playlistCount = playlistNames.length;
}); });
} catch (error) { } catch (error) {
@ -64,7 +52,6 @@ class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context);
return Container( return Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
image: DecorationImage( image: DecorationImage(
@ -90,20 +77,16 @@ class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin
children: [ children: [
Row( Row(
children: [ children: [
ClipRRect( Image.network(
borderRadius: BorderRadius.circular(10), AppData().currentAvatar,
child: Image.network( width: 64,
avatar, height: 64,
width: 60,
height: 60,
fit: BoxFit.cover,
),
), ),
const SizedBox( const SizedBox(
width: 25, width: 25,
), ),
Text( Text(
username, AppData().currentUsername,
style: const TextStyle(fontSize: 20), style: const TextStyle(fontSize: 20),
) )
], ],
@ -124,19 +107,12 @@ class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin
Container( Container(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
left: 15, right: 15, top: 20, bottom: 20), left: 15, right: 15, top: 20, bottom: 20),
//
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
InkWell( InkWell(
onTap: () { onTap: () {
Navigator.push( Get.to(const MyMusicView());
context,
MaterialPageRoute(
builder: (context) => const MyMusicView(),
),
);
}, },
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -164,41 +140,26 @@ class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin
], ],
), ),
), ),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
//
InkWell( InkWell(
onTap: () async { onTap: () {
final result = await Navigator.push( Get.to(const MyMusicView());
context,
MaterialPageRoute(
builder: (context) => MyDownloadView(),
),
);
if (result == true) {
setState(() {
downloadCount = downloadManager.completedNumber();
});
}
}, },
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Image.asset("assets/img/artist_pic.png"), Image.asset("assets/img/artist_pic.png"),
Column( const Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Text( Text(
"本地下载", "本地下载",
style: TextStyle(fontSize: 20), style: TextStyle(fontSize: 20),
), ),
Text( Text(
'${downloadCount}', "19首",
style: TextStyle(fontSize: 16), style: TextStyle(fontSize: 16),
), ),
], ],
@ -214,107 +175,168 @@ class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin
), ),
], ],
)), )),
/// ///
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'歌单 $playlistCount',
style: const TextStyle(
fontSize: 20, fontWeight: FontWeight.w500),
),
Row(
children: [
IconButton(
onPressed: () {
_showAddPlaylistDialog();
},
icon: Image.asset(
"assets/img/user_add.png",
width: 31,
color: const Color(0xff404040),
)),
IconButton(
onPressed: () {},
icon: Image.asset("assets/img/user_export.png",
width: 31))
],
)
],
),
Container( Container(
child: Column( padding: const EdgeInsets.only(
crossAxisAlignment: CrossAxisAlignment.start, left: 15, right: 15, top: 10, bottom: 5),
children: [ child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
Row( children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, InkWell(
children: [ onTap: () {},
Text( child: Row(
'歌单 $playlistCount', mainAxisAlignment: MainAxisAlignment.spaceBetween,
style: const TextStyle( children: [
fontSize: 20, Image.asset("assets/img/artist_pic.png"),
fontWeight: FontWeight.w500 const Column(
), crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"我的收藏",
style: TextStyle(fontSize: 20),
),
Text(
"19首",
style: TextStyle(fontSize: 16),
),
],
),
const SizedBox(
width: 80,
),
Image.asset(
"assets/img/user_next.png",
)
],
), ),
Row( ),
const SizedBox(
height: 10,
),
InkWell(
onTap: () {},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
IconButton( Image.asset("assets/img/artist_pic.png"),
onPressed: () { const Column(
_showAddPlaylistDialog(); crossAxisAlignment: CrossAxisAlignment.start,
}, children: [
icon: Image.asset( Text(
"assets/img/user_add.png", "本地下载",
width: 31, style: TextStyle(fontSize: 20),
color: const Color(0xff404040), ),
) Text(
"19首",
style: TextStyle(fontSize: 16),
),
],
),
const SizedBox(
width: 80,
), ),
IconButton( Image.asset(
onPressed: () {}, "assets/img/user_next.png",
icon: Image.asset(
"assets/img/user_export.png",
width: 31
)
) )
], ],
) ),
], ),
), ],
)),
const SizedBox( InkWell(
height: 10, onTap: () {
), Get.to(const MyMusicView());
},
// child: Column(
Padding( children: List.generate(playlistNames.length, (index) {
padding: const EdgeInsets.symmetric(horizontal: 15), return Dismissible(
child: Column( key: Key(playlistNames[index]),
children: List.generate( direction: DismissDirection.endToStart,
playlistNames.length, background: Container(
(index) => Column( color: Colors.red,
children: [ alignment: Alignment.centerRight,
InkWell( padding: const EdgeInsets.only(right: 20.0),
onTap: () { child: const Icon(
print('点击成功'); Icons.delete,
Navigator.push( color: Colors.white,
context, ),
MaterialPageRoute( ),
builder: (context) => MyMusicView( confirmDismiss: (direction) async {
songlistIdd: playlistid[index] return await _showDeleteConfirmationDialog(
), context, index);
), },
); onDismissed: (direction) {
}, setState(() {
child: Row( playlistNames.removeAt(index);
playlistid.removeAt(index);
playlistCount--;
});
},
child: ListTile(
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Image.asset("assets/img/artist_pic.png"),
const SizedBox(
width: 30,
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [ children: [
Image.asset("assets/img/artist_pic.png"), Text(
const SizedBox(width: 25), playlistNames[index],
Expanded( style: const TextStyle(fontSize: 18),
child: Column( ),
crossAxisAlignment: CrossAxisAlignment.start, const Text(
children: [ '0首',
Text( style: TextStyle(fontSize: 18),
playlistNames[index],
style: const TextStyle(fontSize: 20),
),
Text(
'$playlistCount',
style: const TextStyle(fontSize: 16),
),
],
),
), ),
Image.asset("assets/img/user_next.png"),
], ],
), ),
), ],
if (index < playlistNames.length - 1) ),
const SizedBox(height: 10), Image.asset(
], "assets/img/user_next.png",
), )
],
), ),
), ),
), );
], }),
), ),
), ),
const SizedBox( const SizedBox(
height: 30, height: 20,
), ),
const Text( const Text(
@ -329,12 +351,7 @@ class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin
children: [ children: [
InkWell( InkWell(
onTap: () { onTap: () {
Navigator.push( Get.to(const MyWorkView());
context,
MaterialPageRoute(
builder: (context) => const MyWorkView(),
),
);
}, },
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -375,71 +392,71 @@ class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin
///--退 ///--退
Future _bottomSheet(BuildContext context) { Future _bottomSheet(BuildContext context) {
return showModalBottomSheet( return showModalBottomSheet(
context: context, context: context,
backgroundColor: Colors.white, backgroundColor: Colors.white,
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30)), borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
), builder: (context) => Container(
isScrollControlled: true, // height: 200,
builder: (context) => Padding( padding: const EdgeInsets.only(top: 20),
padding: const EdgeInsets.only(top: 20), child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min, // 使Column children: [
crossAxisAlignment: CrossAxisAlignment.stretch, Row(
children: [ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
Row( children: [
mainAxisAlignment: MainAxisAlignment.spaceEvenly, Column(
children: [ children: [
Column( IconButton(
children: [ onPressed: () {
IconButton( Get.to(const UserInfo());
onPressed: () async { },
Navigator.pop(context); icon: Image.asset("assets/img/user_infor.png"),
bool result = await Navigator.push( iconSize: 60,
context,
MaterialPageRoute(
builder: (context) => const UserInfo(),
), ),
); const Text("账户信息")
if (result) { ],
setState(() { ),
avatar = AppData().currentAvatar; Column(
username = AppData().currentUsername; children: [
}); IconButton(
} onPressed: () async {
}, UniversalBean bean = await LogoutApiClient()
icon: Image.asset("assets/img/user_infor.png"), .logout(
iconSize: 60, Authorization: AppData().currentToken);
if (bean.code == 200) {
Get.to(const BeginView());
}
},
icon: Image.asset("assets/img/user_out.png"),
iconSize: 60,
),
const Text("退出登录")
],
),
],
),
const SizedBox(
height: 30,
),
ElevatedButton(
onPressed: () => Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 14),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
), ),
const Text("账户信息") child: const Text(
], "取消",
), style: TextStyle(color: Colors.black, fontSize: 18),
Column(
children: [
IconButton(
onPressed: () async {
Navigator.pop(context);
Get.to(const BeginView());
UniversalBean bean = await LogoutApiClient().logout(
Authorization: AppData().currentToken,
);
AppData().currentToken = '';
AppData().currentUsername = '';
AppData().currentAvatar = '';
},
icon: Image.asset("assets/img/user_out.png"),
iconSize: 60,
), ),
const Text("退出登录") ),
], ],
), ),
], ));
),
const SizedBox(height: 30),
],
),
),
);
} }
///-- ///--
@ -461,19 +478,8 @@ class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin
content: TextFieldColor(controller: _controller, hintText: '请输入歌单名称'), content: TextFieldColor(controller: _controller, hintText: '请输入歌单名称'),
actions: <Widget>[ actions: <Widget>[
TextButton( TextButton(
onPressed: () async { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
String enteredSongName = _controller.text;
SonglistBean bean = await SonglistApi().addSonglist(
songlistName: enteredSongName,
Authorization: AppData().currentToken);
if (bean.code == 200) {
print('添加成功');
setState(() {
playlistCount++;
playlistNames.add(enteredSongName);
});
}
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482), backgroundColor: const Color(0xff429482),
@ -483,13 +489,22 @@ class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin
), ),
), ),
child: const Text( child: const Text(
"确认", "取消",
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
), ),
TextButton( TextButton(
onPressed: () { onPressed: () async {
Navigator.of(context).pop(); Navigator.of(context).pop();
String enteredSongName = _controller.text;
playlistCount++;
// Add the new playlist
setState(() {
playlistNames.add(enteredSongName);
});
SonglistBean bean = await SonglistApi().addSonglist(
songlistName: _controller.text,
Authorization: AppData().currentToken);
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482), backgroundColor: const Color(0xff429482),
@ -499,7 +514,7 @@ class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin
), ),
), ),
child: const Text( child: const Text(
"取消", "确认",
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
), ),

@ -1,76 +0,0 @@
import 'package:flutter/material.dart';
class CommentPage extends StatefulWidget {
const CommentPage({Key? key}) : super(key: key);
@override
_CommentPageState createState() => _CommentPageState();
}
class _CommentPageState extends State<CommentPage> {
final TextEditingController _controller = TextEditingController();
final List<String> _comments = ["这是第一个评论", "很喜欢这首歌!"]; //
void _addComment() {
if (_controller.text.isNotEmpty) {
setState(() {
_comments.insert(0, _controller.text); //
});
_controller.clear(); //
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('评论'),
),
body: Column(
children: [
//
Expanded(
child: ListView.builder(
reverse: true, //
itemCount: _comments.length,
itemBuilder: (context, index) {
return ListTile(
leading: const CircleAvatar(
child: Icon(Icons.person),
),
title: Text(_comments[index]),
subtitle: Text('${DateTime.now().difference(DateTime.now().subtract(Duration(minutes: index * 5))).inMinutes} 分钟前'),
);
},
),
),
const Divider(),
//
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: TextField(
controller: _controller,
decoration: InputDecoration(
hintText: '输入你的评论...',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
onSubmitted: (_) => _addComment(), //
),
),
IconButton(
icon: const Icon(Icons.send, color: Colors.blue),
onPressed: _addComment,
),
],
),
),
],
),
);
}
}

@ -8,7 +8,6 @@ class TextFieldColor extends StatelessWidget {
final String? Function(String?)? validator; final String? Function(String?)? validator;
final FocusNode? focusNode; final FocusNode? focusNode;
final String? Function(String?)? onChanged; final String? Function(String?)? onChanged;
final bool enabled; // enabled
const TextFieldColor({ const TextFieldColor({
super.key, super.key,
@ -19,13 +18,11 @@ class TextFieldColor extends StatelessWidget {
this.validator, this.validator,
this.focusNode, this.focusNode,
this.onChanged, this.onChanged,
this.enabled = true, //
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return TextFormField( return TextFormField(
enabled: enabled,
validator: validator, validator: validator,
controller: controller, controller: controller,
focusNode: focusNode, focusNode: focusNode,
@ -37,26 +34,23 @@ class TextFieldColor extends StatelessWidget {
suffixIcon: suffixIcon, suffixIcon: suffixIcon,
contentPadding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 16.0), contentPadding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 16.0),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
borderSide: BorderSide.none, borderSide: BorderSide.none
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
borderSide: BorderSide.none, borderSide: BorderSide.none,
), ),
disabledBorder: OutlineInputBorder( // fillColor: Color(0xffE3F0ED),
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide.none,
),
fillColor: enabled ? const Color(0xffE3F0ED) : const Color(0xffE3F0ED).withOpacity(0.7), //
filled: true, filled: true,
hintText: hintText, hintText: hintText,
alignLabelWithHint: true, alignLabelWithHint: true,
hintStyle: TextStyle( hintStyle: TextStyle(
color: enabled ? const Color(0xff6E6E6E) : const Color(0xff6E6E6E).withOpacity(0.5), color: Color(0xff6E6E6E),
fontSize: 16, fontSize: 16
), ),
), ),
); );
} }
} }

@ -5,18 +5,12 @@
import FlutterMacOS import FlutterMacOS
import Foundation import Foundation
import audio_session
import audioplayers_darwin import audioplayers_darwin
import file_selector_macos import file_selector_macos
import just_audio
import path_provider_foundation import path_provider_foundation
import shared_preferences_foundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin")) AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
} }

@ -6,23 +6,15 @@ packages:
description: description:
name: async name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.11.0" version: "2.11.0"
audio_session:
dependency: transitive
description:
name: audio_session
sha256: "343e83bc7809fbda2591a49e525d6b63213ade10c76f15813be9aed6657b3261"
url: "https://pub.dev"
source: hosted
version: "0.1.21"
audioplayers: audioplayers:
dependency: "direct main" dependency: "direct main"
description: description:
name: audioplayers name: audioplayers
sha256: c05c6147124cd63e725e861335a8b4d57300b80e6e92cea7c145c739223bbaef sha256: c05c6147124cd63e725e861335a8b4d57300b80e6e92cea7c145c739223bbaef
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.2.1" version: "5.2.1"
audioplayers_android: audioplayers_android:
@ -30,7 +22,7 @@ packages:
description: description:
name: audioplayers_android name: audioplayers_android
sha256: b00e1a0e11365d88576320ec2d8c192bc21f1afb6c0e5995d1c57ae63156acb5 sha256: b00e1a0e11365d88576320ec2d8c192bc21f1afb6c0e5995d1c57ae63156acb5
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "4.0.3" version: "4.0.3"
audioplayers_darwin: audioplayers_darwin:
@ -38,7 +30,7 @@ packages:
description: description:
name: audioplayers_darwin name: audioplayers_darwin
sha256: "3034e99a6df8d101da0f5082dcca0a2a99db62ab1d4ddb3277bed3f6f81afe08" sha256: "3034e99a6df8d101da0f5082dcca0a2a99db62ab1d4ddb3277bed3f6f81afe08"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.0.2" version: "5.0.2"
audioplayers_linux: audioplayers_linux:
@ -46,7 +38,7 @@ packages:
description: description:
name: audioplayers_linux name: audioplayers_linux
sha256: "60787e73fefc4d2e0b9c02c69885402177e818e4e27ef087074cf27c02246c9e" sha256: "60787e73fefc4d2e0b9c02c69885402177e818e4e27ef087074cf27c02246c9e"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.1.0" version: "3.1.0"
audioplayers_platform_interface: audioplayers_platform_interface:
@ -54,7 +46,7 @@ packages:
description: description:
name: audioplayers_platform_interface name: audioplayers_platform_interface
sha256: "365c547f1bb9e77d94dd1687903a668d8f7ac3409e48e6e6a3668a1ac2982adb" sha256: "365c547f1bb9e77d94dd1687903a668d8f7ac3409e48e6e6a3668a1ac2982adb"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "6.1.0" version: "6.1.0"
audioplayers_web: audioplayers_web:
@ -62,7 +54,7 @@ packages:
description: description:
name: audioplayers_web name: audioplayers_web
sha256: "22cd0173e54d92bd9b2c80b1204eb1eb159ece87475ab58c9788a70ec43c2a62" sha256: "22cd0173e54d92bd9b2c80b1204eb1eb159ece87475ab58c9788a70ec43c2a62"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "4.1.0" version: "4.1.0"
audioplayers_windows: audioplayers_windows:
@ -70,7 +62,7 @@ packages:
description: description:
name: audioplayers_windows name: audioplayers_windows
sha256: "9536812c9103563644ada2ef45ae523806b0745f7a78e89d1b5fb1951de90e1a" sha256: "9536812c9103563644ada2ef45ae523806b0745f7a78e89d1b5fb1951de90e1a"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.1.0" version: "3.1.0"
boolean_selector: boolean_selector:
@ -78,7 +70,7 @@ packages:
description: description:
name: boolean_selector name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
characters: characters:
@ -86,7 +78,7 @@ packages:
description: description:
name: characters name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
clock: clock:
@ -94,7 +86,7 @@ packages:
description: description:
name: clock name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
collection: collection:
@ -102,7 +94,7 @@ packages:
description: description:
name: collection name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.18.0" version: "1.18.0"
cross_file: cross_file:
@ -110,7 +102,7 @@ packages:
description: description:
name: cross_file name: cross_file
sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670" sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.3.4+2" version: "0.3.4+2"
crypto: crypto:
@ -118,7 +110,7 @@ packages:
description: description:
name: crypto name: crypto
sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.6" version: "3.0.6"
cupertino_icons: cupertino_icons:
@ -126,7 +118,7 @@ packages:
description: description:
name: cupertino_icons name: cupertino_icons
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.8" version: "1.0.8"
dio: dio:
@ -134,7 +126,7 @@ packages:
description: description:
name: dio name: dio
sha256: "5598aa796bbf4699afd5c67c0f5f6e2ed542afc956884b9cd58c306966efc260" sha256: "5598aa796bbf4699afd5c67c0f5f6e2ed542afc956884b9cd58c306966efc260"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.7.0" version: "5.7.0"
dio_web_adapter: dio_web_adapter:
@ -142,7 +134,7 @@ packages:
description: description:
name: dio_web_adapter name: dio_web_adapter
sha256: "33259a9276d6cea88774a0000cfae0d861003497755969c92faa223108620dc8" sha256: "33259a9276d6cea88774a0000cfae0d861003497755969c92faa223108620dc8"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
fake_async: fake_async:
@ -150,7 +142,7 @@ packages:
description: description:
name: fake_async name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.1" version: "1.3.1"
ffi: ffi:
@ -158,7 +150,7 @@ packages:
description: description:
name: ffi name: ffi
sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.3" version: "2.1.3"
file: file:
@ -166,7 +158,7 @@ packages:
description: description:
name: file name: file
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "7.0.1" version: "7.0.1"
file_picker: file_picker:
@ -174,23 +166,23 @@ packages:
description: description:
name: file_picker name: file_picker
sha256: "1bbf65dd997458a08b531042ec3794112a6c39c07c37ff22113d2e7e4f81d4e4" sha256: "1bbf65dd997458a08b531042ec3794112a6c39c07c37ff22113d2e7e4f81d4e4"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "6.2.1" version: "6.2.1"
file_selector_linux: file_selector_linux:
dependency: transitive dependency: transitive
description: description:
name: file_selector_linux name: file_selector_linux
sha256: b2b91daf8a68ecfa4a01b778a6f52edef9b14ecd506e771488ea0f2e0784198b sha256: "712ce7fab537ba532c8febdb1a8f167b32441e74acd68c3ccb2e36dcb52c4ab2"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.9.3+1" version: "0.9.3"
file_selector_macos: file_selector_macos:
dependency: transitive dependency: transitive
description: description:
name: file_selector_macos name: file_selector_macos
sha256: "271ab9986df0c135d45c3cdb6bd0faa5db6f4976d3e4b437cf7d0f258d941bfc" sha256: "271ab9986df0c135d45c3cdb6bd0faa5db6f4976d3e4b437cf7d0f258d941bfc"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.9.4+2" version: "0.9.4+2"
file_selector_platform_interface: file_selector_platform_interface:
@ -198,7 +190,7 @@ packages:
description: description:
name: file_selector_platform_interface name: file_selector_platform_interface
sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.6.2" version: "2.6.2"
file_selector_windows: file_selector_windows:
@ -206,7 +198,7 @@ packages:
description: description:
name: file_selector_windows name: file_selector_windows
sha256: "8f5d2f6590d51ecd9179ba39c64f722edc15226cc93dcc8698466ad36a4a85a4" sha256: "8f5d2f6590d51ecd9179ba39c64f722edc15226cc93dcc8698466ad36a4a85a4"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.9.3+3" version: "0.9.3+3"
fixnum: fixnum:
@ -214,7 +206,7 @@ packages:
description: description:
name: fixnum name: fixnum
sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
flutter: flutter:
@ -227,7 +219,7 @@ packages:
description: description:
name: flutter_lints name: flutter_lints
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.3" version: "2.0.3"
flutter_plugin_android_lifecycle: flutter_plugin_android_lifecycle:
@ -235,7 +227,7 @@ packages:
description: description:
name: flutter_plugin_android_lifecycle name: flutter_plugin_android_lifecycle
sha256: "9b78450b89f059e96c9ebb355fa6b3df1d6b330436e0b885fb49594c41721398" sha256: "9b78450b89f059e96c9ebb355fa6b3df1d6b330436e0b885fb49594c41721398"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.23" version: "2.0.23"
flutter_swiper_view: flutter_swiper_view:
@ -243,7 +235,7 @@ packages:
description: description:
name: flutter_swiper_view name: flutter_swiper_view
sha256: "2a165b259e8a4c49d4da5626b967ed42a73dac2d075bd9e266ad8d23b9f01879" sha256: "2a165b259e8a4c49d4da5626b967ed42a73dac2d075bd9e266ad8d23b9f01879"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.8" version: "1.1.8"
flutter_test: flutter_test:
@ -261,7 +253,7 @@ packages:
description: description:
name: get name: get
sha256: e4e7335ede17452b391ed3b2ede016545706c01a02292a6c97619705e7d2a85e sha256: e4e7335ede17452b391ed3b2ede016545706c01a02292a6c97619705e7d2a85e
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "4.6.6" version: "4.6.6"
get_storage: get_storage:
@ -269,7 +261,7 @@ packages:
description: description:
name: get_storage name: get_storage
sha256: "39db1fffe779d0c22b3a744376e86febe4ade43bf65e06eab5af707dc84185a2" sha256: "39db1fffe779d0c22b3a744376e86febe4ade43bf65e06eab5af707dc84185a2"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
http: http:
@ -277,7 +269,7 @@ packages:
description: description:
name: http name: http
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.2" version: "1.2.2"
http_parser: http_parser:
@ -285,7 +277,7 @@ packages:
description: description:
name: http_parser name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "4.0.2" version: "4.0.2"
image_picker: image_picker:
@ -293,7 +285,7 @@ packages:
description: description:
name: image_picker name: image_picker
sha256: "021834d9c0c3de46bf0fe40341fa07168407f694d9b2bb18d532dc1261867f7a" sha256: "021834d9c0c3de46bf0fe40341fa07168407f694d9b2bb18d532dc1261867f7a"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.2" version: "1.1.2"
image_picker_android: image_picker_android:
@ -301,7 +293,7 @@ packages:
description: description:
name: image_picker_android name: image_picker_android
sha256: "8faba09ba361d4b246dc0a17cb4289b3324c2b9f6db7b3d457ee69106a86bd32" sha256: "8faba09ba361d4b246dc0a17cb4289b3324c2b9f6db7b3d457ee69106a86bd32"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.8.12+17" version: "0.8.12+17"
image_picker_for_web: image_picker_for_web:
@ -309,7 +301,7 @@ packages:
description: description:
name: image_picker_for_web name: image_picker_for_web
sha256: "717eb042ab08c40767684327be06a5d8dbb341fe791d514e4b92c7bbe1b7bb83" sha256: "717eb042ab08c40767684327be06a5d8dbb341fe791d514e4b92c7bbe1b7bb83"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.6" version: "3.0.6"
image_picker_ios: image_picker_ios:
@ -317,7 +309,7 @@ packages:
description: description:
name: image_picker_ios name: image_picker_ios
sha256: "4f0568120c6fcc0aaa04511cb9f9f4d29fc3d0139884b1d06be88dcec7641d6b" sha256: "4f0568120c6fcc0aaa04511cb9f9f4d29fc3d0139884b1d06be88dcec7641d6b"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.8.12+1" version: "0.8.12+1"
image_picker_linux: image_picker_linux:
@ -325,7 +317,7 @@ packages:
description: description:
name: image_picker_linux name: image_picker_linux
sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa" sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.1+1" version: "0.2.1+1"
image_picker_macos: image_picker_macos:
@ -333,7 +325,7 @@ packages:
description: description:
name: image_picker_macos name: image_picker_macos
sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62" sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.1+1" version: "0.2.1+1"
image_picker_platform_interface: image_picker_platform_interface:
@ -341,7 +333,7 @@ packages:
description: description:
name: image_picker_platform_interface name: image_picker_platform_interface
sha256: "9ec26d410ff46f483c5519c29c02ef0e02e13a543f882b152d4bfd2f06802f80" sha256: "9ec26d410ff46f483c5519c29c02ef0e02e13a543f882b152d4bfd2f06802f80"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.10.0" version: "2.10.0"
image_picker_windows: image_picker_windows:
@ -349,7 +341,7 @@ packages:
description: description:
name: image_picker_windows name: image_picker_windows
sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb" sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.1+1" version: "0.2.1+1"
js: js:
@ -357,39 +349,15 @@ packages:
description: description:
name: js name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.6.7" version: "0.6.7"
just_audio:
dependency: "direct main"
description:
name: just_audio
sha256: a49e7120b95600bd357f37a2bb04cd1e88252f7cdea8f3368803779b925b1049
url: "https://pub.dev"
source: hosted
version: "0.9.42"
just_audio_platform_interface:
dependency: transitive
description:
name: just_audio_platform_interface
sha256: "0243828cce503c8366cc2090cefb2b3c871aa8ed2f520670d76fd47aa1ab2790"
url: "https://pub.dev"
source: hosted
version: "4.3.0"
just_audio_web:
dependency: transitive
description:
name: just_audio_web
sha256: "9a98035b8b24b40749507687520ec5ab404e291d2b0937823ff45d92cb18d448"
url: "https://pub.dev"
source: hosted
version: "0.4.13"
leak_tracker: leak_tracker:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "10.0.5" version: "10.0.5"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
@ -397,7 +365,7 @@ packages:
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.5" version: "3.0.5"
leak_tracker_testing: leak_tracker_testing:
@ -405,7 +373,7 @@ packages:
description: description:
name: leak_tracker_testing name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.1" version: "3.0.1"
lints: lints:
@ -413,7 +381,7 @@ packages:
description: description:
name: lints name: lints
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
matcher: matcher:
@ -421,7 +389,7 @@ packages:
description: description:
name: matcher name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.16+1" version: "0.12.16+1"
material_color_utilities: material_color_utilities:
@ -429,7 +397,7 @@ packages:
description: description:
name: material_color_utilities name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.11.1" version: "0.11.1"
meta: meta:
@ -437,7 +405,7 @@ packages:
description: description:
name: meta name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.15.0" version: "1.15.0"
mime: mime:
@ -445,7 +413,7 @@ packages:
description: description:
name: mime name: mime
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
nested: nested:
@ -453,7 +421,7 @@ packages:
description: description:
name: nested name: nested
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
path: path:
@ -461,23 +429,23 @@ packages:
description: description:
name: path name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.9.0" version: "1.9.0"
path_provider: path_provider:
dependency: transitive dependency: transitive
description: description:
name: path_provider name: path_provider
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.5" version: "2.1.4"
path_provider_android: path_provider_android:
dependency: transitive dependency: transitive
description: description:
name: path_provider_android name: path_provider_android
sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.2.12" version: "2.2.12"
path_provider_foundation: path_provider_foundation:
@ -485,7 +453,7 @@ packages:
description: description:
name: path_provider_foundation name: path_provider_foundation
sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16 sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.4.0" version: "2.4.0"
path_provider_linux: path_provider_linux:
@ -493,7 +461,7 @@ packages:
description: description:
name: path_provider_linux name: path_provider_linux
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.2.1" version: "2.2.1"
path_provider_platform_interface: path_provider_platform_interface:
@ -501,7 +469,7 @@ packages:
description: description:
name: path_provider_platform_interface name: path_provider_platform_interface
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.2" version: "2.1.2"
path_provider_windows: path_provider_windows:
@ -509,63 +477,15 @@ packages:
description: description:
name: path_provider_windows name: path_provider_windows
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.3.0" version: "2.3.0"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb"
url: "https://pub.dev"
source: hosted
version: "11.3.1"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: "71bbecfee799e65aff7c744761a57e817e73b738fedf62ab7afd5593da21f9f1"
url: "https://pub.dev"
source: hosted
version: "12.0.13"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0
url: "https://pub.dev"
source: hosted
version: "9.4.5"
permission_handler_html:
dependency: transitive
description:
name: permission_handler_html
sha256: af26edbbb1f2674af65a8f4b56e1a6f526156bc273d0e65dd8075fab51c78851
url: "https://pub.dev"
source: hosted
version: "0.1.3+2"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9
url: "https://pub.dev"
source: hosted
version: "4.2.3"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
url: "https://pub.dev"
source: hosted
version: "0.2.1"
platform: platform:
dependency: transitive dependency: transitive
description: description:
name: platform name: platform
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.1.6" version: "3.1.6"
plugin_platform_interface: plugin_platform_interface:
@ -573,7 +493,7 @@ packages:
description: description:
name: plugin_platform_interface name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.8" version: "2.1.8"
provider: provider:
@ -581,73 +501,9 @@ packages:
description: description:
name: provider name: provider
sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "6.1.2" version: "6.1.2"
rxdart:
dependency: transitive
description:
name: rxdart
sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962"
url: "https://pub.dev"
source: hosted
version: "0.28.0"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
sha256: "95f9997ca1fb9799d494d0cb2a780fd7be075818d59f00c43832ed112b158a82"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
sha256: "3b9febd815c9ca29c9e3520d50ec32f49157711e143b7a4ca039eb87e8ade5ab"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: "07e050c7cd39bad516f8d64c455f04508d09df104be326d8c02551590a0d513d"
url: "https://pub.dev"
source: hosted
version: "2.5.3"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
sha256: d2ca4132d3946fec2184261726b355836a82c33d7d5b67af32692aff18a4684e
url: "https://pub.dev"
source: hosted
version: "2.4.2"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -658,7 +514,7 @@ packages:
description: description:
name: source_span name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0"
sprintf: sprintf:
@ -666,7 +522,7 @@ packages:
description: description:
name: sprintf name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "7.0.0" version: "7.0.0"
stack_trace: stack_trace:
@ -674,7 +530,7 @@ packages:
description: description:
name: stack_trace name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.11.1" version: "1.11.1"
stream_channel: stream_channel:
@ -682,7 +538,7 @@ packages:
description: description:
name: stream_channel name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.2" version: "2.1.2"
string_scanner: string_scanner:
@ -690,7 +546,7 @@ packages:
description: description:
name: string_scanner name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
synchronized: synchronized:
@ -698,7 +554,7 @@ packages:
description: description:
name: synchronized name: synchronized
sha256: "69fe30f3a8b04a0be0c15ae6490fc859a78ef4c43ae2dd5e8a623d45bfcf9225" sha256: "69fe30f3a8b04a0be0c15ae6490fc859a78ef4c43ae2dd5e8a623d45bfcf9225"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.3.0+3" version: "3.3.0+3"
term_glyph: term_glyph:
@ -706,7 +562,7 @@ packages:
description: description:
name: term_glyph name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.1" version: "1.2.1"
test_api: test_api:
@ -714,7 +570,7 @@ packages:
description: description:
name: test_api name: test_api
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.7.2" version: "0.7.2"
typed_data: typed_data:
@ -722,7 +578,7 @@ packages:
description: description:
name: typed_data name: typed_data
sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.4.0" version: "1.4.0"
uuid: uuid:
@ -730,7 +586,7 @@ packages:
description: description:
name: uuid name: uuid
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "4.5.1" version: "4.5.1"
vector_math: vector_math:
@ -738,7 +594,7 @@ packages:
description: description:
name: vector_math name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.4" version: "2.1.4"
vm_service: vm_service:
@ -746,7 +602,7 @@ packages:
description: description:
name: vm_service name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "14.2.5" version: "14.2.5"
web: web:
@ -754,23 +610,23 @@ packages:
description: description:
name: web name: web
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
win32: win32:
dependency: "direct main" dependency: "direct main"
description: description:
name: win32 name: win32
sha256: "84ba388638ed7a8cb3445a320c8273136ab2631cd5f2c57888335504ddab1bc2" sha256: e1d0cc62e65dc2561f5071fcbccecf58ff20c344f8f3dc7d4922df372a11df1f
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.8.0" version: "5.7.1"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
name: xdg_directories name: xdg_directories
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.dev" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
sdks: sdks:

@ -30,12 +30,10 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
win32: ^5.7.1 win32: ^5.1.0
flutter_swiper_view: 1.1.8 flutter_swiper_view: 1.1.8
audioplayers: ^5.2.1 audioplayers: ^5.2.1
permission_handler: ^11.0.1
just_audio: ^0.9.34
shared_preferences: ^2.2.0
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.

@ -10,11 +10,6 @@ include(${EPHEMERAL_DIR}/generated_config.cmake)
# https://github.com/flutter/flutter/issues/57146. # https://github.com/flutter/flutter/issues/57146.
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
# Set fallback configurations for older versions of the flutter tool.
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
set(FLUTTER_TARGET_PLATFORM "windows-x64")
endif()
# === Flutter Library === # === Flutter Library ===
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
@ -97,7 +92,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E env COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT} ${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
${FLUTTER_TARGET_PLATFORM} $<CONFIG> windows-x64 $<CONFIG>
VERBATIM VERBATIM
) )
add_custom_target(flutter_assemble DEPENDS add_custom_target(flutter_assemble DEPENDS

@ -8,13 +8,10 @@
#include <audioplayers_windows/audioplayers_windows_plugin.h> #include <audioplayers_windows/audioplayers_windows_plugin.h>
#include <file_selector_windows/file_selector_windows.h> #include <file_selector_windows/file_selector_windows.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
AudioplayersWindowsPluginRegisterWithRegistrar( AudioplayersWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
FileSelectorWindowsRegisterWithRegistrar( FileSelectorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorWindows")); registry->GetRegistrarForPlugin("FileSelectorWindows"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
} }

@ -5,7 +5,6 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_windows audioplayers_windows
file_selector_windows file_selector_windows
permission_handler_windows
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST

Loading…
Cancel
Save