Merge branch 'refs/heads/dev'

# Conflicts:
#	lib/view/user/user_view.dart
#	pubspec.lock
#	pubspec.yaml
master
Spark 1 week ago
commit 1bab49f997

@ -1,6 +1,13 @@
buildscript {
ext.kotlin_version = '1.7.10'
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()
mavenCentral()
}
@ -13,6 +20,13 @@ buildscript {
allprojects {
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()
mavenCentral()
mavenCentral()

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

@ -2,13 +2,41 @@ import 'package:dio/dio.dart';
import 'package:music_player_miao/models/search_bean.dart';
import 'package:music_player_miao/models/songlist_bean.dart';
import '../models/getAllSongs_bean.dart';
import '../models/universal_bean.dart';
import 'package:music_player_miao/models/getMyWorks.dart';
const String _SonglistURL = 'http://flyingpig.fun:10010/songlists';
///
const String _MyWorksURL = 'http://flyingpig.fun:10010/musics/upload-music';
class SonglistApi {
final Dio dio = Dio();
///
Future<MyMusicListBean> getAllSongs({required int id, required String Authorization}) async {
String urlWithId = 'http://flyingpig.fun: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 {
Response response = await dio.get(_SonglistURL,
data: {

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

@ -0,0 +1,43 @@
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,6 +9,8 @@ class MusicListBean {
String? uploadUserName;
bool? likeOrNot;
bool? collectOrNot;
MusicListBean.formMap(Map map){
code = map['code'];
msg= map['msg'];

@ -0,0 +1,34 @@
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'];
}
}

@ -1,22 +1,94 @@
import 'package:flutter/material.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 '../../api/api_songlist.dart';
import '../../api/api_songlist.dart';
class MyMusicView extends StatefulWidget {
const MyMusicView({super.key});
List<T> flatten<T>(Iterable<Iterable<T>> iterable) {
return iterable.expand((inner) => inner).toList();
}
class MyMusicView extends StatefulWidget {
final int? songlistIdd;
const MyMusicView({Key? key, this.songlistIdd}) : super(key: key);
@override
State<MyMusicView> createState() => _MyMusicViewState();
}
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());
bool _isSelectMode = false;
final List<bool> _mySongListSelections = List.generate(2, (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() {
setState(() {
_isSelectMode = !_isSelectMode;
@ -232,8 +304,10 @@ class _MyMusicViewState extends State<MyMusicView> {
],
),
Expanded(
child: ListView.builder(
itemCount: 10,
child: songsNum == 0
? Center(child: Text('该歌单为空')) //
: ListView.builder(
itemCount: songsNum,
itemBuilder: (BuildContext context, int index) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 5.0),
@ -249,8 +323,11 @@ class _MyMusicViewState extends State<MyMusicView> {
shape: const CircleBorder(),
activeColor: const Color(0xff429482),
)
: null,
title: Text('歌曲名 $index - 歌手'),
: CircleAvatar(
backgroundImage: NetworkImage(coverPath[index]), //
radius: 25,
),
title: Text('${name[index]} - ${singerName[index]}'), //
trailing: _isSelectMode
? null
: IconButton(
@ -444,3 +521,6 @@ class _MyMusicViewState extends State<MyMusicView> {
);
}
}

@ -1,6 +1,9 @@
import 'package:flutter/material.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';
class MyWorkView extends StatefulWidget {
@ -11,6 +14,12 @@ class MyWorkView extends StatefulWidget {
}
class _MyWorkViewState extends State<MyWorkView> {
int MyWorkCount = 0;
List MyWorkNames = [];
List Songid = [];
List coverPath = [];
List musicPath = [];
List singerName = [];
final listVM = Get.put(HomeViewModel());
bool _isSelectMode = false;
@ -18,6 +27,37 @@ class _MyWorkViewState extends State<MyWorkView> {
List<bool> _mySongListSelections = List.generate(2, (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() {
setState(() {
_isSelectMode = !_isSelectMode;
@ -248,8 +288,10 @@ class _MyWorkViewState extends State<MyWorkView> {
],
),
Expanded(
child: ListView.builder(
itemCount: 10,
child: MyWorkCount == 0
? Center(child: Text('你还没有作品')) //
: ListView.builder(
itemCount: MyWorkCount,
itemBuilder: (BuildContext context, int index) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 5.0),
@ -265,8 +307,11 @@ class _MyWorkViewState extends State<MyWorkView> {
shape: const CircleBorder(),
activeColor: const Color(0xff429482),
)
: null,
title: Text('歌曲名 $index - 歌手'),
: CircleAvatar(
backgroundImage: NetworkImage(coverPath[index]), //
radius: 25,
),
title: Text('${MyWorkNames[index]} - ${singerName[index]}'), //
trailing: _isSelectMode
? null
: IconButton(

@ -27,9 +27,9 @@ class UserView extends StatefulWidget {
class _UserViewState extends State<UserView> {
final homeVM = Get.put(HomeViewModel());
final TextEditingController _controller = TextEditingController();
int playlistCount = 2;
int playlistCount = 0;
List playlistNames = [];
List playlistid = [];
List<int> playlistid = [];
int downloadCount = 0;
String avatar = AppData().currentAvatar;
String username = AppData().currentUsername;
@ -51,7 +51,7 @@ class _UserViewState extends State<UserView> {
setState(() {
playlistNames = bean2.data!.map((data) => data.name!).toList();
playlistid = bean2.data!.map((data) => data.id!).toList();
playlistid = bean2.data!.map((data) => data.id!).toList(); // idint
playlistCount = playlistNames.length;
});
} catch (error) {
@ -116,6 +116,8 @@ class _UserViewState extends State<UserView> {
Container(
padding: const EdgeInsets.only(
left: 15, right: 15, top: 20, bottom: 20),
//
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
@ -152,6 +154,8 @@ class _UserViewState extends State<UserView> {
const SizedBox(
height: 10,
),
//
InkWell(
onTap: () async {
final result = await Get.to(const MyDownloadView());
@ -220,72 +224,43 @@ class _UserViewState extends State<UserView> {
],
),
Container(
padding: const EdgeInsets.only(
left: 15, right: 15, top: 10, bottom: 5),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
InkWell(
onTap: () {},
padding: const EdgeInsets.only(left: 15, right: 15, top: 10, bottom: 5),
child: ListView.builder(
shrinkWrap: true, // 使ListView
itemCount: playlistNames.length, // itemCount
itemBuilder: (context, index) {
return InkWell(
onTap: () {
print('点击成功');
Get.to(MyMusicView(songlistIdd: playlistid[index]));
//
//
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset("assets/img/artist_pic.png"),
const Column(
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"我的收藏",
playlistNames[index], //
style: TextStyle(fontSize: 20),
),
Text(
"19首",
'$playlistCount', //
style: TextStyle(fontSize: 16),
),
],
),
const SizedBox(
width: 80,
),
Image.asset(
"assets/img/user_next.png",
)
const SizedBox(width: 80),
Image.asset("assets/img/user_next.png"),
],
),
),
const SizedBox(
height: 10,
),
InkWell(
onTap: () {},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset("assets/img/artist_pic.png"),
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",
)
],
);
},
),
),
],
)),
InkWell(
onTap: () {
Get.to(const MyMusicView());
@ -469,7 +444,6 @@ class _UserViewState extends State<UserView> {
);
}
///--
void _showAddPlaylistDialog() {
_controller.clear();

Loading…
Cancel
Save