Haptic feedback & double-tap settings
This commit is contained in:
parent
aad592e01a
commit
c421da9a48
|
@ -157,6 +157,8 @@
|
||||||
"preferences.position.remember-position" = "Remember position";
|
"preferences.position.remember-position" = "Remember position";
|
||||||
"preferences.position.sync-position" = "Sync position with web and other devices";
|
"preferences.position.sync-position" = "Sync position with web and other devices";
|
||||||
"preferences.position.newest" = "Load newest";
|
"preferences.position.newest" = "Load newest";
|
||||||
|
"preferences.require-double-tap-to-reblog" = "Require double tap to reblog";
|
||||||
|
"preferences.require-double-tap-to-favorite" = "Require double tap to favorite";
|
||||||
"preferences.show-reblog-and-favorite-counts" = "Show reblog and favorite counts";
|
"preferences.show-reblog-and-favorite-counts" = "Show reblog and favorite counts";
|
||||||
"preferences.status-word" = "Status word";
|
"preferences.status-word" = "Status word";
|
||||||
"filters.active" = "Active";
|
"filters.active" = "Active";
|
||||||
|
|
|
@ -157,11 +157,23 @@ public extension AppPreferences {
|
||||||
get { self[.showReblogAndFavoriteCounts] ?? false }
|
get { self[.showReblogAndFavoriteCounts] ?? false }
|
||||||
set { self[.showReblogAndFavoriteCounts] = newValue }
|
set { self[.showReblogAndFavoriteCounts] = newValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var requireDoubleTapToReblog: Bool {
|
||||||
|
get { self[.requireDoubleTapToReblog] ?? false }
|
||||||
|
set { self[.requireDoubleTapToReblog] = newValue }
|
||||||
|
}
|
||||||
|
|
||||||
|
var requireDoubleTapToFavorite: Bool {
|
||||||
|
get { self[.requireDoubleTapToFavorite] ?? false }
|
||||||
|
set { self[.requireDoubleTapToFavorite] = newValue }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension AppPreferences {
|
private extension AppPreferences {
|
||||||
enum Item: String {
|
enum Item: String {
|
||||||
case statusWord
|
case statusWord
|
||||||
|
case requireDoubleTapToReblog
|
||||||
|
case requireDoubleTapToFavorite
|
||||||
case useSystemReduceMotionForMedia
|
case useSystemReduceMotionForMedia
|
||||||
case animateAvatars
|
case animateAvatars
|
||||||
case animateHeaders
|
case animateHeaders
|
||||||
|
|
|
@ -69,6 +69,10 @@ struct PreferencesView: View {
|
||||||
Text(option.localizedStringKey).tag(option)
|
Text(option.localizedStringKey).tag(option)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Toggle("preferences.require-double-tap-to-reblog",
|
||||||
|
isOn: $identityContext.appPreferences.requireDoubleTapToReblog)
|
||||||
|
Toggle("preferences.require-double-tap-to-favorite",
|
||||||
|
isOn: $identityContext.appPreferences.requireDoubleTapToFavorite)
|
||||||
if accessibilityReduceMotion {
|
if accessibilityReduceMotion {
|
||||||
Toggle("preferences.media.use-system-reduce-motion",
|
Toggle("preferences.media.use-system-reduce-motion",
|
||||||
isOn: $identityContext.appPreferences.useSystemReduceMotionForMedia)
|
isOn: $identityContext.appPreferences.useSystemReduceMotionForMedia)
|
||||||
|
|
|
@ -245,13 +245,29 @@ private extension StatusView {
|
||||||
for: .touchUpInside)
|
for: .touchUpInside)
|
||||||
|
|
||||||
reblogButton.addAction(
|
reblogButton.addAction(
|
||||||
UIAction { [weak self] _ in self?.statusConfiguration.viewModel.toggleReblogged() },
|
UIAction { [weak self] _ in
|
||||||
|
guard let self = self,
|
||||||
|
!self.statusConfiguration.viewModel.identityContext.appPreferences.requireDoubleTapToReblog
|
||||||
|
else { return }
|
||||||
|
|
||||||
|
self.reblog()
|
||||||
|
},
|
||||||
for: .touchUpInside)
|
for: .touchUpInside)
|
||||||
|
|
||||||
|
reblogButton.addTarget(self, action: #selector(reblogButtonDoubleTap(sender:event:)), for: .touchDownRepeat)
|
||||||
|
|
||||||
favoriteButton.addAction(
|
favoriteButton.addAction(
|
||||||
UIAction { [weak self] _ in self?.statusConfiguration.viewModel.toggleFavorited() },
|
UIAction { [weak self] _ in
|
||||||
|
guard let self = self,
|
||||||
|
!self.statusConfiguration.viewModel.identityContext.appPreferences.requireDoubleTapToFavorite
|
||||||
|
else { return }
|
||||||
|
|
||||||
|
self.favorite()
|
||||||
|
},
|
||||||
for: .touchUpInside)
|
for: .touchUpInside)
|
||||||
|
|
||||||
|
favoriteButton.addTarget(self, action: #selector(favoriteButtonDoubleTap(sender:event:)), for: .touchDownRepeat)
|
||||||
|
|
||||||
shareButton.addAction(
|
shareButton.addAction(
|
||||||
UIAction { [weak self] _ in self?.statusConfiguration.viewModel.shareStatus() },
|
UIAction { [weak self] _ in self?.statusConfiguration.viewModel.shareStatus() },
|
||||||
for: .touchUpInside)
|
for: .touchUpInside)
|
||||||
|
@ -534,6 +550,38 @@ private extension StatusView {
|
||||||
menuButton.setImage(UIImage(systemName: "ellipsis",
|
menuButton.setImage(UIImage(systemName: "ellipsis",
|
||||||
withConfiguration: UIImage.SymbolConfiguration(scale: scale)), for: .normal)
|
withConfiguration: UIImage.SymbolConfiguration(scale: scale)), for: .normal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func reblogButtonDoubleTap(sender: UIButton, event: UIEvent) {
|
||||||
|
guard
|
||||||
|
statusConfiguration.viewModel.identityContext.appPreferences.requireDoubleTapToReblog,
|
||||||
|
event.allTouches?.first?.tapCount == 2 else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
reblog()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func favoriteButtonDoubleTap(sender: UIButton, event: UIEvent) {
|
||||||
|
guard
|
||||||
|
statusConfiguration.viewModel.identityContext.appPreferences.requireDoubleTapToFavorite,
|
||||||
|
event.allTouches?.first?.tapCount == 2 else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
favorite()
|
||||||
|
}
|
||||||
|
|
||||||
|
func reblog() {
|
||||||
|
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
|
||||||
|
|
||||||
|
statusConfiguration.viewModel.toggleReblogged()
|
||||||
|
}
|
||||||
|
|
||||||
|
func favorite() {
|
||||||
|
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
|
||||||
|
|
||||||
|
statusConfiguration.viewModel.toggleFavorited()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension UIButton {
|
private extension UIButton {
|
||||||
|
|
Loading…
Reference in New Issue