-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #564 from wakmusic/491-LyricHighlighting
π :: (#491) κ°μ¬ νμ΄λΌμ΄ν ꡬν
- Loading branch information
Showing
57 changed files
with
1,531 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
230 changes: 139 additions & 91 deletions
230
Projects/App/Sources/Application/NeedleGenerated.swift
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ public struct LyricsEntity: Equatable { | |
} | ||
|
||
public let text: String | ||
public var isHighlighting: Bool = false | ||
} |
25 changes: 25 additions & 0 deletions
25
Projects/Features/LyricHighlightingFeature/Demo/Resources/LaunchScreen.storyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> | ||
<capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<scenes> | ||
<!--View Controller--> | ||
<scene sceneID="EHf-IW-A2E"> | ||
<objects> | ||
<viewController id="01J-lp-oVM" sceneMemberID="viewController"> | ||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | ||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> | ||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> | ||
</view> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="53" y="375"/> | ||
</scene> | ||
</scenes> | ||
</document> |
19 changes: 19 additions & 0 deletions
19
Projects/Features/LyricHighlightingFeature/Demo/Sources/AppDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import UIKit | ||
|
||
@main | ||
final class AppDelegate: UIResponder, UIApplicationDelegate { | ||
var window: UIWindow? | ||
|
||
func application( | ||
_ application: UIApplication, | ||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil | ||
) -> Bool { | ||
window = UIWindow(frame: UIScreen.main.bounds) | ||
let viewController = UIViewController() | ||
viewController.view.backgroundColor = .yellow | ||
window?.rootViewController = viewController | ||
window?.makeKeyAndVisible() | ||
|
||
return true | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
Projects/Features/LyricHighlightingFeature/Interface/LyricHighlightingFactory.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import UIKit | ||
|
||
public protocol LyricHighlightingFactory { | ||
func makeView(model: LyricHighlightingRequiredModel) -> UIViewController | ||
} |
21 changes: 21 additions & 0 deletions
21
Projects/Features/LyricHighlightingFeature/Interface/LyricHighlightingRequiredModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Foundation | ||
|
||
public struct LyricHighlightingRequiredModel { | ||
public let songID: String | ||
public let title: String | ||
public let artist: String | ||
public let highlightingItems: [String] | ||
|
||
/// κ°μ¬ νμ΄λΌμ΄ν νλ©΄μ μ£Όμ ν΄μ€μΌν νμ μμ΄ν | ||
public init( | ||
songID: String, // λ Έλ κ³ μ ID | ||
title: String, // λ Έλ μ λͺ© | ||
artist: String, // μν°μ€νΈ μ΄λ¦ | ||
highlightingItems: [String] = [] // λ°μ½λ μ΄ν νλ©΄μΌλ‘ λμ΄κ° λλ§ λ£μΌλ©΄λ©λλ€. | ||
) { | ||
self.songID = songID | ||
self.title = title | ||
self.artist = artist | ||
self.highlightingItems = highlightingItems | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import DependencyPlugin | ||
import ProjectDescription | ||
import ProjectDescriptionHelpers | ||
|
||
let project = Project.module( | ||
name: ModulePaths.Feature.LyricHighlightingFeature.rawValue, | ||
targets: [ | ||
.interface( | ||
module: .feature(.LyricHighlightingFeature) | ||
), | ||
.implements( | ||
module: .feature(.LyricHighlightingFeature), | ||
dependencies: [ | ||
.feature(target: .BaseFeature), | ||
.feature(target: .LyricHighlightingFeature, type: .interface), | ||
.domain(target: .SongsDomain, type: .interface) | ||
] | ||
), | ||
.tests( | ||
module: .feature(.LyricHighlightingFeature), | ||
dependencies: [.feature(target: .LyricHighlightingFeature)] | ||
), | ||
.demo( | ||
module: .feature(.LyricHighlightingFeature), | ||
dependencies: [ | ||
.feature(target: .LyricHighlightingFeature) | ||
] | ||
) | ||
] | ||
) |
12 changes: 12 additions & 0 deletions
12
Projects/Features/LyricHighlightingFeature/Sources/Components/LyricDecoratingComponent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Foundation | ||
import LyricHighlightingFeatureInterface | ||
import NeedleFoundation | ||
|
||
public protocol LyricDecoratingDependency: Dependency {} | ||
|
||
public final class LyricDecoratingComponent: Component<LyricDecoratingDependency> { | ||
public func makeView(model: LyricHighlightingRequiredModel) -> LyricDecoratingViewController { | ||
let viewModel = LyricDecoratingViewModel(model: model) | ||
return LyricDecoratingViewController(viewModel: viewModel) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...cts/Features/LyricHighlightingFeature/Sources/Components/LyricHighlightingComponent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Foundation | ||
import LyricHighlightingFeatureInterface | ||
import NeedleFoundation | ||
import SongsDomainInterface | ||
import UIKit | ||
|
||
public protocol LyricHighlightingDependency: Dependency { | ||
var fetchLyricsUseCase: any FetchLyricsUseCase { get } | ||
var lyricDecoratingComponent: LyricDecoratingComponent { get } | ||
var lyricHighlightingFactory: any LyricHighlightingFactory { get } | ||
} | ||
|
||
public final class LyricHighlightingComponent: Component<LyricHighlightingDependency>, LyricHighlightingFactory { | ||
public func makeView(model: LyricHighlightingRequiredModel) -> UIViewController { | ||
let viewModel = LyricHighlightingViewModel(model: model, fetchLyricsUseCase: dependency.fetchLyricsUseCase) | ||
return LyricHighlightingViewController( | ||
viewModel: viewModel, | ||
lyricDecoratingComponent: dependency.lyricDecoratingComponent | ||
) | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
...LyricHighlightingFeature/Sources/ViewControllers/LyricDecoratingViewController+Bind.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import DesignSystem | ||
import Foundation | ||
import RxCocoa | ||
import RxSwift | ||
import UIKit | ||
|
||
extension LyricDecoratingViewController { | ||
func inputBind() { | ||
input.fetchBackgroundImage.onNext(()) | ||
|
||
collectionView.rx | ||
.setDelegate(self) | ||
.disposed(by: disposeBag) | ||
|
||
collectionView.rx.itemSelected | ||
.do(onNext: { [collectionView] indexPath in | ||
collectionView.scrollToItem( | ||
at: indexPath, | ||
at: .centeredHorizontally, | ||
animated: true | ||
) | ||
}) | ||
.bind(to: input.didTapBackground) | ||
.disposed(by: disposeBag) | ||
|
||
backButton.rx.tap | ||
.bind(with: self) { owner, _ in | ||
owner.navigationController?.popViewController(animated: true) | ||
} | ||
.disposed(by: disposeBag) | ||
|
||
saveButton.rx.tap | ||
.bind(with: self) { owner, _ in | ||
let activityViewController = UIActivityViewController( | ||
activityItems: [owner.decorateShareContentView.asImage(size: .init(width: 960, height: 960))], | ||
applicationActivities: nil | ||
) | ||
activityViewController.popoverPresentationController?.sourceRect = CGRect( | ||
x: owner.view.bounds.midX, | ||
y: owner.view.bounds.midY, | ||
width: 0, | ||
height: 0 | ||
) | ||
activityViewController.popoverPresentationController?.permittedArrowDirections = [] | ||
owner.present(activityViewController, animated: true, completion: nil) | ||
} | ||
.disposed(by: disposeBag) | ||
} | ||
|
||
func outputBind() { | ||
output.updateSongTitle | ||
.bind(with: self, onNext: { owner, song in | ||
owner.songTitleLabel.text = song | ||
owner.songTitleLabel.setTextWithAttributes(kernValue: -0.5, alignment: .center) | ||
}) | ||
.disposed(by: disposeBag) | ||
|
||
output.updateArtist | ||
.bind(with: self, onNext: { owner, artist in | ||
owner.artistLabel.text = artist | ||
owner.artistLabel.setTextWithAttributes(kernValue: -0.5, alignment: .center) | ||
}) | ||
.disposed(by: disposeBag) | ||
|
||
output.dataSource | ||
.skip(1) | ||
.do(onNext: { [decorateImageView, indicator] entities in | ||
decorateImageView.backgroundColor = entities.filter { $0.isSelected }.first? | ||
.imageColor ?? DesignSystemAsset.PrimaryColorV2.point.color | ||
indicator.stopAnimating() | ||
}) | ||
.bind(to: collectionView.rx.items) { collectionView, index, model in | ||
guard let cell = collectionView.dequeueReusableCell( | ||
withReuseIdentifier: "\(LyricDecoratingCell.self)", | ||
for: IndexPath(item: index, section: 0) | ||
) as? LyricDecoratingCell else { | ||
return UICollectionViewCell() | ||
} | ||
cell.update(model: model, index: index) | ||
return cell | ||
} | ||
.disposed(by: disposeBag) | ||
|
||
output.highlightingItems | ||
.filter { !$0.isEmpty } | ||
.map { lyric in | ||
let style = NSMutableParagraphStyle() | ||
style.alignment = .center | ||
style.lineSpacing = 8 | ||
let attributedString = NSMutableAttributedString( | ||
string: lyric, | ||
attributes: [ | ||
.font: DesignSystemFontFamily.Pretendard.medium.font(size: 18), | ||
.foregroundColor: UIColor.white, | ||
.kern: -0.5, | ||
.paragraphStyle: style | ||
] | ||
) | ||
return attributedString | ||
} | ||
.bind(to: highlightingLyricLabel.rx.attributedText) | ||
.disposed(by: disposeBag) | ||
} | ||
} |
Oops, something went wrong.