feat: 完成搜索功能

master
Spark 2 weeks ago
parent 8d4a9e519e
commit db425e3cbe

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

@ -0,0 +1,8 @@
## 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

@ -1,3 +1,4 @@
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

@ -1,7 +1,6 @@
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://flyingpig.fun:10010/users/username'; const String _changeNameURL = 'http://flyingpig.fun:10010/users/username';
@ -9,6 +8,7 @@ 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,13 +16,19 @@ 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(headers:{'Authorization':Authorization,'Content-Type':'application/json;charset=UTF-8'}) options: Options(
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);
} }
/// ///
@ -32,7 +38,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'),
}); });
@ -46,8 +52,8 @@ class ChangeApiClient {
}, },
), ),
); );
print(response.data); print(response.data);
avatarUrlNotifier.value = avatar.path;
return UniversalBean.formMap(response.data); return UniversalBean.formMap(response.data);
} }

@ -1,13 +1,15 @@
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 _getMusic1 = 'http://flyingpig.fun:10010/musics/1'; const String _getMusic1 = 'http://flyingpig.fun:10010/musics/1';
const String _getMusic2 = 'http://flyingpig.fun:10010/musics/2'; const String _getMusic2 = 'http://flyingpig.fun:10010/musics/2';
const String _getMusic3 = 'http://flyingpig.fun:10010/musics/3'; const String _getMusic3 = 'http://flyingpig.fun:10010/musics/3';
const String _getSongDetail = 'http://flyingpig.fun:10010/musics';
/// ///
class GetMusic { class GetMusic {
final Dio dio = Dio(); final Dio dio = Dio();
@ -51,3 +53,40 @@ 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://flyingpig.fun: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; //
}
}
}

@ -9,18 +9,27 @@ import '../models/search_bean.dart';
const String _SearchURL = 'http://flyingpig.fun:10010/musics/search'; const String _SearchURL = 'http://flyingpig.fun:10010/musics/search';
const String _postComment = 'http://flyingpig.fun: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();

@ -1,12 +1,36 @@
class Song { class Song {
final String pic; String pic;
final String artistPic; String artistPic;
final String title; String title;
final String artist; String artist;
final String musicurl; String musicurl;
final int id; int id;
final bool likes; bool likes;
final bool collection; 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
);
}
} }

@ -20,16 +20,24 @@ class HomeView extends StatefulWidget {
} }
class _HomeViewState extends State<HomeView> { class _HomeViewState extends State<HomeView> {
// 使 GetX HomeViewModel homeVM
// Get.put() HomeViewModel GetX 便使
final homeVM = Get.put(HomeViewModel()); final homeVM = Get.put(HomeViewModel());
// TextEditingController
//
final TextEditingController _controller = TextEditingController(); final TextEditingController _controller = TextEditingController();
// _isSearching
// _isSearching true_isSearching false
bool _isSearching = false; bool _isSearching = false;
void initState() { void initState() {
super.initState(); super.initState();
_fetchSonglistData(); _fetchSonglistData();
} }
List<Song> songs = []; List<Song> selectedSongs = [];
Future<void> _fetchSonglistData() async { Future<void> _fetchSonglistData() async {
MusicListBean bean1 = MusicListBean bean1 =
await GetMusic().getMusic1(Authorization: AppData().currentToken); await GetMusic().getMusic1(Authorization: AppData().currentToken);
@ -39,7 +47,7 @@ class _HomeViewState extends State<HomeView> {
await GetMusic().getMusic3(Authorization: AppData().currentToken); await GetMusic().getMusic3(Authorization: AppData().currentToken);
setState(() { setState(() {
songs = [ selectedSongs = [
Song( Song(
artistPic: bean1.coverPath!, artistPic: bean1.coverPath!,
title: bean1.name!, title: bean1.name!,
@ -79,28 +87,99 @@ class _HomeViewState extends State<HomeView> {
{"image": "assets/img/banner.png"}, {"image": "assets/img/banner.png"},
]; ];
List<String> _filteredData = []; List<Song> _filteredData = [];
Future<void> _filterData(String query) async { Future<void> _filterData(String query) async {
if (query.isNotEmpty) { if (query.isNotEmpty) {
SearchBean bean = await SearchMusic().search(keyword: query); try {
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 = bean.data _filteredData = [];
?.map((data) => _isSearching = false;
"${data.name} ") // Adjust this based on your data structure
.toList() ??
[];
_isSearching = true;
}); });
} }
} else { } else {
setState(() { setState(() {
_filteredData = [];
_isSearching = false; _isSearching = false;
}); });
} }
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
/// ///
@ -160,6 +239,14 @@ class _HomeViewState extends State<HomeView> {
), ),
), ),
/// ///
Container( Container(
padding: const EdgeInsets.only(left: 20, right: 20, top: 10), padding: const EdgeInsets.only(left: 20, right: 20, top: 10),
@ -224,7 +311,21 @@ class _HomeViewState extends State<HomeView> {
itemCount: _filteredData.length, itemCount: _filteredData.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return ListTile( return ListTile(
title: Text(_filteredData[index]), title: Text(_filteredData[index].title),
onTap: () {
//
Navigator.push(
// 使 Navigator
context,
MaterialPageRoute(
// MusicView
builder: (context) => MusicView(
song: _filteredData[index], //
initialSongIndex: index, //
),
),
);
},
); );
}, },
), ),
@ -233,6 +334,7 @@ class _HomeViewState extends State<HomeView> {
), ),
), ),
///+ ///+
Container( Container(
padding: const EdgeInsets.only(left: 20, right: 20, top: 10), padding: const EdgeInsets.only(left: 20, right: 20, top: 10),
@ -259,18 +361,18 @@ class _HomeViewState extends State<HomeView> {
), ),
ListView.builder( ListView.builder(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
itemCount: songs.length, itemCount: selectedSongs.length,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return ListTile( return ListTile(
leading: Image.network(songs[index].pic), leading: Image.network(selectedSongs[index].pic),
title: Text( title: Text(
songs[index].title, selectedSongs[index].title,
style: const TextStyle(fontSize: 18, color: Colors.black), style: const TextStyle(fontSize: 18, color: Colors.black),
), ),
subtitle: Text( subtitle: Text(
songs[index].artist, selectedSongs[index].artist,
style: const TextStyle(fontSize: 16, color: Colors.black), style: const TextStyle(fontSize: 16, color: Colors.black),
), ),
trailing: InkWell( trailing: InkWell(
@ -284,7 +386,7 @@ class _HomeViewState extends State<HomeView> {
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => MusicView( builder: (context) => MusicView(
song: songs[index], song: selectedSongs[index],
initialSongIndex: index, initialSongIndex: index,
), ),
), ),

@ -1,42 +1,47 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:music_player_miao/view/rank_view.dart'; import 'package:music_player_miao/view/rank_view.dart';
import 'package:music_player_miao/view/user/user_view.dart'; import 'package:music_player_miao/view/user/user_view.dart';
import 'package:get/get.dart';
import '../home_view.dart'; import '../home_view.dart';
import '../release_view.dart'; import '../release_view.dart';
class MainTabView extends StatefulWidget { class MainTabView extends StatefulWidget {
const MainTabView({super.key}); const MainTabView({super.key});
// TabController
TabController? getController(BuildContext context) {
final state = context.findAncestorStateOfType<_MainTabViewState>();
return state?.controller;
}
@override @override
State<MainTabView> createState() => _MainTabViewState(); State<MainTabView> createState() => _MainTabViewState();
} }
class _MainTabViewState extends State<MainTabView> with SingleTickerProviderStateMixin{ class _MainTabViewState extends State<MainTabView> with SingleTickerProviderStateMixin {
TabController? controller; late 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();
// TabController
controller = TabController(length: 4, vsync: this); controller = TabController(length: 4, vsync: this);
controller?.addListener(() { controller.addListener(() {
selectTab = controller?.index ?? 0;
setState(() { setState(() {
selectTab = controller.index;
}); });
}); });
} }
@override @override
void dispose() { void dispose() {
// TODO: implement dispose controller.dispose();
super.dispose(); super.dispose();
controller?.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -48,7 +53,7 @@ class _MainTabViewState extends State<MainTabView> with SingleTickerProviderStat
HomeView(), HomeView(),
RankView(), RankView(),
ReleaseView(), ReleaseView(),
UserView() UserView(),
], ],
), ),
bottomNavigationBar: BottomAppBar( bottomNavigationBar: BottomAppBar(
@ -59,43 +64,37 @@ class _MainTabViewState extends State<MainTabView> with SingleTickerProviderStat
indicatorColor: Colors.transparent, indicatorColor: Colors.transparent,
indicatorWeight: 3, indicatorWeight: 3,
labelColor: Colors.black, labelColor: Colors.black,
labelStyle: const TextStyle( labelStyle: const TextStyle(fontSize: 12),
fontSize: 12
),
unselectedLabelColor: const Color(0xffCDCDCD), unselectedLabelColor: const Color(0xffCDCDCD),
unselectedLabelStyle: const TextStyle( unselectedLabelStyle: const TextStyle(fontSize: 12),
fontSize: 12
),
tabs: [ tabs: [
Tab( Tab(
text: text: "首页",
"首页", icon: Image.asset(
icon:Image.asset( selectTab == 0 ? "assets/img/home_tab.png" : "assets/img/home_tab_un.png",
selectTab == 0?"assets/img/home_tab.png":"assets/img/home_tab_un.png", width: 45, height: 45,
width: 45,height: 45,), ),
), ),
Tab( Tab(
text: text: "排行榜",
"排行榜", icon: Image.asset(
icon:Image.asset( selectTab == 1 ? "assets/img/list_tab.png" : "assets/img/list_tab_un.png",
selectTab == 1?"assets/img/list_tab.png":"assets/img/list_tab_un.png", width: 45, height: 45,
width: 45,height: 45,), ),
), ),
Tab( Tab(
text: text: "发布",
"发布", icon: Image.asset(
icon:Image.asset(selectTab == 2?"assets/img/music_tab.png":"assets/img/music_tab_un.png", selectTab == 2 ? "assets/img/music_tab.png" : "assets/img/music_tab_un.png",
width: 45,height: 45,), width: 45, height: 45,
),
), ),
Tab( Tab(
text: text: "个人",
"个人", icon: Image.asset(
icon:Image.asset(selectTab == 3?"assets/img/user_tab.png":"assets/img/user_tab_un.png", selectTab == 3 ? "assets/img/user_tab.png" : "assets/img/user_tab_un.png",
width: 45,height: 45,), width: 45, height: 45,
),
), ),
], ],
), ),

@ -1,17 +1,12 @@
// 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:music_player_miao/widget/text_field.dart'; import 'package:image_picker/image_picker.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'; import '../../view/main_tab_view/main_tab_view.dart';
class UserInfo extends StatefulWidget { class UserInfo extends StatefulWidget {
const UserInfo({super.key}); const UserInfo({super.key});
@ -23,7 +18,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();
late File _selectedImage; File? _selectedImage;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -42,7 +37,17 @@ class _UserInfoState extends State<UserInfo> {
elevation: 0, elevation: 0,
leading: IconButton( leading: IconButton(
onPressed: () { onPressed: () {
Get.back(); // MainTabView
Get.back(); //
//
Future.delayed(Duration(milliseconds: 100), () {
// MainTabView TabController
final mainTabController = Get.find<MainTabView>().getController(context);
if (mainTabController != null) {
mainTabController.index = 3; //
}
});
}, },
icon: Image.asset( icon: Image.asset(
"assets/img/back.png", "assets/img/back.png",
@ -60,77 +65,8 @@ class _UserInfoState extends State<UserInfo> {
body: SingleChildScrollView( body: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
Container( _buildAvatarRow(),
height: 80, _buildNicknameRow(),
color: Colors.white.withOpacity(0.6),
padding: const EdgeInsets.only(left: 48, right: 25),
child: InkWell(
onTap: () {
_bottomSheet(context);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"头像",
style: TextStyle(fontSize: 20),
),
Row(
children: [
Image.network(
AppData().currentAvatar,
width: 64,
height: 64,
),
const SizedBox(
width: 20,
),
Image.asset(
"assets/img/user_next.png",
width: 25,
height: 25,
)
],
)
],
),
),
),
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(
"assets/img/user_next.png",
width: 25,
height: 25,
)
],
)
],
),
),
)
], ],
), ),
), ),
@ -138,68 +74,159 @@ class _UserInfoState extends State<UserInfo> {
); );
} }
//
Widget _buildAvatarRow() {
return Container(
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,
children: [
const Text(
"头像",
style: TextStyle(fontSize: 20),
),
Row(
children: [
_buildAvatarImage(),
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(
"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: 132, 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('assets/images/bg.png'); _selectedImage = File(pickedFile.path);
setState(() { setState(() {}); // UI
_selectedImage = File(pickedFile.path);
print(_selectedImage); //
}); await ChangeApiClient().changeHeader(
UniversalBean bean = await ChangeApiClient().changeHeader( Authorization: AppData().currentToken,
Authorization: AppData().currentToken, avatar: _selectedImage!);
avatar: _selectedImage);
GetInfoBean bean1 = await GetInfoApiClient().getInfo( //
Authorization: AppData().currentToken); _updatetouxiang(_selectedImage!.path);
AppData appData = AppData(); //
appData.box.write('currentAvatar', AppData().currentAvatar); await GetInfoApiClient().getInfo(
} Authorization: AppData().currentToken);
}, }
style: ElevatedButton.styleFrom( },
backgroundColor: Colors.transparent, style: ElevatedButton.styleFrom(
elevation: 0, backgroundColor: Colors.transparent,
padding: const EdgeInsets.symmetric(vertical: 12), elevation: 0,
tapTargetSize: MaterialTapTargetSize.shrinkWrap, padding: const EdgeInsets.symmetric(vertical: 12),
), tapTargetSize: MaterialTapTargetSize.shrinkWrap,
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: 18),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
"取消",
style: TextStyle(color: Colors.black, fontSize: 18),
),
),
],
), ),
)); 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: 18),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
"取消",
style: TextStyle(color: Colors.black, fontSize: 18),
),
),
],
),
),
);
} }
void _showNicknameDialog() { void _showNicknameDialog() {
@ -209,12 +236,12 @@ 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: TextFieldColor( content: TextField(
controller: _controller, controller: _controller,
hintText: '请输入新昵称', decoration: const InputDecoration(hintText: '请输入新昵称'),
), ),
actions: <Widget>[ actions: <Widget>[
TextButton( TextButton(
@ -225,8 +252,7 @@ class _UserInfoState extends State<UserInfo> {
backgroundColor: const Color(0xff429482), backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50), minimumSize: const Size(130, 50),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: borderRadius: BorderRadius.circular(5.0),
BorderRadius.circular(5.0), // Adjust the radius as needed
), ),
), ),
child: const Text( child: const Text(
@ -237,7 +263,7 @@ class _UserInfoState extends State<UserInfo> {
TextButton( TextButton(
onPressed: () async { onPressed: () async {
_updateNickname(); _updateNickname();
UniversalBean bean = await ChangeApiClient().changeName( await ChangeApiClient().changeName(
Authorization: AppData().currentToken, Authorization: AppData().currentToken,
userName: AppData().currentUsername); userName: AppData().currentUsername);
Navigator.of(context).pop(); Navigator.of(context).pop();
@ -246,8 +272,7 @@ class _UserInfoState extends State<UserInfo> {
backgroundColor: const Color(0xff429482), backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50), minimumSize: const Size(130, 50),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: borderRadius: BorderRadius.circular(5.0),
BorderRadius.circular(5.0), // Adjust the radius as needed
), ),
), ),
child: const Text( child: const Text(
@ -267,4 +292,14 @@ 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); //
});
}
} }

@ -93,10 +93,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.17.2" version: "1.18.0"
cross_file: cross_file:
dependency: transitive dependency: transitive
description: description:
@ -141,10 +141,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: ffi name: ffi
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.1.3"
file: file:
dependency: transitive dependency: transitive
description: description:
@ -336,6 +336,30 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.6.7" version: "0.6.7"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.flutter-io.cn"
source: hosted
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.1"
lints: lints:
dependency: transitive dependency: transitive
description: description:
@ -348,26 +372,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.16" version: "0.12.16+1"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.5.0" version: "0.11.1"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.9.1" version: "1.15.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@ -388,10 +412,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: path name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.3" version: "1.9.0"
path_provider: path_provider:
dependency: transitive dependency: transitive
description: description:
@ -489,18 +513,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.11.0" version: "1.11.1"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.1" version: "2.1.2"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
@ -529,10 +553,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.6.0" version: "0.7.2"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -557,22 +581,22 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.4" version: "2.1.4"
web: vm_service:
dependency: transitive dependency: transitive
description: description:
name: web name: vm_service
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.1.4-beta" version: "14.2.5"
win32: win32:
dependency: transitive dependency: "direct main"
description: description:
name: win32 name: win32
sha256: "7c99c0e1e2fa190b48d25c81ca5e42036d5cac81430ef249027d97b0935c553f" sha256: "10169d3934549017f0ae278ccb07f828f9d6ea21573bab0fb77b0e1ef0fce454"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.1.0" version: "5.7.2"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
@ -582,5 +606,5 @@ packages:
source: hosted source: hosted
version: "1.0.3" version: "1.0.3"
sdks: sdks:
dart: ">=3.1.2 <4.0.0" dart: ">=3.5.0 <4.0.0"
flutter: ">=3.13.0" flutter: ">=3.18.0-18.0.pre.54"

@ -30,7 +30,7 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
win32: ^5.7.1
flutter_swiper_view: 1.1.8 flutter_swiper_view: 1.1.8
audioplayers: ^5.2.1 audioplayers: ^5.2.1

@ -10,6 +10,11 @@ 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")
@ -92,7 +97,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"
windows-x64 $<CONFIG> ${FLUTTER_TARGET_PLATFORM} $<CONFIG>
VERBATIM VERBATIM
) )
add_custom_target(flutter_assemble DEPENDS add_custom_target(flutter_assemble DEPENDS

Loading…
Cancel
Save