Compare commits

..

3 Commits

@ -1,6 +1,13 @@
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()
} }
@ -13,6 +20,13 @@ 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() mavenCentral()

@ -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\://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/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://flyingpig.fun:10010/songlists'; const String _SonglistURL = 'http://flyingpig.fun:10010/songlists';
/// const String _MyWorksURL = 'http://flyingpig.fun:10010/musics/upload-music';
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://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 { Future<SearchBean> getSonglist({required String Authorization}) async {
Response response = await dio.get(_SonglistURL, Response response = await dio.get(_SonglistURL,
data: { data: {

@ -1,9 +1,13 @@
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();
@ -20,9 +24,14 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return const GetMaterialApp( return GetMaterialApp(
debugShowCheckedModeBanner: false, title: 'Flutter Demo',
home: SplashView(), 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; 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'];

@ -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: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';
class MyMusicView extends StatefulWidget { List<T> flatten<T>(Iterable<Iterable<T>> iterable) {
const MyMusicView({super.key}); return iterable.expand((inner) => inner).toList();
}
class MyMusicView extends StatefulWidget {
final int? songlistIdd;
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;
@ -232,8 +304,10 @@ class _MyMusicViewState extends State<MyMusicView> {
], ],
), ),
Expanded( Expanded(
child: ListView.builder( child: songsNum == 0
itemCount: 10, ? Center(child: Text('该歌单为空')) //
: ListView.builder(
itemCount: songsNum,
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),
@ -249,8 +323,11 @@ class _MyMusicViewState extends State<MyMusicView> {
shape: const CircleBorder(), shape: const CircleBorder(),
activeColor: const Color(0xff429482), activeColor: const Color(0xff429482),
) )
: null, : CircleAvatar(
title: Text('歌曲名 $index - 歌手'), backgroundImage: NetworkImage(coverPath[index]), //
radius: 25,
),
title: Text('${name[index]} - ${singerName[index]}'), //
trailing: _isSelectMode trailing: _isSelectMode
? null ? null
: IconButton( : IconButton(
@ -444,3 +521,6 @@ class _MyMusicViewState extends State<MyMusicView> {
); );
} }
} }

@ -1,6 +1,9 @@
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 {
@ -11,6 +14,12 @@ 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;
@ -18,6 +27,37 @@ 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;
@ -248,8 +288,10 @@ class _MyWorkViewState extends State<MyWorkView> {
], ],
), ),
Expanded( Expanded(
child: ListView.builder( child: MyWorkCount == 0
itemCount: 10, ? Center(child: Text('你还没有作品')) //
: 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),
@ -265,8 +307,11 @@ class _MyWorkViewState extends State<MyWorkView> {
shape: const CircleBorder(), shape: const CircleBorder(),
activeColor: const Color(0xff429482), activeColor: const Color(0xff429482),
) )
: null, : CircleAvatar(
title: Text('歌曲名 $index - 歌手'), backgroundImage: NetworkImage(coverPath[index]), //
radius: 25,
),
title: Text('${MyWorkNames[index]} - ${singerName[index]}'), //
trailing: _isSelectMode trailing: _isSelectMode
? null ? null
: IconButton( : IconButton(

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

Loading…
Cancel
Save