Compare commits

..

No commits in common. '1bab49f99747edab8591e61fdd740554bc8d60d8' and '874c491b0d56dbdb61f365a6d584f029985b5ef2' have entirely different histories.

@ -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,13 +13,6 @@ 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\://mirrors.cloud.tencent.com/gradle/gradle-7.5-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

@ -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://flyingpig.fun:10010/songlists';
const String _MyWorksURL = 'http://flyingpig.fun: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://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,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'];
}
}

@ -1,94 +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;
@ -304,10 +232,8 @@ class _MyMusicViewState extends State<MyMusicView> {
], ],
), ),
Expanded( Expanded(
child: songsNum == 0 child: ListView.builder(
? Center(child: Text('该歌单为空')) // itemCount: 10,
: 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),
@ -323,11 +249,8 @@ class _MyMusicViewState extends State<MyMusicView> {
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('${name[index]} - ${singerName[index]}'), //
trailing: _isSelectMode trailing: _isSelectMode
? null ? null
: IconButton( : IconButton(
@ -521,6 +444,3 @@ class _MyMusicViewState extends State<MyMusicView> {
); );
} }
} }

@ -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(

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

Loading…
Cancel
Save