Fix the audio timer

dev
wenlei 9 months ago
parent 68e635e97d
commit 822336eee7

@ -1896,7 +1896,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = AY569L2R6W;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
@ -1937,7 +1937,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = AY569L2R6W;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;

@ -10,7 +10,7 @@ import UIKit
enum PresentationViewType {
case tips(Bool)
case filter
case audioMore
case audioMore(Bool)
case share
case photoConfirm
case audioTrackList
@ -81,9 +81,9 @@ class CardPresentationController: PresentationController, UIGestureRecognizerDel
case .filter:
return containerView.bounds
.inset(by: UIEdgeInsets(top: containerView.bounds.height - 474 - BaseDimensions.bottomHeight, left: 0, bottom: 0, right: 0))
case .audioMore:
case .audioMore(let isShowTiming):
return containerView.bounds
.inset(by: UIEdgeInsets(top: containerView.bounds.height - 323 - BaseDimensions.bottomHeight, left: 0, bottom: 0, right: 0))
.inset(by: UIEdgeInsets(top: containerView.bounds.height - (isShowTiming ? 377 : 323) - BaseDimensions.bottomHeight, left: 0, bottom: 0, right: 0))
case .share:
return containerView.bounds
.inset(by: UIEdgeInsets(top: containerView.bounds.height - 251 - BaseDimensions.bottomHeight, left: 0, bottom: 0, right: 0))

@ -31,43 +31,44 @@ class CommentCountButton: UIControl {
var count: Int? {
didSet {
// self.commentImageView.snp.removeConstraints()
// self.commentCountLabel.snp.removeConstraints()
if let count = count, count > 0 {
commentCountLabel.isHidden = false
commentCountLabel.text = count.commentDigital(aimCount: 999)
} else {
commentCountLabel.isHidden = true
commentCountLabel.text = " "
}
if let count = count, count > 0 {
commentCountLabel.snp.remakeConstraints { make in
make.right.equalTo(self).offset(-4)
make.top.equalTo(self)
}
commentImageView.snp.remakeConstraints { make in
make.left.equalTo(self)
make.right.equalTo(commentCountLabel.snp.left).offset(0)
make.top.equalTo(self)
make.bottom.equalTo(self)
make.size.equalTo(CGSize.init(width: 24, height: 24))
}
// commentCountLabel.snp.makeConstraints { make in
// make.right.equalTo(self)
// make.top.equalTo(self)
// }
//
// commentImageView.snp.makeConstraints { make in
// make.left.equalTo(self)
// make.right.equalTo(commentCountLabel.snp.left).offset(0)
// make.top.equalTo(self)
// make.bottom.equalTo(self)
// make.size.equalTo(CGSize.init(width: 24, height: 24))
// }
//
} else {
commentCountLabel.isHidden = true
// commentImageView.snp.makeConstraints { make in
// make.left.equalTo(self)
// make.top.equalTo(self)
// make.bottom.equalTo(self)
// make.size.equalTo(CGSize.init(width: 24, height: 24))
// make.right.equalTo(self)
// }
commentCountLabel.snp.removeConstraints()
commentImageView.snp.removeConstraints()
commentImageView.snp.remakeConstraints { make in
make.left.equalTo(self)
make.top.equalTo(self)
make.bottom.equalTo(self)
make.size.equalTo(CGSize.init(width: 24, height: 24))
make.right.equalTo(self)
}
}
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
@ -100,37 +101,15 @@ class CommentCountButton: UIControl {
override func layoutSubviews() {
super.layoutSubviews()
if let count = count, count > 0 {
commentCountLabel.snp.makeConstraints { make in
make.right.equalTo(self).offset(-4)
make.top.equalTo(self)
}
commentImageView.snp.makeConstraints { make in
make.left.equalTo(self)
make.right.equalTo(commentCountLabel.snp.left).offset(0)
make.top.equalTo(self)
make.bottom.equalTo(self)
make.size.equalTo(CGSize.init(width: 24, height: 24))
}
} else {
commentImageView.snp.makeConstraints { make in
make.left.equalTo(self)
make.top.equalTo(self)
make.bottom.equalTo(self)
make.size.equalTo(CGSize.init(width: 24, height: 24))
make.right.equalTo(self)
}
}
// commentImageView.snp.makeConstraints { make in
// make.left.equalTo(self)
// make.top.equalTo(self)
// make.bottom.equalTo(self)
// make.size.equalTo(CGSize.init(width: 24, height: 24))
// make.right.equalTo(self)
// }
}

@ -174,10 +174,10 @@ class HomeViewCell: UITableViewCell {
return gradientLayerView
}()
lazy var commentCountButton: CommentCountButton = {
var commentCountButton: CommentCountButton = {
let commentCountButton = CommentCountButton.init()
commentCountButton.setContentHuggingPriority(.required, for: .horizontal)
commentCountButton.setContentCompressionResistancePriority(.required, for: .horizontal)
// commentCountButton.setContentHuggingPriority(.required, for: .horizontal)
// commentCountButton.setContentCompressionResistancePriority(.required, for: .horizontal)
return commentCountButton
}()
@ -205,7 +205,10 @@ class HomeViewCell: UITableViewCell {
homeNumberView.numberLabel.text = journal.journalNo
titleImageView.kf.setImage(with: URL.init(string: journal.image ?? ""))
if journal.journalNo == "1017" {
print("journal.totalCommentReplyInt\(journal.totalCommentReplyInt)")
}
if journal.commentList?.isEmpty == false {
commentLabel.isHidden = true
rollingNoticeView.isHidden = false
@ -220,7 +223,8 @@ class HomeViewCell: UITableViewCell {
commentLabel.isHidden = false
rollingNoticeView.isHidden = true
multiUserAvatarView.isHidden = true
commentCountButton.count = 0
}

@ -175,9 +175,10 @@ extension AudioMoreActionController {
extension AudioMoreActionController: UIViewControllerTransitioningDelegate {
func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
guard let viewModel = self.viewModel as? AudioMoreActionViewModel else { return nil }
let carePresentationVC = CardPresentationController.init(presentedViewController: presented, presenting: presenting)
carePresentationVC.viewType = .audioMore
carePresentationVC.viewType = .audioMore(viewModel.isShowTiming)
return carePresentationVC
}

@ -242,7 +242,7 @@ class JournalDetailController: TableViewController {
viewModel.item.accept(track.element)
let audioMoreActionViewModel = AudioMoreActionViewModel(audioTrack: viewModel.item, provider: viewModel.provider)
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore))
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore(false)))
}.disposed(by: rx.disposeBag)

@ -75,7 +75,7 @@ class MineDownloadViewController: TableViewController {
let audioMoreActionViewModel = AudioMoreActionViewModel.init(audioTrack: viewModel.item, provider: viewModel.provider)
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore))
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore(false)))
}

@ -69,7 +69,7 @@ class MineSingleController: TableViewController {
let audioMoreActionViewModel = AudioMoreActionViewModel.init(audioTrack: viewModel.needRefresh, provider: viewModel.provider)
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore))
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore(false)))
}

@ -221,7 +221,7 @@ class PersonalSongViewController: CollectionViewController, UIScrollViewDelegate
viewModel.item.accept(audioTrack)
let audioMoreActionViewModel = AudioMoreActionViewModel.init(audioTrack: viewModel.item, provider: viewModel.provider)
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore))
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore(false)))
}

@ -68,7 +68,7 @@ class AudioTrackListViewController: ViewController {
let audioMoreActionViewModel = AudioMoreActionViewModel.init(audioTrack: viewModel.reloadData, provider: viewModel.provider)
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore))
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore(false)))
}

@ -198,7 +198,7 @@ class PlayerViewController: ViewController {
let audioMoreActionViewModel = AudioMoreActionViewModel.init(audioTrack: viewModel.currentAudioTrack, isShowTiming: true, provider: viewModel.provider)
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore))
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore(true)))

@ -223,7 +223,7 @@ class SongResultsViewController: CollectionViewController {
viewModel.item.accept(audioTrack)
let audioMoreActionViewModel = AudioMoreActionViewModel.init(audioTrack: viewModel.item, provider: viewModel.provider)
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore))
self?.navigator.show(segue: .audioMore(viewModel: audioMoreActionViewModel), sender: self, transition: .navigationPresent(type: .audioMore(false)))
}

@ -28,6 +28,7 @@ class CacheViewController: TableViewController {
override func makeUI() {
super.makeUI()
tableView.backgroundColor = .backgroundColor()
view.backgroundColor = .backgroundColor()
tableView.register(CacheViewCell.self, forCellReuseIdentifier: "CacheViewCell")
@ -236,6 +237,15 @@ class CacheHeaderView: UIView {
return tipsLabel
}()
let containerView: UIView = {
let containerView = UIView.init()
containerView.backgroundColor = .white
containerView.layer.cornerRadius = 98
return containerView
}()
private var isPathCreated = false
var cacheCalculation: CacheCalculation? {
@ -268,9 +278,12 @@ class CacheHeaderView: UIView {
func makeUI() {
addSubview(titleLabel)
addSubview(contentLabel)
addSubview(tipsLabel)
backgroundColor = .clear
addSubview(containerView)
containerView.addSubview(titleLabel)
containerView.addSubview(contentLabel)
containerView.addSubview(tipsLabel)
}
@ -278,21 +291,26 @@ class CacheHeaderView: UIView {
override func layoutSubviews() {
super.layoutSubviews()
containerView.snp.makeConstraints { make in
make.centerX.equalTo(self)
make.top.equalTo(self).offset(40)
make.size.equalTo(CGSize.init(width: 196, height: 196))
}
titleLabel.snp.makeConstraints { make in
make.centerX.equalTo(self)
make.top.equalTo(self).offset(101)
make.centerX.equalTo(containerView)
make.top.equalTo(containerView).offset(52)
}
contentLabel.snp.makeConstraints { make in
make.centerX.equalTo(self)
make.left.equalTo(self).offset(10)
make.right.equalTo(self).offset(-10)
make.centerX.equalTo(containerView)
make.left.equalTo(containerView).offset(10)
make.right.equalTo(containerView).offset(-10)
make.top.equalTo(titleLabel.snp.bottom).offset(8)
}
tipsLabel.snp.makeConstraints { make in
make.centerX.equalTo(self)
make.centerX.equalTo(containerView)
make.top.equalTo(contentLabel.snp.bottom).offset(3)
}
@ -303,7 +321,6 @@ class CacheHeaderView: UIView {
private func createCircularPath() {
self.backgroundColor = .clear
// self.layer.cornerRadius = self.frame.size.width / 2
guard !isPathCreated else { return }

@ -123,7 +123,7 @@ class TimingViewController: ViewController {
.observe(on: MainScheduler.instance)
.subscribe(onNext: { [weak self] timeString in
self?.timingView.countLabel.text = timeString
self?.timingView.countLabel.text = timeString == "00:00" ? "min" : timeString
})
.disposed(by: rx.disposeBag)

@ -28,7 +28,7 @@ class TimingViewModel: ViewModel, ViewModelType {
let items: BehaviorRelay<[TimingSection]>
let modelSelected: Driver<Timing>
let timingType: BehaviorRelay<TimingType>
let switchState: BehaviorRelay<Bool>
let switchState: PublishRelay<Bool>
}
let itemSelected = PublishSubject<Timing>()
@ -36,12 +36,34 @@ class TimingViewModel: ViewModel, ViewModelType {
let currentItem = BehaviorRelay<Timing?>.init(value: nil)
let timingType = BehaviorRelay<TimingType>.init(value: .normal)
let switchState: BehaviorRelay<Bool> = BehaviorRelay(value: RxTimer.shared.isRunning.value)
let switchState: PublishRelay<Bool> = PublishRelay()
func transform(input: Input) -> Output {
input.viewWillAppear.subscribe { (_) in
let items = Timing.allCases.map { timing -> Timing in
if timing.description * 60 == RxTimer.shared.lastTime {
switch timing {
case .timeing15:
return .timeing15(isSelected: true)
case .timeing30:
return .timeing30(isSelected: true)
case .timeing60:
return .timeing60(isSelected: true)
case .timeing90:
return .timeing90(isSelected: true)
case .timeing120:
return .timeing120(isSelected: true)
case .custom(_, let timeing):
return .custom(isSelected: true, timeing: timeing)
}
} else {
return timing
}
}
self.items.accept([TimingSection.init(items: Timing.allCases)])
}.disposed(by: rx.disposeBag)
@ -78,7 +100,7 @@ class TimingViewModel: ViewModel, ViewModelType {
}
self.items.accept(updatedSections)
} else {
self.items.accept([TimingSection.init(items: Timing.allCases)])
}
@ -102,13 +124,11 @@ class TimingViewModel: ViewModel, ViewModelType {
}.disposed(by: rx.disposeBag)
switchState.distinctUntilChanged().subscribe { isOn in
switchState.subscribe { isOn in
guard let defaultTime = self.items.value.first?.items.first else { return }
let timing = self.currentItem.value ?? defaultTime
if isOn {
if RxTimer.shared.isRunning.value == false {
self.startTimer(timing: timing)
}
self.startTimer(timing: timing)
} else {
self.currentItem.accept(nil)
RxTimer.shared.invalidate()
@ -126,7 +146,7 @@ class TimingViewModel: ViewModel, ViewModelType {
func startTimer(timing: Timing) {
RxTimer.shared.defaultTime = timing.description * 60
RxTimer.shared.lastTime = timing.description * 60
RxTimer.shared.fire().subscribe { timingStr in

@ -37,7 +37,7 @@ class ESTMusicIndicatorContentView: UIView {
private let kMinBaseOscillationPeriod = CFTimeInterval(0.6)
private let kMaxBaseOscillationPeriod = CFTimeInterval(0.8)
private let kOscillationAnimationKey:String = "oscillation"
private let kDecayDuration = CFTimeInterval(0.3)
private let kDecayDuration = CFTimeInterval(0.5)
private let kDecayAnimationKey:String = "decay"
var barLayers = [CALayer]()

@ -13,7 +13,9 @@ import UIKit
public class RxTimer: NSObject {
static let shared = RxTimer()
public var defaultTime: Int = 60
public var defaultTime: Int = 0
public var lastTime: Int = 0
public let isRunning: BehaviorRelay<Bool> = BehaviorRelay(value: false)
private lazy var residueTime = BehaviorRelay(value: defaultTime)
@ -87,7 +89,6 @@ extension RxTimer {
endBackgroundTask()
isRunning.accept(false)
AudioManager.sharedInstance.pause()
}
private func updateResidueTime() {
@ -95,6 +96,8 @@ extension RxTimer {
if time <= 0 {
invalidate()
residueTime.accept(defaultTime)
AudioManager.sharedInstance.pause()
lastTime = 60
} else {
residueTime.accept(time)
}

Loading…
Cancel
Save