Skip to content

Commit

Permalink
添加上传铃声提示
Browse files Browse the repository at this point in the history
  • Loading branch information
Finb committed Apr 1, 2024
1 parent 5af2a55 commit cf32d33
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Bark/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,5 @@ Github Issue: https://github.com/Finb/Bark/issues
uploadSound = "Upload Sound";
customSounds = "Custom Sounds";
defaultSounds = "Default Sounds";
uploadSoundNoticeFullText = "Please convert the sound file to caf format, and make sure it's no longer than 30 seconds.";
uploadSoundNoticeHighlightText = "convert the sound file to caf format";
2 changes: 2 additions & 0 deletions Bark/tr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,5 @@ Github Issue: https://github.com/Finb/Bark/issues
uploadSound = "Upload Sound";
customSounds = "Custom Sounds";
defaultSounds = "Default Sounds";
uploadSoundNoticeFullText = "Please convert the sound file to caf format, and make sure it's no longer than 30 seconds.";
uploadSoundNoticeHighlightText = "convert the sound file to caf format";
2 changes: 2 additions & 0 deletions Bark/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,5 @@ Github Issue: https://github.com/Finb/Bark/issues
uploadSound = "上传铃声";
customSounds = "自定义铃声";
defaultSounds = "默认铃声";
uploadSoundNoticeFullText = "请先将铃声转换成 caf 格式,时长不超过 30 秒。";
uploadSoundNoticeHighlightText = "转换成 caf 格式";
44 changes: 42 additions & 2 deletions Controller/SoundsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ class SoundsViewController: BaseViewController<SoundsViewModel> {
}

extension SoundsViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 40
}

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return NSLocalizedString("uploadSoundNoticeFullText").count <= 30 ? 50 : 60
}

func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let sectionTitle = tableView.dataSource?.tableView?(tableView, titleForHeaderInSection: section) ?? ""

Expand All @@ -115,8 +123,40 @@ extension SoundsViewController: UITableViewDelegate {
return view
}

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 40
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let view = UIView()

let fullText = NSLocalizedString("uploadSoundNoticeFullText")
let highlightText = NSLocalizedString("uploadSoundNoticeHighlightText")
let attrStr = NSMutableAttributedString(
string: fullText,
attributes: [
NSAttributedString.Key.foregroundColor: BKColor.grey.darken3,
NSAttributedString.Key.font: RobotoFont.regular(with: 14)
]
)
attrStr.setAttributes([
NSAttributedString.Key.foregroundColor: BKColor.lightBlue.darken3,
NSAttributedString.Key.font: RobotoFont.regular(with: 14)
], range: (fullText as NSString).range(of: highlightText))

let label = UILabel()
label.attributedText = attrStr
label.numberOfLines = 0
view.addSubview(label)
label.snp.makeConstraints { make in
make.left.equalTo(12)
make.right.equalTo(-12)
make.top.equalTo(12)
}

label.isUserInteractionEnabled = true
label.addGestureRecognizer(UITapGestureRecognizer())
label.gestureRecognizers?.first?.rx.event.subscribe(onNext: { _ in
UIApplication.shared.open(URL(string: "https://convertio.co/mp3-caf/")!)
}).disposed(by: label.rx.disposeBag)

return view
}
}

Expand Down

0 comments on commit cf32d33

Please sign in to comment.