diff --git a/Bark/en.lproj/Localizable.strings b/Bark/en.lproj/Localizable.strings index d3fbf8e4..0c1f5fe1 100644 --- a/Bark/en.lproj/Localizable.strings +++ b/Bark/en.lproj/Localizable.strings @@ -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"; diff --git a/Bark/tr.lproj/Localizable.strings b/Bark/tr.lproj/Localizable.strings index 90556369..1e513b1d 100644 --- a/Bark/tr.lproj/Localizable.strings +++ b/Bark/tr.lproj/Localizable.strings @@ -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"; diff --git a/Bark/zh-Hans.lproj/Localizable.strings b/Bark/zh-Hans.lproj/Localizable.strings index 5a0f97c2..5c880fbc 100644 --- a/Bark/zh-Hans.lproj/Localizable.strings +++ b/Bark/zh-Hans.lproj/Localizable.strings @@ -173,3 +173,5 @@ Github Issue: https://github.com/Finb/Bark/issues uploadSound = "上传铃声"; customSounds = "自定义铃声"; defaultSounds = "默认铃声"; +uploadSoundNoticeFullText = "请先将铃声转换成 caf 格式,时长不超过 30 秒。"; +uploadSoundNoticeHighlightText = "转换成 caf 格式"; diff --git a/Controller/SoundsViewController.swift b/Controller/SoundsViewController.swift index ade18025..8b444526 100644 --- a/Controller/SoundsViewController.swift +++ b/Controller/SoundsViewController.swift @@ -97,6 +97,14 @@ class SoundsViewController: BaseViewController { } 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) ?? "" @@ -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 } }