feat: set setting footer to app version and add GitHub entry
This commit is contained in:
parent
1320425564
commit
3e77c72d32
|
@ -58,6 +58,7 @@ extension SettingsItem {
|
||||||
|
|
||||||
enum Link: CaseIterable, Hashable {
|
enum Link: CaseIterable, Hashable {
|
||||||
case accountSettings
|
case accountSettings
|
||||||
|
case github
|
||||||
case termsOfService
|
case termsOfService
|
||||||
case privacyPolicy
|
case privacyPolicy
|
||||||
case clearMediaCache
|
case clearMediaCache
|
||||||
|
@ -66,6 +67,7 @@ extension SettingsItem {
|
||||||
var title: String {
|
var title: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .accountSettings: return L10n.Scene.Settings.Section.BoringZone.accountSettings
|
case .accountSettings: return L10n.Scene.Settings.Section.BoringZone.accountSettings
|
||||||
|
case .github: return "GitHub"
|
||||||
case .termsOfService: return L10n.Scene.Settings.Section.BoringZone.terms
|
case .termsOfService: return L10n.Scene.Settings.Section.BoringZone.terms
|
||||||
case .privacyPolicy: return L10n.Scene.Settings.Section.BoringZone.privacy
|
case .privacyPolicy: return L10n.Scene.Settings.Section.BoringZone.privacy
|
||||||
case .clearMediaCache: return L10n.Scene.Settings.Section.SpicyZone.clear
|
case .clearMediaCache: return L10n.Scene.Settings.Section.SpicyZone.clear
|
||||||
|
@ -76,6 +78,7 @@ extension SettingsItem {
|
||||||
var textColor: UIColor {
|
var textColor: UIColor {
|
||||||
switch self {
|
switch self {
|
||||||
case .accountSettings: return Asset.Colors.brandBlue.color
|
case .accountSettings: return Asset.Colors.brandBlue.color
|
||||||
|
case .github: return Asset.Colors.brandBlue.color
|
||||||
case .termsOfService: return Asset.Colors.brandBlue.color
|
case .termsOfService: return Asset.Colors.brandBlue.color
|
||||||
case .privacyPolicy: return Asset.Colors.brandBlue.color
|
case .privacyPolicy: return Asset.Colors.brandBlue.color
|
||||||
case .clearMediaCache: return .systemRed
|
case .clearMediaCache: return .systemRed
|
||||||
|
|
|
@ -66,7 +66,7 @@ extension MetaLabel {
|
||||||
|
|
||||||
case .settingTableFooter:
|
case .settingTableFooter:
|
||||||
font = .preferredFont(forTextStyle: .body)
|
font = .preferredFont(forTextStyle: .body)
|
||||||
textColor = Asset.Colors.Label.primary.color
|
textColor = Asset.Colors.Label.secondary.color
|
||||||
numberOfLines = 0
|
numberOfLines = 0
|
||||||
textContainer.maximumNumberOfLines = 0
|
textContainer.maximumNumberOfLines = 0
|
||||||
paragraphStyle.alignment = .center
|
paragraphStyle.alignment = .center
|
||||||
|
|
|
@ -105,18 +105,18 @@ class SettingsViewController: UIViewController, NeedsDependency {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let tableFooterLabel = MetaLabel(style: .settingTableFooter)
|
let tableFooterLabel = MetaLabel(style: .settingTableFooter)
|
||||||
// lazy var tableFooterView: UIView = {
|
lazy var tableFooterView: UIView = {
|
||||||
// // init with a frame to fix a conflict ('UIView-Encapsulated-Layout-Height' UIStackView:0x7ffe41e47da0.height == 0)
|
// init with a frame to fix a conflict ('UIView-Encapsulated-Layout-Height' UIStackView:0x7ffe41e47da0.height == 0)
|
||||||
// let view = UIStackView(frame: CGRect(x: 0, y: 0, width: 320, height: 320))
|
let view = UIStackView(frame: CGRect(x: 0, y: 0, width: 320, height: 320))
|
||||||
// view.isLayoutMarginsRelativeArrangement = true
|
view.isLayoutMarginsRelativeArrangement = true
|
||||||
// view.layoutMargins = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
|
view.layoutMargins = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
|
||||||
// view.axis = .vertical
|
view.axis = .vertical
|
||||||
// view.alignment = .center
|
view.alignment = .center
|
||||||
//
|
|
||||||
// tableFooterLabel.linkDelegate = self
|
// tableFooterLabel.linkDelegate = self
|
||||||
// view.addArrangedSubview(tableFooterLabel)
|
view.addArrangedSubview(tableFooterLabel)
|
||||||
// return view
|
return view
|
||||||
// }()
|
}()
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
@ -188,24 +188,31 @@ class SettingsViewController: UIViewController, NeedsDependency {
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
viewModel.currentInstance
|
|
||||||
.receive(on: RunLoop.main)
|
let footer = "Mastodon v\(UIApplication.appVersion()) (\(UIApplication.appBuild()))"
|
||||||
.sink { [weak self] instance in
|
let metaContent = PlaintextMetaContent(string: footer)
|
||||||
guard let self = self else { return }
|
tableFooterLabel.configure(content: metaContent)
|
||||||
let version = instance?.version ?? "-"
|
|
||||||
let link = #"<a href="https://github.com/mastodon/mastodon">mastodon/mastodon</a>"#
|
// FIXME:
|
||||||
let content = L10n.Scene.Settings.Footer.mastodonDescription(link, version)
|
// needs a workaround for GitHub link
|
||||||
let mastodonContent = MastodonContent(content: content, emojis: [:])
|
// viewModel.currentInstance
|
||||||
do {
|
// .receive(on: RunLoop.main)
|
||||||
let metaContent = try MastodonMetaContent.convert(document: mastodonContent)
|
// .sink { [weak self] instance in
|
||||||
self.tableFooterLabel.configure(content: metaContent)
|
// guard let self = self else { return }
|
||||||
} catch {
|
// let version = instance?.version ?? "-"
|
||||||
let metaContent = PlaintextMetaContent(string: "")
|
// let link = #"<a href="https://github.com/mastodon/mastodon">mastodon/mastodon</a>"#
|
||||||
self.tableFooterLabel.configure(content: metaContent)
|
// let content = L10n.Scene.Settings.Footer.mastodonDescription(link, version)
|
||||||
assertionFailure()
|
// let mastodonContent = MastodonContent(content: content, emojis: [:])
|
||||||
}
|
// do {
|
||||||
}
|
// let metaContent = try MastodonMetaContent.convert(document: mastodonContent)
|
||||||
.store(in: &disposeBag)
|
// self.tableFooterLabel.configure(content: metaContent)
|
||||||
|
// } catch {
|
||||||
|
// let metaContent = PlaintextMetaContent(string: "")
|
||||||
|
// self.tableFooterLabel.configure(content: metaContent)
|
||||||
|
// assertionFailure()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// .store(in: &disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupView() {
|
private func setupView() {
|
||||||
|
@ -259,7 +266,7 @@ class SettingsViewController: UIViewController, NeedsDependency {
|
||||||
settingsAppearanceTableViewCellDelegate: self,
|
settingsAppearanceTableViewCellDelegate: self,
|
||||||
settingsToggleCellDelegate: self
|
settingsToggleCellDelegate: self
|
||||||
)
|
)
|
||||||
// tableView.tableFooterView = tableFooterView
|
tableView.tableFooterView = tableFooterView
|
||||||
}
|
}
|
||||||
|
|
||||||
func alertToSignout() {
|
func alertToSignout() {
|
||||||
|
@ -376,6 +383,13 @@ extension SettingsViewController: UITableViewDelegate {
|
||||||
guard let box = context.authenticationService.activeMastodonAuthenticationBox.value,
|
guard let box = context.authenticationService.activeMastodonAuthenticationBox.value,
|
||||||
let url = URL(string: "https://\(box.domain)/auth/edit") else { return }
|
let url = URL(string: "https://\(box.domain)/auth/edit") else { return }
|
||||||
viewModel.openAuthenticationPage(authenticateURL: url, presentationContextProvider: self)
|
viewModel.openAuthenticationPage(authenticateURL: url, presentationContextProvider: self)
|
||||||
|
case .github:
|
||||||
|
guard let url = URL(string: "https://github.com/mastodon/mastodon-ios") else { break }
|
||||||
|
coordinator.present(
|
||||||
|
scene: .safari(url: url),
|
||||||
|
from: self,
|
||||||
|
transition: .safariPresent(animated: true, completion: nil)
|
||||||
|
)
|
||||||
case .termsOfService, .privacyPolicy:
|
case .termsOfService, .privacyPolicy:
|
||||||
// same URL
|
// same URL
|
||||||
guard let url = viewModel.privacyURL else { break }
|
guard let url = viewModel.privacyURL else { break }
|
||||||
|
|
|
@ -130,6 +130,7 @@ extension SettingsViewModel {
|
||||||
let boringZoneSettingsItems: [SettingsItem] = {
|
let boringZoneSettingsItems: [SettingsItem] = {
|
||||||
let links: [SettingsItem.Link] = [
|
let links: [SettingsItem.Link] = [
|
||||||
.accountSettings,
|
.accountSettings,
|
||||||
|
.github,
|
||||||
.termsOfService,
|
.termsOfService,
|
||||||
.privacyPolicy
|
.privacyPolicy
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue