mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
调整设置页面样式
This commit is contained in:
parent
387f561c43
commit
d3053ad875
@ -75,6 +75,7 @@
|
||||
063B909B272149BF00431EC2 /* HomeViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 063B909A272149BF00431EC2 /* HomeViewModelTests.swift */; };
|
||||
0642B55A27EB13F100453D91 /* MutableTextCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0642B55927EB13F100453D91 /* MutableTextCell.swift */; };
|
||||
0642B55C27EB149900453D91 /* MutableTextCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0642B55B27EB149900453D91 /* MutableTextCellViewModel.swift */; };
|
||||
0647DB682CE604AA00102066 /* MessageSettingFooter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0647DB672CE604AA00102066 /* MessageSettingFooter.swift */; };
|
||||
064CAB9E256BE9090018155C /* PreviewCardCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 064CAB9D256BE9090018155C /* PreviewCardCellViewModel.swift */; };
|
||||
064CABA6256BE9510018155C /* PreviewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 064CABA5256BE9510018155C /* PreviewModel.swift */; };
|
||||
0653677629B719BC0038BDB8 /* CryptoSettingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F08EA329B098DD006AB9CA /* CryptoSettingManager.swift */; };
|
||||
@ -309,6 +310,7 @@
|
||||
063B909A272149BF00431EC2 /* HomeViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModelTests.swift; sourceTree = "<group>"; };
|
||||
0642B55927EB13F100453D91 /* MutableTextCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MutableTextCell.swift; sourceTree = "<group>"; };
|
||||
0642B55B27EB149900453D91 /* MutableTextCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MutableTextCellViewModel.swift; sourceTree = "<group>"; };
|
||||
0647DB672CE604AA00102066 /* MessageSettingFooter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageSettingFooter.swift; sourceTree = "<group>"; };
|
||||
064CAB9D256BE9090018155C /* PreviewCardCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewCardCellViewModel.swift; sourceTree = "<group>"; };
|
||||
064CABA5256BE9510018155C /* PreviewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewModel.swift; sourceTree = "<group>"; };
|
||||
0653677729B727A60038BDB8 /* CryptoSettingRelay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoSettingRelay.swift; sourceTree = "<group>"; };
|
||||
@ -511,6 +513,7 @@
|
||||
06787C382A710568008ABDD7 /* GesturePassTextView.swift */,
|
||||
0635A8042CE47DFE0027E00F /* SettingSectionHeader.swift */,
|
||||
0635A8062CE4883A0027E00F /* DonateCell.swift */,
|
||||
0647DB672CE604AA00102066 /* MessageSettingFooter.swift */,
|
||||
);
|
||||
path = View;
|
||||
sourceTree = "<group>";
|
||||
@ -1209,6 +1212,7 @@
|
||||
06EEF335291CD00000CA228A /* CryptoSettingViewModel.swift in Sources */,
|
||||
0637FA8020E0981E00E80174 /* BarkSettings.swift in Sources */,
|
||||
065BE4402563D649002A8CA4 /* SoundsViewModel.swift in Sources */,
|
||||
0647DB682CE604AA00102066 /* MessageSettingFooter.swift in Sources */,
|
||||
065BE4462563D7E5002A8CA4 /* ViewModelType.swift in Sources */,
|
||||
0603706B20E20A7C00F4CA05 /* String+Extension.swift in Sources */,
|
||||
068F66B3247BD84C00DAD25A /* MessageListViewController.swift in Sources */,
|
||||
|
||||
@ -2073,7 +2073,7 @@
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "隐私协议"
|
||||
"value" : "隐私政策"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2262,6 +2262,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"restoreSubscription" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Restore Subscription"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "恢复订阅"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"restricted" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
@ -2560,6 +2577,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"sourceCode" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Source Code"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "开源代码"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"successfulDonation" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
@ -2852,6 +2886,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"userAgreement" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "User Agreement"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "用户协议"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"viewAllSounds" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
|
||||
@ -33,12 +33,18 @@ class MessageSettingsViewController: BaseViewController<MessageSettingsViewModel
|
||||
tableView.sectionFooterHeight = UITableView.automaticDimension
|
||||
tableView.sectionHeaderHeight = UITableView.automaticDimension
|
||||
|
||||
let footer = MessageSettingFooter()
|
||||
footer.openLinkHandler = { [weak self] link in
|
||||
self?.openLink(link: link)
|
||||
}
|
||||
tableView.tableFooterView = footer
|
||||
|
||||
tableView.delegate = self
|
||||
return tableView
|
||||
}()
|
||||
|
||||
private var headers: [String?] = []
|
||||
private var footers: [MessageSettingSectionFooterProtocol?] = []
|
||||
private var footers: [String?] = []
|
||||
|
||||
override func makeUI() {
|
||||
self.title = NSLocalizedString("settings")
|
||||
@ -275,6 +281,24 @@ class MessageSettingsViewController: BaseViewController<MessageSettingsViewModel
|
||||
|
||||
}.disposed(by: rx.disposeBag)
|
||||
}
|
||||
|
||||
func openLink(link: String) {
|
||||
switch link {
|
||||
case "privacyPolicy":
|
||||
self.navigationController?.present(BarkSFSafariViewController(
|
||||
url: URL(string: "https://api.day.app/privacy")!
|
||||
), animated: true, completion: nil)
|
||||
case "userAgreement":
|
||||
self.navigationController?.present(BarkSFSafariViewController(
|
||||
url: URL(string: "https://www.apple.com/legal/internet-services/itunes/dev/stdeula")!
|
||||
), animated: true, completion: nil)
|
||||
case "restoreSubscription":
|
||||
SwiftyStoreKit.restorePurchases { [weak self] _ in
|
||||
self?.showSnackbar(text: NSLocalizedString("done"))
|
||||
}
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension MessageSettingsViewController: UITableViewDelegate {
|
||||
@ -288,21 +312,8 @@ extension MessageSettingsViewController: UITableViewDelegate {
|
||||
|
||||
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
|
||||
guard self.footers.count > section, let footer = self.footers[section] else { return UIView() }
|
||||
|
||||
let footerView = SettingSectionFooter()
|
||||
footerView.titleLabel.text = footer.title
|
||||
if let footerUrl = footer.url, let url = URL(string: footerUrl) {
|
||||
footerView.titleLabel.numberOfLines = 0
|
||||
footerView.titleLabel.minimumScaleFactor = 0.5
|
||||
footerView.titleLabel.adjustsFontSizeToFitWidth = true
|
||||
|
||||
// 点击跳转
|
||||
let tap = UITapGestureRecognizer()
|
||||
footerView.addGestureRecognizer(tap)
|
||||
tap.rx.event.asControlEvent().subscribe(onNext: { [weak self] _ in
|
||||
self?.navigationController?.present(BarkSFSafariViewController(url: url), animated: true, completion: nil)
|
||||
}).disposed(by: footerView.rx.disposeBag)
|
||||
}
|
||||
footerView.titleLabel.text = footer
|
||||
return footerView
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,10 +150,10 @@ class MessageSettingsViewModel: ViewModel, ViewModelType {
|
||||
url: URL(string: NSLocalizedString("docUrl"))
|
||||
))
|
||||
otherSettings.append(.detail(
|
||||
title: NSLocalizedString("privacyPolicy"),
|
||||
title: NSLocalizedString("sourceCode"),
|
||||
text: nil,
|
||||
textColor: nil,
|
||||
url: URL(string: "https://api.day.app/privacy")
|
||||
url: URL(string: "https://github.com/Finb/Bark")
|
||||
))
|
||||
|
||||
settings.append(
|
||||
@ -171,10 +171,7 @@ class MessageSettingsViewModel: ViewModel, ViewModelType {
|
||||
SectionModel(
|
||||
model: MessageSettingSection(
|
||||
header: NSLocalizedString("donate"),
|
||||
footer: MessageSettingSectionFooter(
|
||||
title: "LICENSED APPLICATION END USER LICENSE AGREEMENT",
|
||||
url: "https://www.apple.com/legal/internet-services/itunes/dev/stdeula/"
|
||||
)
|
||||
footer: nil
|
||||
),
|
||||
items: donateSettings
|
||||
)
|
||||
@ -248,27 +245,7 @@ enum MessageSettingItem {
|
||||
case donate(title: String, productId: String)
|
||||
}
|
||||
|
||||
protocol MessageSettingSectionFooterProtocol {
|
||||
var title: String? { get }
|
||||
var url: String? { get }
|
||||
}
|
||||
|
||||
extension String: MessageSettingSectionFooterProtocol {
|
||||
var title: String? {
|
||||
return self
|
||||
}
|
||||
|
||||
var url: String? {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
struct MessageSettingSectionFooter: MessageSettingSectionFooterProtocol {
|
||||
var title: String?
|
||||
var url: String?
|
||||
}
|
||||
|
||||
struct MessageSettingSection {
|
||||
var header: String?
|
||||
var footer: MessageSettingSectionFooterProtocol?
|
||||
var footer: String?
|
||||
}
|
||||
|
||||
42
View/MessageSettingFooter.swift
Normal file
42
View/MessageSettingFooter.swift
Normal file
@ -0,0 +1,42 @@
|
||||
//
|
||||
// MessageSettingFooter.swift
|
||||
// Bark
|
||||
//
|
||||
// Created by huangfeng on 11/14/24.
|
||||
// Copyright © 2024 Fin. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class MessageSettingFooter: UITextView, UITextViewDelegate {
|
||||
init() {
|
||||
super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 40), textContainer: .none)
|
||||
self.backgroundColor = UIColor.clear
|
||||
self.isEditable = false
|
||||
self.delegate = self
|
||||
|
||||
self.font = UIFont.preferredFont(ofSize: 12)
|
||||
self.textColor = BKColor.grey.darken1
|
||||
|
||||
let attr = NSMutableAttributedString(string: NSLocalizedString("privacyPolicy"), attributes: [.link: "privacyPolicy"])
|
||||
attr.append(NSAttributedString(string: " · "))
|
||||
attr.append(NSAttributedString(string: NSLocalizedString("userAgreement"), attributes: [.link: "userAgreement"]))
|
||||
attr.append(NSAttributedString(string: " · "))
|
||||
attr.append(NSAttributedString(string: NSLocalizedString("restoreSubscription"), attributes: [.link: "restoreSubscription"]))
|
||||
|
||||
self.attributedText = attr
|
||||
self.linkTextAttributes = [.foregroundColor: BKColor.grey.darken1, .underlineStyle: NSUnderlineStyle.single.rawValue]
|
||||
self.textAlignment = .center
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
var openLinkHandler: ((String) -> Void)?
|
||||
func textView(_ textView: UITextView, shouldInteractWith url: URL, in characterRange: NSRange) -> Bool {
|
||||
self.openLinkHandler?(url.absoluteString)
|
||||
return false
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user