mirror of
https://github.com/metabolist/metatext.git
synced 2025-04-15 16:24:10 +00:00
Merge branch 'develop' into edge-to-edge
This commit is contained in:
commit
4990604b19
7 changed files with 170 additions and 36 deletions
|
@ -255,7 +255,7 @@
|
|||
"preferences.require-double-tap-to-favorite" = "Require double tap to favorite";
|
||||
"preferences.show-reblog-and-favorite-counts" = "Show boost and favorite counts";
|
||||
"preferences.status-word" = "Status word";
|
||||
"preferences.favorite-word" = "Favorite word";
|
||||
"preferences.display-favorites-as" = "Display favorites as";
|
||||
"filters.active" = "Active";
|
||||
"filters.expired" = "Expired";
|
||||
"filter.add-new" = "Add New Filter";
|
||||
|
@ -315,8 +315,11 @@
|
|||
"status.delete.confirm.post" = "Are you sure you want to delete this post?";
|
||||
"status.delete.confirm.toot" = "Are you sure you want to delete this toot?";
|
||||
"status.delete-and-redraft" = "Delete & re-draft";
|
||||
"status.delete-and-redraft.confirm.post" = "Are you sure you want to delete this post and re-draft it? Favorites and boosts will be lost, and replies to the original post will be orphaned.";
|
||||
"status.delete-and-redraft.confirm.toot" = "Are you sure you want to delete this toot and re-draft it? Favorites and boosts will be lost, and replies to the original toot will be orphaned.";
|
||||
"status.delete-and-redraft.confirm.post-favorites" = "Are you sure you want to delete this post and re-draft it? Favorites and boosts will be lost, and replies to the original post will be orphaned.";
|
||||
"status.delete-and-redraft.confirm.toot-favorites" = "Are you sure you want to delete this toot and re-draft it? Favorites and boosts will be lost, and replies to the original toot will be orphaned.";
|
||||
"status.delete-and-redraft.confirm.post-likes" = "Are you sure you want to delete this post and re-draft it? Likes and boosts will be lost, and replies to the original post will be orphaned.";
|
||||
"status.delete-and-redraft.confirm.toot-likes" = "Are you sure you want to delete this toot and re-draft it? Likes and boosts will be lost, and replies to the original toot will be orphaned.";
|
||||
|
||||
"status.mute" = "Mute conversation";
|
||||
"status.new-items.post" = "New posts";
|
||||
"status.new-items.toot" = "New toots";
|
||||
|
@ -335,6 +338,8 @@
|
|||
"status.reblog-button.undo.accessibility-label" = "Unboost";
|
||||
"status.favorite-button.accessibility-label" = "Favorite";
|
||||
"status.favorite-button.undo.accessibility-label" = "Unfavorite";
|
||||
"status.like-button.accessibility-label" = "Like";
|
||||
"status.like-button.undo.accessibility-label" = "Unlike";
|
||||
"status.show-more" = "Show More";
|
||||
"status.show-more-all-button.accessibilty-label" = "Show more for all";
|
||||
"status.show-less" = "Show Less";
|
||||
|
@ -360,3 +365,4 @@
|
|||
"timelines.local" = "Local";
|
||||
"timelines.federated" = "Federated";
|
||||
"toot" = "Toot";
|
||||
"likes" = "Likes";
|
||||
|
|
|
@ -66,6 +66,22 @@
|
|||
<string>%ld Favorites</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>status.likes-count-%ld</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@likes@</string>
|
||||
<key>likes</key>
|
||||
<dict>
|
||||
<key>NSStringFormatSpecTypeKey</key>
|
||||
<string>NSStringPluralRuleType</string>
|
||||
<key>NSStringFormatValueTypeKey</key>
|
||||
<string>ld</string>
|
||||
<key>one</key>
|
||||
<string>%ld Like</string>
|
||||
<key>other</key>
|
||||
<string>%ld Likes</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>status.replies-count-%ld</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
|
|
|
@ -32,10 +32,9 @@ public extension AppPreferences {
|
|||
public var id: String { rawValue }
|
||||
}
|
||||
|
||||
enum FavoriteWord: String, CaseIterable, Identifiable {
|
||||
case favorite
|
||||
case favourite
|
||||
case like
|
||||
enum DisplayFavoritesAs: String, CaseIterable, Identifiable {
|
||||
case favorites
|
||||
case likes
|
||||
|
||||
public var id: String { rawValue }
|
||||
}
|
||||
|
@ -87,16 +86,16 @@ public extension AppPreferences {
|
|||
set { self[.statusWord] = newValue.rawValue }
|
||||
}
|
||||
|
||||
var favoriteWord: FavoriteWord {
|
||||
var displayFavoritesAs: DisplayFavoritesAs {
|
||||
get {
|
||||
if let rawValue = self[.favoriteWord] as String?,
|
||||
let value = FavoriteWord(rawValue: rawValue) {
|
||||
if let rawValue = self[.displayFavoritesAs] as String?,
|
||||
let value = DisplayFavoritesAs(rawValue: rawValue) {
|
||||
return value
|
||||
}
|
||||
|
||||
return .favorite
|
||||
return .favorites
|
||||
}
|
||||
set { self[.favoriteWord] = newValue.rawValue }
|
||||
set { self[.displayFavoritesAs] = newValue.rawValue }
|
||||
}
|
||||
|
||||
var animateAvatars: AnimateAvatars {
|
||||
|
@ -232,7 +231,7 @@ private extension AppPreferences {
|
|||
enum Item: String {
|
||||
case colorScheme
|
||||
case statusWord
|
||||
case favoriteWord
|
||||
case displayFavoritesAs
|
||||
case requireDoubleTapToReblog
|
||||
case requireDoubleTapToFavorite
|
||||
case animateAvatars
|
||||
|
|
|
@ -687,12 +687,17 @@ private extension TableViewController {
|
|||
let deleteAndRedraftConfirmMessage: String
|
||||
let deleteConfirmMessage: String
|
||||
|
||||
let favoritesNoun = viewModel.identityContext.appPreferences.displayFavoritesAs.rawValue
|
||||
|
||||
switch viewModel.identityContext.appPreferences.statusWord {
|
||||
case .toot:
|
||||
deleteAndRedraftConfirmMessage = NSLocalizedString("status.delete-and-redraft.confirm.toot", comment: "")
|
||||
deleteAndRedraftConfirmMessage = NSLocalizedString(
|
||||
"status.delete-and-redraft.confirm.toot-".appending(favoritesNoun),
|
||||
comment: "")
|
||||
deleteConfirmMessage = NSLocalizedString("status.delete.confirm.toot", comment: "")
|
||||
case .post:
|
||||
deleteAndRedraftConfirmMessage = NSLocalizedString("status.delete-and-redraft.confirm.post", comment: "")
|
||||
deleteAndRedraftConfirmMessage = NSLocalizedString(
|
||||
"status.delete-and-redraft.confirm.post-".appending(favoritesNoun), comment: "")
|
||||
deleteConfirmMessage = NSLocalizedString("status.delete.confirm.post", comment: "")
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,12 @@ struct PreferencesView: View {
|
|||
}
|
||||
Toggle("preferences.edge-to-edge-view",
|
||||
isOn: $identityContext.appPreferences.edgeToEdgeView)
|
||||
Picker("preferences.display-favorites-as",
|
||||
selection: $identityContext.appPreferences.displayFavoritesAs) {
|
||||
ForEach(AppPreferences.DisplayFavoritesAs.allCases) { option in
|
||||
Text(option.localizedStringKey).tag(option)
|
||||
}
|
||||
}
|
||||
Toggle("preferences.show-reblog-and-favorite-counts",
|
||||
isOn: $identityContext.appPreferences.showReblogAndFavoriteCounts)
|
||||
Toggle("preferences.require-double-tap-to-reblog",
|
||||
|
@ -184,6 +190,17 @@ extension AppPreferences.StatusWord {
|
|||
}
|
||||
}
|
||||
|
||||
extension AppPreferences.DisplayFavoritesAs {
|
||||
var localizedStringKey: LocalizedStringKey {
|
||||
switch self {
|
||||
case .favorites:
|
||||
return "favorites"
|
||||
case .likes:
|
||||
return "likes"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension AppPreferences.AnimateAvatars {
|
||||
var localizedStringKey: LocalizedStringKey {
|
||||
switch self {
|
||||
|
|
|
@ -163,9 +163,36 @@ private extension NotificationView {
|
|||
isAccessibilityElement = true
|
||||
}
|
||||
|
||||
var colorForFavoriteView: UIColor {
|
||||
switch notificationConfiguration.viewModel.identityContext.appPreferences.displayFavoritesAs {
|
||||
case .favorites:
|
||||
return .systemYellow
|
||||
case .likes:
|
||||
return .systemRed
|
||||
}
|
||||
}
|
||||
|
||||
var labelForFavoriteView: String {
|
||||
switch notificationConfiguration.viewModel.identityContext.appPreferences.displayFavoritesAs {
|
||||
case .favorites:
|
||||
return "notifications.favourited-your-status-%@"
|
||||
case .likes:
|
||||
return "notifications.liked-your-status-%@"
|
||||
}
|
||||
}
|
||||
|
||||
var imageNameForFavoriteView: String {
|
||||
switch notificationConfiguration.viewModel.identityContext.appPreferences.displayFavoritesAs {
|
||||
case .favorites:
|
||||
return "star.fill"
|
||||
case .likes:
|
||||
return "heart.fill"
|
||||
}
|
||||
}
|
||||
|
||||
func applyNotificationConfiguration() {
|
||||
let viewModel = notificationConfiguration.viewModel
|
||||
|
||||
var imageName = viewModel.type.systemImageName
|
||||
avatarImageView.sd_setImage(with: viewModel.accountViewModel.avatarURL())
|
||||
|
||||
switch viewModel.type {
|
||||
|
@ -184,12 +211,13 @@ private extension NotificationView {
|
|||
identityContext: viewModel.identityContext)
|
||||
iconImageView.tintColor = .systemGreen
|
||||
case .favourite:
|
||||
typeLabel.attributedText = "notifications.favourited-your-status-%@".localizedBolding(
|
||||
imageName = imageNameForFavoriteView
|
||||
typeLabel.attributedText = labelForFavoriteView.localizedBolding(
|
||||
displayName: viewModel.accountViewModel.displayName,
|
||||
emojis: viewModel.accountViewModel.emojis,
|
||||
label: typeLabel,
|
||||
identityContext: viewModel.identityContext)
|
||||
iconImageView.tintColor = .systemYellow
|
||||
iconImageView.tintColor = colorForFavoriteView
|
||||
case .poll:
|
||||
typeLabel.text = NSLocalizedString(
|
||||
viewModel.accountViewModel.isSelf
|
||||
|
@ -229,7 +257,7 @@ private extension NotificationView {
|
|||
timeLabel.accessibilityLabel = viewModel.accessibilityTime
|
||||
|
||||
iconImageView.image = UIImage(
|
||||
systemName: viewModel.type.systemImageName,
|
||||
systemName: imageName,
|
||||
withConfiguration: UIImage.SymbolConfiguration(scale: .medium))
|
||||
|
||||
let accessibilityAttributedLabel = NSMutableAttributedString(string: "")
|
||||
|
|
|
@ -464,6 +464,15 @@ private extension StatusView {
|
|||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
var favoriteCountLabel: String {
|
||||
switch statusConfiguration.viewModel.identityContext.appPreferences.displayFavoritesAs {
|
||||
case .favorites:
|
||||
return "status.favorites-count-%ld"
|
||||
case .likes:
|
||||
return "status.likes-count-%ld"
|
||||
}
|
||||
}
|
||||
|
||||
func applyStatusConfiguration() {
|
||||
let viewModel = statusConfiguration.viewModel
|
||||
let isContextParent = viewModel.configuration.isContextParent
|
||||
|
@ -611,8 +620,9 @@ private extension StatusView {
|
|||
localizationKey: "status.reblogs-count-%ld",
|
||||
count: viewModel.reblogsCount)
|
||||
rebloggedByButton.isHidden = noReblogs
|
||||
|
||||
favoritedByButton.setAttributedLocalizedTitle(
|
||||
localizationKey: "status.favorites-count-%ld",
|
||||
localizationKey: favoriteCountLabel,
|
||||
count: viewModel.favoritesCount)
|
||||
favoritedByButton.isHidden = noFavorites
|
||||
|
||||
|
@ -840,7 +850,7 @@ private extension StatusView {
|
|||
if statusConfiguration.viewModel.favoritesCount > 0 {
|
||||
accessibilityAttributedLabel.appendWithSeparator(
|
||||
String.localizedStringWithFormat(
|
||||
NSLocalizedString("status.favorites-count-%ld", comment: ""),
|
||||
NSLocalizedString(favoriteCountLabel, comment: ""),
|
||||
statusConfiguration.viewModel.favoritesCount))
|
||||
}
|
||||
}
|
||||
|
@ -853,10 +863,24 @@ private extension StatusView {
|
|||
return accessibilityAttributedLabel
|
||||
}
|
||||
|
||||
var favoriteIcon: String {
|
||||
switch statusConfiguration.viewModel.identityContext.appPreferences.displayFavoritesAs {
|
||||
case .favorites: return "star"
|
||||
case .likes: return "heart"
|
||||
}
|
||||
}
|
||||
|
||||
var favoritedIcon: String {
|
||||
switch statusConfiguration.viewModel.identityContext.appPreferences.displayFavoritesAs {
|
||||
case .favorites: return "star.fill"
|
||||
case .likes: return "heart.fill"
|
||||
}
|
||||
}
|
||||
|
||||
func setButtonImages(font: UIFont) {
|
||||
let visibility = statusConfiguration.viewModel.visibility
|
||||
let reblogSystemImageName: String
|
||||
|
||||
let isFavorited = statusConfiguration.viewModel.favorited
|
||||
if statusConfiguration.viewModel.configuration.isContextParent {
|
||||
reblogSystemImageName = "arrow.2.squarepath"
|
||||
} else {
|
||||
|
@ -876,7 +900,7 @@ private extension StatusView {
|
|||
pointSize: font.pointSize,
|
||||
weight: statusConfiguration.viewModel.reblogged ? .bold : .regular)),
|
||||
for: .normal)
|
||||
favoriteButton.setImage(UIImage(systemName: statusConfiguration.viewModel.favorited ? "star.fill" : "star",
|
||||
favoriteButton.setImage(UIImage(systemName: isFavorited ? favoritedIcon : favoriteIcon,
|
||||
withConfiguration: UIImage.SymbolConfiguration(pointSize: font.pointSize)),
|
||||
for: .normal)
|
||||
shareButton.setImage(UIImage(systemName: "square.and.arrow.up",
|
||||
|
@ -923,17 +947,29 @@ private extension StatusView {
|
|||
}
|
||||
|
||||
func setFavoriteButtonColor(favorited: Bool) {
|
||||
let favoriteColor: UIColor = favorited ? .systemYellow : .secondaryLabel
|
||||
var favoriteColor: UIColor
|
||||
var favoriteLabel: String
|
||||
var undoFavoriteLabel: String
|
||||
switch statusConfiguration.viewModel.identityContext.appPreferences.displayFavoritesAs {
|
||||
case .favorites:
|
||||
favoriteColor = favorited ? .systemYellow : .secondaryLabel
|
||||
favoriteLabel = "status.favorite-button.undo.accessibility-label"
|
||||
undoFavoriteLabel = "status.favorite-button.accessibility-label"
|
||||
case .likes:
|
||||
favoriteColor = favorited ? .systemRed : .secondaryLabel
|
||||
favoriteLabel = "status.like-button.undo.accessibility-label"
|
||||
undoFavoriteLabel = "status.like-button.accessibility-label"
|
||||
}
|
||||
|
||||
favoriteButton.tintColor = favoriteColor
|
||||
favoriteButton.setTitleColor(favoriteColor, for: .normal)
|
||||
|
||||
if favorited {
|
||||
favoriteButton.accessibilityLabel =
|
||||
NSLocalizedString("status.favorite-button.undo.accessibility-label", comment: "")
|
||||
NSLocalizedString(undoFavoriteLabel, comment: "")
|
||||
} else {
|
||||
favoriteButton.accessibilityLabel =
|
||||
NSLocalizedString("status.favorite-button.accessibility-label", comment: "")
|
||||
NSLocalizedString(favoriteLabel, comment: "")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -956,20 +992,47 @@ private extension StatusView {
|
|||
statusConfiguration.viewModel.toggleReblogged()
|
||||
}
|
||||
|
||||
func animateFavorite() {
|
||||
switch statusConfiguration.viewModel.identityContext.appPreferences.displayFavoritesAs {
|
||||
|
||||
case .favorites:
|
||||
self.animateAsFavorite()
|
||||
case .likes:
|
||||
self.animateAsLike()
|
||||
}
|
||||
}
|
||||
|
||||
func animateAsFavorite() {
|
||||
UIViewPropertyAnimator.runningPropertyAnimator(
|
||||
withDuration: .defaultAnimationDuration,
|
||||
delay: 0,
|
||||
options: .curveLinear) {
|
||||
self.setFavoriteButtonColor(favorited: !self.statusConfiguration.viewModel.favorited)
|
||||
self.favoriteButton.imageView?.transform =
|
||||
self.favoriteButton.imageView?.transform.rotated(by: .pi) ?? .identity
|
||||
} completion: { _ in
|
||||
self.favoriteButton.imageView?.transform = .identity
|
||||
}
|
||||
}
|
||||
|
||||
func animateAsLike() {
|
||||
UIViewPropertyAnimator.runningPropertyAnimator(
|
||||
withDuration: .defaultAnimationDuration,
|
||||
delay: 0,
|
||||
options: .curveEaseInOut) {
|
||||
self.setFavoriteButtonColor(favorited: !self.statusConfiguration.viewModel.favorited)
|
||||
self.favoriteButton.imageView?.transform =
|
||||
self.favoriteButton.imageView?.transform.scaledBy(x: 0.7, y: 0.7) ?? .identity
|
||||
} completion: { _ in
|
||||
self.favoriteButton.imageView?.transform = .identity
|
||||
}
|
||||
}
|
||||
|
||||
func favorite() {
|
||||
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
|
||||
|
||||
if !UIAccessibility.isReduceMotionEnabled {
|
||||
UIViewPropertyAnimator.runningPropertyAnimator(
|
||||
withDuration: .defaultAnimationDuration,
|
||||
delay: 0,
|
||||
options: .curveLinear) {
|
||||
self.setFavoriteButtonColor(favorited: !self.statusConfiguration.viewModel.favorited)
|
||||
self.favoriteButton.imageView?.transform =
|
||||
self.favoriteButton.imageView?.transform.rotated(by: .pi) ?? .identity
|
||||
} completion: { _ in
|
||||
self.favoriteButton.imageView?.transform = .identity
|
||||
}
|
||||
self.animateFavorite()
|
||||
}
|
||||
|
||||
statusConfiguration.viewModel.toggleFavorited()
|
||||
|
|
Loading…
Reference in a new issue