Skip to content

Commit

Permalink
#298: 검색추천화면 - 4개 섹션 구성
Browse files Browse the repository at this point in the history
  • Loading branch information
wendoei committed Dec 15, 2024
1 parent 35acb00 commit b4273b1
Show file tree
Hide file tree
Showing 24 changed files with 1,447 additions and 247 deletions.
61 changes: 57 additions & 4 deletions StreetDrop/StreetDrop.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ protocol RecentMusicQueriesStorage {
query: RecentMusicQueryDTO,
completion: @escaping (Result<RecentMusicQueryDTO, Error>) -> Void
)
func deleteRecentQuery(query: RecentMusicQueryDTO) async
}

protocol RecommendMusicQueriesStorage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ extension UserDefaultsRecentMusicQueriesStorage: RecentMusicQueriesStorage {
completion(.success(query))
}
}

func deleteRecentQuery(query: RecentMusicQueryDTO) async {
var queries = self.fetchRecentMusicQueries().list
self.cleanUpQueries(for: query, in: &queries)
self.persist(recentMusicQueries: queries)
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// RecommendMusicRepository.swift
// StreetDrop
//
// Created by jihye kim on 07/08/2024.
//

import Foundation

import RxSwift

protocol RecommendMusicRepository {
func fetchPromptOfTheDay() -> Single<String>
func fetchTrendingMusicList() -> Single<[Music]>
func fetchMostDroppedMusicList() -> Single<[Music]>
func fetchArtistList() -> Single<[Artist]>
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ protocol SearchingMusicRepository {
func fetchRecommendMusicQueries() -> Single<RecommendMusic>
func fetchRecentMusicQueries() -> Single<[String]>
func fetchVillageName(latitude: Double, longitude: Double) -> Single<String>
func deleteRecentMusicQueries(keyword: String) async
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// DefaultRecommendMusicRepository.swift
// StreetDrop
//
// Created by jihye kim on 07/08/2024.
//

import Foundation

import Moya
import RxSwift

final class DefaultRecommendMusicRepository: RecommendMusicRepository {
private let networkManager: NetworkManager

init(
networkManager: NetworkManager = NetworkManager(
provider: MoyaProvider<MultiTarget>()
)
) {
self.networkManager = networkManager
}

// TODO: jihye - update api

func fetchPromptOfTheDay() -> Single<String> {
Single.just("비오는 날, 어떤 음악이 떠오르시나요?")
}

func fetchTrendingMusicList() -> Single<[Music]> {
Single.just([
Music(
albumName: "",
artistName: "ILLIT",
songName: "Magnetic",
durationTime: "2:41",
albumImage: "https://is2-ssl.mzstatic.com/image/thumb/Music126/v4/03/8d/0e/038d0e52-e96d-f386-b8eb-9f77fa013543/195497146918_Cover.jpg/300x300bb.jpg",
albumThumbnailImage: "https://is2-ssl.mzstatic.com/image/thumb/Music126/v4/03/8d/0e/038d0e52-e96d-f386-b8eb-9f77fa013543/195497146918_Cover.jpg/100x100bb.jpg",
genre: []
)
])
}

func fetchMostDroppedMusicList() -> Single<[Music]> {
Single.just([
Music(
albumName: "",
artistName: "NewJeans",
songName: "Supernatural",
durationTime: "3:11",
albumImage: "https://is2-ssl.mzstatic.com/image/thumb/Music126/v4/03/8d/0e/038d0e52-e96d-f386-b8eb-9f77fa013543/195497146918_Cover.jpg/300x300bb.jpg",
albumThumbnailImage: "https://is2-ssl.mzstatic.com/image/thumb/Music126/v4/03/8d/0e/038d0e52-e96d-f386-b8eb-9f77fa013543/195497146918_Cover.jpg/100x100bb.jpg",
genre: []
)
])
}

func fetchArtistList() -> Single<[Artist]> {
return Single.just([
Artist(name: "NewJeans", image: "https://is2-ssl.mzstatic.com/image/thumb/Music126/v4/03/8d/0e/038d0e52-e96d-f386-b8eb-9f77fa013543/195497146918_Cover.jpg/100x100bb.jpg"),
Artist(name: "SEVENTEEN", image: "https://is2-ssl.mzstatic.com/image/thumb/Music126/v4/03/8d/0e/038d0e52-e96d-f386-b8eb-9f77fa013543/195497146918_Cover.jpg/100x100bb.jpg"),
Artist(name: "아이유", image: "https://is2-ssl.mzstatic.com/image/thumb/Music126/v4/03/8d/0e/038d0e52-e96d-f386-b8eb-9f77fa013543/195497146918_Cover.jpg/100x100bb.jpg"),
Artist(name: "aespa", image: "https://is2-ssl.mzstatic.com/image/thumb/Music126/v4/03/8d/0e/038d0e52-e96d-f386-b8eb-9f77fa013543/195497146918_Cover.jpg/100x100bb.jpg"),
Artist(name: "최유리", image: "https://is2-ssl.mzstatic.com/image/thumb/Music126/v4/03/8d/0e/038d0e52-e96d-f386-b8eb-9f77fa013543/195497146918_Cover.jpg/100x100bb.jpg")
])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,10 @@ final class DefaultSearchingMusicRepository: SearchingMusicRepository {
responseType: String.self
)
}

func deleteRecentMusicQueries(keyword: String) async {
await self.recentMusicQueriesPersistentStorage.deleteRecentQuery(
query: RecentMusicQueryDTO(query: keyword)
)
}
}
2 changes: 1 addition & 1 deletion StreetDrop/StreetDrop/Domain/Entity/Music.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

struct Music {
struct Music: Hashable {
let albumName: String
let artistName: String
let songName: String
Expand Down
6 changes: 6 additions & 0 deletions StreetDrop/StreetDrop/Domain/Entity/RecommendMusic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ struct RecommendMusicData: Decodable {
let text: String
let color: String
}

// TODO: jihye - api update
struct Artist: Hashable {
let name: String
let image: String
}
41 changes: 41 additions & 0 deletions StreetDrop/StreetDrop/Domain/UseCase/RecommendMusicUsecase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// RecommendMusicUsecase.swift
// StreetDrop
//
// Created by jihye kim on 07/08/2024.
//

import Foundation

import RxSwift

protocol RecommendMusicUsecase {
func getPromptOfTheDay() -> Single<String>
func getTrendingMusicList() -> Single<[Music]>
func getMostDroppedMusicList() -> Single<[Music]>
func getArtistList() -> Single<[Artist]>
}

final class DefaultRecommendMusicUsecase: RecommendMusicUsecase {
private let recommendMusicRepository: RecommendMusicRepository

init(recommendMusicRepository: RecommendMusicRepository = DefaultRecommendMusicRepository()) {
self.recommendMusicRepository = recommendMusicRepository
}

func getPromptOfTheDay() -> Single<String> {
recommendMusicRepository.fetchPromptOfTheDay()
}

func getTrendingMusicList() -> Single<[Music]> {
recommendMusicRepository.fetchTrendingMusicList()
}

func getMostDroppedMusicList() -> Single<[Music]> {
recommendMusicRepository.fetchMostDroppedMusicList()
}

func getArtistList() -> Single<[Artist]> {
recommendMusicRepository.fetchArtistList()
}
}
5 changes: 5 additions & 0 deletions StreetDrop/StreetDrop/Domain/UseCase/SearchMusicUsecase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ protocol SearchMusicUsecase {
func getRecentSearches() -> Single<[String]>
func getVillageName(latitude: Double, longitude: Double) -> Single<String>
func fetchRecommendSearch() -> Single<RecommendMusic>
func deleteRecentSearch(keyword: String) async
}

final class DefaultSearchingMusicUsecase: SearchMusicUsecase {
Expand Down Expand Up @@ -44,4 +45,8 @@ final class DefaultSearchingMusicUsecase: SearchMusicUsecase {
func fetchRecommendSearch() -> Single<RecommendMusic> {
return self.searchingMusicRepository.fetchRecommendMusicQueries()
}

func deleteRecentSearch(keyword: String) async {
await self.searchingMusicRepository.deleteRecentMusicQueries(keyword: keyword)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,10 @@ private extension EditCommentViewController {
//MARK: - UI

func configureUI() {
self.cancelButton.setTitle(Constant.empty, for: .normal)
self.dropButton.setTitle(Constant.editButtonDisabledTitle, for: .disabled)
self.dropButton.setTitle(Constant.editButtonNormalTitle, for: .normal)
self.backButton.setTitle(Constant.empty, for: .normal)
self.locationLabel.isHidden = true
self.cancelButton.setTitle(Constant.empty, for: .normal)

self.topView.addSubview(titleLabel)
titleLabel.snp.makeConstraints {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ class MusicDropViewController: UIViewController, Toastable, Alertable {
return button
}()

lazy var cancelButton: UIButton = {
let button: UIButton = UIButton()
button.setTitle("나가기", for: .normal)
button.setTitleColor(.gray300, for: .normal)
button.titleLabel?.font = .pretendard(size: 14, weight: 600)

return button
}()

lazy var topView: UIView = UIView()

private lazy var scrollView: UIScrollView = {
Expand Down Expand Up @@ -299,16 +290,10 @@ private extension MusicDropViewController {
}.disposed(by: disposeBag)

backButton.rx.tap
.bind { [weak self] in
self?.navigationController?.popViewController(animated: true)
}
.disposed(by: disposeBag)

cancelButton.rx.tap
.bind(with: self) { owner, _ in
let dismissAction: AlertCompletion = { [weak self] in
self?.navigationController?.dismiss(animated: true)
self?.navigationController?.popToRootViewController(animated: true)
self?.navigationController?.popViewController(animated: true)
}

owner.showAlert(
Expand Down Expand Up @@ -407,7 +392,7 @@ private extension MusicDropViewController {
self.view.backgroundColor = .gray900
self.view.clipsToBounds = true

[backButton, cancelButton].forEach {
[backButton].forEach {
topView.addSubview($0)
}

Expand Down Expand Up @@ -454,11 +439,6 @@ private extension MusicDropViewController {
$0.trailing.equalTo(backButton.titleLabel!.snp.leading)
}

cancelButton.snp.makeConstraints {
$0.trailing.equalToSuperview().inset(24)
$0.centerY.equalToSuperview()
}

scrollView.snp.makeConstraints {
$0.leading.trailing.bottom.equalTo(self.view.safeAreaLayoutGuide)
$0.top.equalTo(topView.snp.bottom)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import UIKit

class GuideDetailView: UIView {
private let text: String

private lazy var speechBubblePointImageView: UIImageView = {
let speechBubblePointImage = UIImage(named: "speechBubblePoint")
let imageView = UIImageView(image: speechBubblePointImage)
Expand All @@ -19,19 +17,21 @@ class GuideDetailView: UIView {

private lazy var guideLabel: UILabel = {
let label = UILabel()
label.text = self.text
label.font = .pretendard(size: 12, weightName: .medium)
label.numberOfLines = 0
label.textColor = .gray200

return label
}()

init(text: String) {
self.text = text
init() {
super.init(frame: .zero)
configureUI()
}

func configureText(_ text: String) {
guideLabel.text = text
}

@available(*, unavailable)
required init?(coder: NSCoder) {
Expand Down

This file was deleted.

Loading

0 comments on commit b4273b1

Please sign in to comment.