Render views count on replies & views button where appropriate
This commit is contained in:
parent
3a1741cedf
commit
20e8b69723
@ -102,7 +102,7 @@ class StoryContextViewController: OWSViewController {
|
||||
|
||||
playbackProgressView.alpha = 1
|
||||
closeButton.alpha = 1
|
||||
replyButton.alpha = 1
|
||||
repliesAndViewsButton.alpha = 1
|
||||
}
|
||||
|
||||
func updateMuteState() {
|
||||
@ -138,7 +138,7 @@ class StoryContextViewController: OWSViewController {
|
||||
private lazy var closeButton = OWSButton(imageName: "x-24", tintColor: .ows_white)
|
||||
|
||||
private lazy var mediaViewContainer = UIView()
|
||||
private lazy var replyButton = OWSFlatButton()
|
||||
private lazy var repliesAndViewsButton = OWSFlatButton()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
@ -156,13 +156,13 @@ class StoryContextViewController: OWSViewController {
|
||||
|
||||
view.addSubview(mediaViewContainer)
|
||||
|
||||
replyButton.setPressedBlock { [weak self] in self?.presentRepliesAndViewsSheet() }
|
||||
replyButton.setBackgroundColors(upColor: .clear)
|
||||
replyButton.autoSetDimension(.height, toSize: 64)
|
||||
replyButton.setTitleColor(Theme.darkThemePrimaryColor)
|
||||
view.addSubview(replyButton)
|
||||
replyButton.autoPinEdge(.leading, to: .leading, of: mediaViewContainer)
|
||||
replyButton.autoPinEdge(.trailing, to: .trailing, of: mediaViewContainer)
|
||||
repliesAndViewsButton.setPressedBlock { [weak self] in self?.presentRepliesAndViewsSheet() }
|
||||
repliesAndViewsButton.setBackgroundColors(upColor: .clear)
|
||||
repliesAndViewsButton.autoSetDimension(.height, toSize: 64)
|
||||
repliesAndViewsButton.setTitleColor(Theme.darkThemePrimaryColor)
|
||||
view.addSubview(repliesAndViewsButton)
|
||||
repliesAndViewsButton.autoPinEdge(.leading, to: .leading, of: mediaViewContainer)
|
||||
repliesAndViewsButton.autoPinEdge(.trailing, to: .trailing, of: mediaViewContainer)
|
||||
|
||||
view.addSubview(playbackProgressView)
|
||||
playbackProgressView.autoPinEdge(.leading, to: .leading, of: mediaViewContainer, withOffset: OWSTableViewController2.defaultHOuterMargin)
|
||||
@ -174,12 +174,12 @@ class StoryContextViewController: OWSViewController {
|
||||
// iPhone with notch or iPad (views/replies rendered below media, media is in a card)
|
||||
mediaViewContainer.layer.cornerRadius = 18
|
||||
mediaViewContainer.clipsToBounds = true
|
||||
replyButton.autoPinEdge(.top, to: .bottom, of: mediaViewContainer)
|
||||
playbackProgressView.autoPinEdge(.bottom, to: .top, of: replyButton, withOffset: -OWSTableViewController2.defaultHOuterMargin)
|
||||
repliesAndViewsButton.autoPinEdge(.top, to: .bottom, of: mediaViewContainer)
|
||||
playbackProgressView.autoPinEdge(.bottom, to: .top, of: repliesAndViewsButton, withOffset: -OWSTableViewController2.defaultHOuterMargin)
|
||||
} else {
|
||||
// iPhone with home button (views/replies rendered on top of media, media is fullscreen)
|
||||
replyButton.autoPinEdge(.bottom, to: .bottom, of: mediaViewContainer)
|
||||
playbackProgressView.autoPinEdge(.bottom, to: .top, of: replyButton)
|
||||
repliesAndViewsButton.autoPinEdge(.bottom, to: .bottom, of: mediaViewContainer)
|
||||
playbackProgressView.autoPinEdge(.bottom, to: .top, of: repliesAndViewsButton)
|
||||
mediaViewContainer.autoPinEdge(toSuperviewSafeArea: .bottom)
|
||||
}
|
||||
|
||||
@ -270,30 +270,47 @@ class StoryContextViewController: OWSViewController {
|
||||
itemView.autoPinEdgesToSuperviewEdges()
|
||||
|
||||
if currentItem.message.localUserAllowedToReply {
|
||||
replyButton.isHidden = false
|
||||
repliesAndViewsButton.isHidden = false
|
||||
|
||||
let replyButtonText: String
|
||||
switch currentItem.numberOfReplies {
|
||||
case 0:
|
||||
replyButtonText = NSLocalizedString("STORY_REPLY_BUTTON_WITH_NO_REPLIES", comment: "Button for replying to a story with no existing replies.")
|
||||
case 1:
|
||||
replyButtonText = NSLocalizedString("STORY_REPLY_BUTTON_WITH_1_REPLY", comment: "Button for replying to a story with a single existing reply.")
|
||||
default:
|
||||
let format = NSLocalizedString("STORY_REPLY_BUTTON_WITH_N_REPLIES_FORMAT", comment: "Button for replying to a story with N existing replies. {embeds the number of replies}")
|
||||
replyButtonText = String(format: format, "\(currentItem.numberOfReplies)")
|
||||
let repliesAndViewsButtonText: String
|
||||
|
||||
switch currentItem.message.direction {
|
||||
case .incoming:
|
||||
if currentItem.numberOfReplies == 0 {
|
||||
repliesAndViewsButtonText = NSLocalizedString(
|
||||
"STORY_REPLY_BUTTON_WITH_NO_REPLIES",
|
||||
comment: "Button for replying to a story with no existing replies.")
|
||||
} else {
|
||||
let format = NSLocalizedString(
|
||||
"STORY_REPLIES_COUNT_%d",
|
||||
tableName: "PluralAware",
|
||||
comment: "Button for replying to a story with N existing replies.")
|
||||
repliesAndViewsButtonText = String(format: format, currentItem.numberOfReplies)
|
||||
}
|
||||
case .outgoing:
|
||||
if case .groupId = context {
|
||||
let format = NSLocalizedString(
|
||||
"STORY_VIEWS_AND_REPLIES_COUNT_%d_%d",
|
||||
tableName: "PluralAware",
|
||||
comment: "Button for viewing the replies and views for a story sent to a group")
|
||||
repliesAndViewsButtonText = String(format: format, currentItem.message.remoteViewCount, currentItem.numberOfReplies)
|
||||
} else {
|
||||
let format = NSLocalizedString(
|
||||
"STORY_VIEWS_COUNT_%d",
|
||||
tableName: "PluralAware",
|
||||
comment: "Button for viewing the views for a story sent to a private list")
|
||||
repliesAndViewsButtonText = String(format: format, currentItem.message.remoteViewCount)
|
||||
}
|
||||
}
|
||||
|
||||
let semiboldStyle = StringStyle(.font(.systemFont(ofSize: 17, weight: .semibold)))
|
||||
let attributedReplyButtonText = replyButtonText.styled(
|
||||
with: .font(.systemFont(ofSize: 17, weight: .regular)),
|
||||
.xmlRules([.style("bold", semiboldStyle)])
|
||||
)
|
||||
replyButton.setAttributedTitle(attributedReplyButtonText)
|
||||
repliesAndViewsButton.setAttributedTitle(repliesAndViewsButtonText.styled(with: .font(.systemFont(ofSize: 17, weight: .regular)),
|
||||
.xmlRules([.style("bold", semiboldStyle)])))
|
||||
} else {
|
||||
replyButton.isHidden = true
|
||||
repliesAndViewsButton.isHidden = true
|
||||
}
|
||||
} else {
|
||||
replyButton.isHidden = true
|
||||
repliesAndViewsButton.isHidden = true
|
||||
}
|
||||
|
||||
if messageDidChange { updateProgressState() }
|
||||
@ -464,7 +481,7 @@ extension StoryContextViewController: UIGestureRecognizerDelegate {
|
||||
if hideChrome {
|
||||
self.playbackProgressView.alpha = 0
|
||||
self.closeButton.alpha = 0
|
||||
self.replyButton.alpha = 0
|
||||
self.repliesAndViewsButton.alpha = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -478,7 +495,7 @@ extension StoryContextViewController: UIGestureRecognizerDelegate {
|
||||
currentItemMediaView?.play {
|
||||
self.playbackProgressView.alpha = 1
|
||||
self.closeButton.alpha = 1
|
||||
self.replyButton.alpha = 1
|
||||
self.repliesAndViewsButton.alpha = 1
|
||||
}
|
||||
delegate?.storyContextViewControllerDidResume(self)
|
||||
}
|
||||
|
||||
@ -6199,12 +6199,6 @@
|
||||
/* Button to access the story privacy settings menu */
|
||||
"STORY_PRIVACY_SETTINGS" = "Privacy";
|
||||
|
||||
/* Button for replying to a story with a single existing reply. */
|
||||
"STORY_REPLY_BUTTON_WITH_1_REPLY" = "<bold>1</bold> reply";
|
||||
|
||||
/* Button for replying to a story with N existing replies. {embeds the number of replies} */
|
||||
"STORY_REPLY_BUTTON_WITH_N_REPLIES_FORMAT" = "<bold>%@</bold> replies";
|
||||
|
||||
/* Button for replying to a story with no existing replies. */
|
||||
"STORY_REPLY_BUTTON_WITH_NO_REPLIES" = "Reply";
|
||||
|
||||
|
||||
@ -1053,6 +1053,22 @@
|
||||
<string>You have %d attempts remaining. If you run out of attempts your account will be locked. After 7 days of inactivity, you can re-register without your PIN. Your account will be wiped and all content deleted.</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>STORY_REPLIES_COUNT_%d</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@caption@</string>
|
||||
<key>caption</key>
|
||||
<dict>
|
||||
<key>NSStringFormatSpecTypeKey</key>
|
||||
<string>NSStringPluralRuleType</string>
|
||||
<key>NSStringFormatValueTypeKey</key>
|
||||
<string>d</string>
|
||||
<key>one</key>
|
||||
<string><bold>1</bold> reply</string>
|
||||
<key>other</key>
|
||||
<string><bold>%d</bold> replies</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>STORY_SELECT_ALLOWED_CONNECTIONS_VIEW_TITLE_%d</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
@ -1085,6 +1101,49 @@
|
||||
<string>%d Excluded</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>STORY_VIEWS_COUNT_%d</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@caption@</string>
|
||||
<key>caption</key>
|
||||
<dict>
|
||||
<key>NSStringFormatSpecTypeKey</key>
|
||||
<string>NSStringPluralRuleType</string>
|
||||
<key>NSStringFormatValueTypeKey</key>
|
||||
<string>d</string>
|
||||
<key>one</key>
|
||||
<string><bold>1</bold> view</string>
|
||||
<key>other</key>
|
||||
<string><bold>%d</bold> views</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>STORY_VIEWS_AND_REPLIES_COUNT_%d_%d</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%1$#@views@ %2$#@replies@</string>
|
||||
<key>views</key>
|
||||
<dict>
|
||||
<key>NSStringFormatSpecTypeKey</key>
|
||||
<string>NSStringPluralRuleType</string>
|
||||
<key>NSStringFormatValueTypeKey</key>
|
||||
<string>d</string>
|
||||
<key>one</key>
|
||||
<string><bold>1</bold> view</string>
|
||||
<key>other</key>
|
||||
<string><bold>%d</bold> views</string>
|
||||
</dict>
|
||||
<key>replies</key>
|
||||
<dict>
|
||||
<key>NSStringFormatSpecTypeKey</key>
|
||||
<string>NSStringPluralRuleType</string>
|
||||
<key>NSStringFormatValueTypeKey</key>
|
||||
<string>d</string>
|
||||
<key>one</key>
|
||||
<string><bold>1</bold> reply</string>
|
||||
<key>other</key>
|
||||
<string><bold>%d</bold> replies</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>THREAD_DETAILS_MORE_MUTUAL_GROUP_%d</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user