Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX/#178] PlaylistView 오류 해결 #179

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions PLAT/PLAT.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"PLAT/Preview Content\"";
DEVELOPMENT_TEAM = 9XG4S4XZWN;
DEVELOPMENT_TEAM = MXGCKXDXUM;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = PLAT/App/Info.plist;
Expand All @@ -1337,7 +1337,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.letsplat.thinkyside;
PRODUCT_BUNDLE_IDENTIFIER = com.letsplat;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
Expand All @@ -1359,7 +1359,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"PLAT/Preview Content\"";
DEVELOPMENT_TEAM = 9XG4S4XZWN;
DEVELOPMENT_TEAM = MXGCKXDXUM;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = PLAT/App/Info.plist;
Expand All @@ -1379,7 +1379,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.letsplat.thinkyside;
PRODUCT_BUNDLE_IDENTIFIER = com.letsplat;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@ final class PlaylistServiceImpl: PlaylistServiceInterface {
}
}

/// 플레이리스트를 업데이트합니다. 이미지URL을 받습니다.
func updatePlaylist(playlistId: Int, title: String, imageUrl: String?) async -> Result<Void, any Error> {

let request = UpdatePlaylistRequest(title: title, playlistImageUrl: imageUrl ?? "")
let response = await playlistRepository.updatePlaylist(request: request, playlistId: Int64(playlistId))
switch response {
case .success:
return .success(())
case .failure(let error):
return .failure(error)
}
}
Comment on lines +191 to +202
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

원래의 UIImage?타입을 받는 함수에서는 기본 이미지(url)을 저장해놓을수 없어서
imageUrl 즉, String?타입을 받는 함수를 별도로 만들었습니다.


/// 플레이리스트의 트랙 순서를 변경합니다.
func updateTrackOrder(playlistId: Int, tracks: [Track]) async -> Result<Void, Error> {

Expand Down
1 change: 1 addition & 0 deletions PLAT/PLAT/Domain/Interface/PlaylistServiceInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ protocol PlaylistServiceInterface {
func uploadPlaylist(title: String, image: UIImage?, tracks: [Track]) async -> Result<Int64, Error>
func appendTrackToPlaylist(playlistId: Int, trackId: Int) async -> Result<Void, Error>
func updatePlaylist(playlistId: Int, title: String, image: UIImage?) async -> Result<Void, Error>
func updatePlaylist(playlistId: Int, title: String, imageUrl: String?) async -> Result<Void, Error>
func updateTrackOrder(playlistId: Int, tracks: [Track]) async -> Result<Void, Error>
func deleteTrackFromPlaylist(playlistId: Int, trackId: Int) async -> Result<Void, Error>
func deletePlaylist(playlistId: Int) async -> Result<Void, Error>
Expand Down
14 changes: 14 additions & 0 deletions PLAT/PLAT/Domain/UseCase/PlaylistUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ extension PlaylistUseCase {
}
}

/// 플레이리스트를 업데이트합니다. ImageUrl을 받습니다.
func updatePlaylist(playlistId: Int, title: String, imageUrl: String?) async {
let result = await playlistService.updatePlaylist(
playlistId: playlistId,
title: title,
imageUrl: imageUrl
)

switch result {
case .success: break
case .failure(let error): print(error) // TODO: 에러 처리
}
}

/// 플레이리스트의 트랙 순서를 변경합니다.
func updateTrackOrder(playlistId: Int, tracks: [Track]) {
Task {
Expand Down
14 changes: 9 additions & 5 deletions PLAT/PLAT/Presentaion/Playlist/PlaylistDetailsEditView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ struct PlaylistDetailsEditView: View {
ToolbarItem(placement: .primaryAction) {
Button {
Task {
await playlistUseCase.updatePlaylist(
playlistId: Int(selectedPlaylist.id),
title: selectedPlaylist.title,
image: selectedImage
)
if let selectedImg = selectedImage {
await playlistUseCase.updatePlaylist(
playlistId: Int(selectedPlaylist.id),
title: selectedPlaylist.title,
image: selectedImage
)
} else {
await playlistUseCase.updatePlaylist(playlistId: Int(selectedPlaylist.id), title: selectedPlaylist.title, imageUrl: selectedPlaylist.imageUrl)
}
Comment on lines +63 to +71
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

플레이리스트 편집을 할 때 이미지를 변경한 경우 selectedImage를 전달해주고,
이미 설정해놓은 이미지가 있는 상태에서 변경없이 완료를 누른 경우 원래 설정되어있던 imageUrl을 전달합니다.


playlistUseCase.fetchPlaylistDetail(playlistId: Int(selectedPlaylist.id))
pathModel.pop()
Expand Down
8 changes: 8 additions & 0 deletions PLAT/PLAT/Presentaion/Playlist/PlaylistView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,16 @@ private struct PlaylistImageView: View {
.placeholder {
RoundedRectangle(cornerRadius: 12)
.frame(width: 68, height: 68)
.foregroundStyle(
LinearGradient(
colors: [.orange, .indigo],
startPoint: .top,
endPoint: .bottom
)
)
}
.resizable()
.scaledToFill()
.frame(width: 68, height: 68)
.clipShape(RoundedRectangle(cornerRadius: 12))
}
Expand Down