feat: add title view for favorite scene
This commit is contained in:
parent
e7279a0ab6
commit
a0a636917f
|
@ -217,7 +217,7 @@
|
|||
"new_posts": "See new posts",
|
||||
"published": "Published!",
|
||||
"Publishing": "Publishing post..."
|
||||
},
|
||||
}
|
||||
},
|
||||
"public_timeline": {
|
||||
"title": "Public"
|
||||
|
@ -288,21 +288,24 @@
|
|||
"cancel": "Cancel"
|
||||
},
|
||||
"recommend": {
|
||||
"buttonText": "See All",
|
||||
"hash_tag": {
|
||||
"title": "Trending in your timeline",
|
||||
"description": "Hashtags that are getting quite a bit of attention among people you follow",
|
||||
"people_talking": "%s people are talking"
|
||||
},
|
||||
"accounts": {
|
||||
"title": "Accounts you might like",
|
||||
"description": "Except for Sam, you will not like his account.",
|
||||
"follow": "Follow"
|
||||
}
|
||||
"buttonText": "See All",
|
||||
"hash_tag": {
|
||||
"title": "Trending in your timeline",
|
||||
"description": "Hashtags that are getting quite a bit of attention among people you follow",
|
||||
"people_talking": "%s people are talking"
|
||||
},
|
||||
"accounts": {
|
||||
"title": "Accounts you might like",
|
||||
"description": "Except for Sam, you will not like his account.",
|
||||
"follow": "Follow"
|
||||
}
|
||||
}
|
||||
},
|
||||
"hashtag": {
|
||||
"prompt": "%s people talking"
|
||||
},
|
||||
"favorite": {
|
||||
"title": "Your Favorites"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
0F1E2D0B2615C39400C38565 /* HashtagTimelineTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F1E2D0A2615C39400C38565 /* HashtagTimelineTitleView.swift */; };
|
||||
0F1E2D0B2615C39400C38565 /* DoubleTitleLabelNavigationBarTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F1E2D0A2615C39400C38565 /* DoubleTitleLabelNavigationBarTitleView.swift */; };
|
||||
0F2021FB2613262F000C64BF /* HashtagTimelineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F2021FA2613262F000C64BF /* HashtagTimelineViewController.swift */; };
|
||||
0F202201261326E6000C64BF /* HashtagTimelineViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F202200261326E6000C64BF /* HashtagTimelineViewModel.swift */; };
|
||||
0F20220726134DA4000C64BF /* HashtagTimelineViewModel+Diffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F20220626134DA4000C64BF /* HashtagTimelineViewModel+Diffable.swift */; };
|
||||
|
@ -377,7 +377,7 @@
|
|||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0F1E2D0A2615C39400C38565 /* HashtagTimelineTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashtagTimelineTitleView.swift; sourceTree = "<group>"; };
|
||||
0F1E2D0A2615C39400C38565 /* DoubleTitleLabelNavigationBarTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoubleTitleLabelNavigationBarTitleView.swift; sourceTree = "<group>"; };
|
||||
0F2021FA2613262F000C64BF /* HashtagTimelineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashtagTimelineViewController.swift; sourceTree = "<group>"; };
|
||||
0F202200261326E6000C64BF /* HashtagTimelineViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashtagTimelineViewModel.swift; sourceTree = "<group>"; };
|
||||
0F20220626134DA4000C64BF /* HashtagTimelineViewModel+Diffable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HashtagTimelineViewModel+Diffable.swift"; sourceTree = "<group>"; };
|
||||
|
@ -760,7 +760,6 @@
|
|||
0F1E2D102615C39800C38565 /* View */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0F1E2D0A2615C39400C38565 /* HashtagTimelineTitleView.swift */,
|
||||
);
|
||||
path = View;
|
||||
sourceTree = "<group>";
|
||||
|
@ -770,10 +769,10 @@
|
|||
children = (
|
||||
0F1E2D102615C39800C38565 /* View */,
|
||||
0F2021FA2613262F000C64BF /* HashtagTimelineViewController.swift */,
|
||||
0F202226261411BA000C64BF /* HashtagTimelineViewController+StatusProvider.swift */,
|
||||
0F202200261326E6000C64BF /* HashtagTimelineViewModel.swift */,
|
||||
0F20220626134DA4000C64BF /* HashtagTimelineViewModel+Diffable.swift */,
|
||||
0F20220C26134E3F000C64BF /* HashtagTimelineViewModel+LoadLatestState.swift */,
|
||||
0F202226261411BA000C64BF /* HashtagTimelineViewController+StatusProvider.swift */,
|
||||
0F20222C261457EE000C64BF /* HashtagTimelineViewModel+LoadOldestState.swift */,
|
||||
0F20223226145E51000C64BF /* HashtagTimelineViewModel+LoadMiddleState.swift */,
|
||||
);
|
||||
|
@ -853,6 +852,7 @@
|
|||
2D571B2E26004EC000540450 /* NavigationBarProgressView.swift */,
|
||||
DB87D44A2609C11900D12C0D /* PollOptionView.swift */,
|
||||
DBE3CDCE261C42ED00430CC6 /* TimelineHeaderView.swift */,
|
||||
0F1E2D0A2615C39400C38565 /* DoubleTitleLabelNavigationBarTitleView.swift */,
|
||||
);
|
||||
path = Content;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1510,13 +1510,13 @@
|
|||
DB8AF55525C1379F002E6C99 /* Scene */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0F2021F5261325ED000C64BF /* HashtagTimeline */,
|
||||
5D03938E2612D200007FE196 /* Webview */,
|
||||
2D7631A425C1532200929FB9 /* Share */,
|
||||
DB8AF54E25C13703002E6C99 /* MainTab */,
|
||||
DB01409B25C40BB600F9F3CF /* Onboarding */,
|
||||
2D38F1D325CD463600561493 /* HomeTimeline */,
|
||||
2D76316325C14BAC00929FB9 /* PublicTimeline */,
|
||||
0F2021F5261325ED000C64BF /* HashtagTimeline */,
|
||||
DB9D6BEE25E4F5370051B173 /* Search */,
|
||||
DB9D6BFD25E4F57B0051B173 /* Notification */,
|
||||
DB9D6C0825E4F5A60051B173 /* Profile */,
|
||||
|
@ -2163,7 +2163,7 @@
|
|||
DB68A06325E905E000CFDF14 /* UIApplication.swift in Sources */,
|
||||
DBB5255E2611F07A002F1F29 /* ProfileViewModel.swift in Sources */,
|
||||
2D8434FB25FF46B300EECE90 /* HomeTimelineNavigationBarTitleView.swift in Sources */,
|
||||
0F1E2D0B2615C39400C38565 /* HashtagTimelineTitleView.swift in Sources */,
|
||||
0F1E2D0B2615C39400C38565 /* DoubleTitleLabelNavigationBarTitleView.swift in Sources */,
|
||||
DB9A488A26034D40008B817C /* ComposeViewModel+PublishState.swift in Sources */,
|
||||
DB45FAD725CA6C76005A8AC7 /* UIBarButtonItem.swift in Sources */,
|
||||
2DA504692601ADE7008F4E6C /* SawToothView.swift in Sources */,
|
||||
|
|
|
@ -299,6 +299,10 @@ internal enum L10n {
|
|||
internal static let title = L10n.tr("Localizable", "Scene.ConfirmEmail.OpenEmailApp.Title")
|
||||
}
|
||||
}
|
||||
internal enum Favorite {
|
||||
/// Your Favorites
|
||||
internal static let title = L10n.tr("Localizable", "Scene.Favorite.Title")
|
||||
}
|
||||
internal enum Hashtag {
|
||||
/// %@ people talking
|
||||
internal static func prompt(_ p1: Any) -> String {
|
||||
|
|
|
@ -102,6 +102,7 @@ uploaded to Mastodon.";
|
|||
"Scene.ConfirmEmail.Subtitle" = "We just sent an email to %@,
|
||||
tap the link to confirm your account.";
|
||||
"Scene.ConfirmEmail.Title" = "One last thing.";
|
||||
"Scene.Favorite.Title" = "Your Favorites";
|
||||
"Scene.Hashtag.Prompt" = "%@ people talking";
|
||||
"Scene.HomeTimeline.NavigationBarState.NewPosts" = "See new posts";
|
||||
"Scene.HomeTimeline.NavigationBarState.Offline" = "Offline";
|
||||
|
|
|
@ -41,7 +41,7 @@ class HashtagTimelineViewController: UIViewController, NeedsDependency {
|
|||
|
||||
let refreshControl = UIRefreshControl()
|
||||
|
||||
let titleView = HashtagTimelineNavigationBarTitleView()
|
||||
let titleView = DoubleTitleLabelNavigationBarTitleView()
|
||||
|
||||
deinit {
|
||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s:", ((#file as NSString).lastPathComponent), #line, #function)
|
||||
|
@ -54,7 +54,7 @@ extension HashtagTimelineViewController {
|
|||
super.viewDidLoad()
|
||||
|
||||
title = "#\(viewModel.hashtag)"
|
||||
titleView.updateTitle(hashtag: viewModel.hashtag, peopleNumber: nil)
|
||||
titleView.update(title: viewModel.hashtag, subtitle: nil)
|
||||
navigationItem.titleView = titleView
|
||||
|
||||
view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color
|
||||
|
@ -107,9 +107,6 @@ extension HashtagTimelineViewController {
|
|||
self?.updatePromptTitle()
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
|
@ -142,7 +139,7 @@ extension HashtagTimelineViewController {
|
|||
private func updatePromptTitle() {
|
||||
var subtitle: String?
|
||||
defer {
|
||||
titleView.updateTitle(hashtag: viewModel.hashtag, peopleNumber: subtitle)
|
||||
titleView.update(title: "#" + viewModel.hashtag, subtitle: subtitle)
|
||||
}
|
||||
guard let histories = viewModel.hashtagEntity.value?.history else {
|
||||
return
|
||||
|
@ -158,7 +155,7 @@ extension HashtagTimelineViewController {
|
|||
.prefix(2)
|
||||
.compactMap({ Int($0.accounts) })
|
||||
.reduce(0, +)
|
||||
subtitle = "\(peopleTalkingNumber)"
|
||||
subtitle = L10n.Scene.Hashtag.prompt("\(peopleTalkingNumber)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ final class FavoriteViewController: UIViewController, NeedsDependency {
|
|||
|
||||
var disposeBag = Set<AnyCancellable>()
|
||||
var viewModel: FavoriteViewModel!
|
||||
|
||||
let titleView = DoubleTitleLabelNavigationBarTitleView()
|
||||
|
||||
lazy var tableView: UITableView = {
|
||||
let tableView = UITableView()
|
||||
|
@ -44,6 +46,7 @@ extension FavoriteViewController {
|
|||
super.viewDidLoad()
|
||||
|
||||
view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color
|
||||
navigationItem.titleView = titleView
|
||||
|
||||
tableView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(tableView)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// HashtagTimelineTitleView.swift
|
||||
// DoubleTitleLabelNavigationBarTitleView.swift
|
||||
// Mastodon
|
||||
//
|
||||
// Created by BradGao on 2021/4/1.
|
||||
|
@ -7,7 +7,7 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
final class HashtagTimelineNavigationBarTitleView: UIView {
|
||||
final class DoubleTitleLabelNavigationBarTitleView: UIView {
|
||||
|
||||
let containerView = UIStackView()
|
||||
|
||||
|
@ -40,7 +40,7 @@ final class HashtagTimelineNavigationBarTitleView: UIView {
|
|||
|
||||
}
|
||||
|
||||
extension HashtagTimelineNavigationBarTitleView {
|
||||
extension DoubleTitleLabelNavigationBarTitleView {
|
||||
private func _init() {
|
||||
containerView.axis = .vertical
|
||||
containerView.alignment = .center
|
||||
|
@ -58,10 +58,10 @@ extension HashtagTimelineNavigationBarTitleView {
|
|||
containerView.addArrangedSubview(subtitleLabel)
|
||||
}
|
||||
|
||||
func updateTitle(hashtag: String, peopleNumber: String?) {
|
||||
titleLabel.text = "#\(hashtag)"
|
||||
if let peopleNumebr = peopleNumber {
|
||||
subtitleLabel.text = L10n.Scene.Hashtag.prompt(peopleNumebr)
|
||||
func update(title: String, subtitle: String?) {
|
||||
titleLabel.text = title
|
||||
if let subtitle = subtitle {
|
||||
subtitleLabel.text = subtitle
|
||||
subtitleLabel.isHidden = false
|
||||
} else {
|
||||
subtitleLabel.text = nil
|
||||
|
@ -69,3 +69,21 @@ extension HashtagTimelineNavigationBarTitleView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if canImport(SwiftUI) && DEBUG
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct DoubleTitleLabelNavigationBarTitleView_Previews: PreviewProvider {
|
||||
|
||||
static var previews: some View {
|
||||
UIViewPreview(width: 375) {
|
||||
DoubleTitleLabelNavigationBarTitleView()
|
||||
}
|
||||
.previewLayout(.fixed(width: 375, height: 100))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue