add a setting to disable the account popover on hover (#1750)

* add a setting to disable the account popover on hover

- not entirely pleased with the AnyView() cast but don't really know of a less invasive change

* Fixes

---------

Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
This commit is contained in:
sh95014 2023-12-16 22:57:20 -08:00 committed by GitHub
parent a7f982e827
commit f9da958047
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 149 additions and 7 deletions

View file

@ -50,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/RevenueCat/purchases-ios.git",
"state" : {
"revision" : "b8d20ba1c8e13cc73d72e37cf98607d01fd357b6",
"version" : "4.31.2"
"revision" : "cb3cc43b6181bc5f4482e35742448ee6ddc587e8",
"version" : "4.31.4"
}
},
{

View file

@ -217,6 +217,9 @@ struct DisplaySettingsView: View {
.font(.scaledBody)
}
}
#if targetEnvironment(macCatalyst)
Toggle("settings.display.show-account-popover", isOn: $userPreferences.showAccountPopover)
#endif
}
.listRowBackground(theme.primaryBackgroundColor)
}

View file

@ -9,6 +9,12 @@
"value" : ""
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : ""
}
},
"eu" : {
"stringUnit" : {
"state" : "translated",
@ -43103,7 +43109,7 @@
},
"en-GB" : {
"stringUnit" : {
"state" : "needs_review",
"state" : "translated",
"value" : "Max reply indentation: %@"
}
},
@ -44138,6 +44144,124 @@
}
}
},
"settings.display.show-account-popover" : {
"localizations" : {
"be" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"ca" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"de" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Show Account on Hover"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "Show Account on Hover"
}
},
"es" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"eu" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"fr" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"it" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"ja" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"ko" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"nb" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"nl" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"pl" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"tr" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"uk" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Show Account on Hover"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "顯示游標下的帳號"
}
}
}
},
"settings.display.show-ipad-column" : {
"localizations" : {
"be" : {
@ -44285,7 +44409,7 @@
},
"en-GB" : {
"stringUnit" : {
"state" : "needs_review",
"state" : "translated",
"value" : "Show reply indentation"
}
},
@ -58116,7 +58240,7 @@
},
"en-GB" : {
"stringUnit" : {
"state" : "needs_review",
"state" : "translated",
"value" : "Select Text"
}
},

View file

@ -1,3 +1,4 @@
import Env
import Nuke
import NukeUI
import Shimmer
@ -143,6 +144,7 @@ extension VerticalAlignment {
public struct AccountPopoverModifier : ViewModifier {
@Environment(Theme.self) private var theme
@Environment(UserPreferences.self) private var userPreferences
@State private var showPopup = false
@State private var autoDismiss = true
@ -151,7 +153,11 @@ public struct AccountPopoverModifier : ViewModifier {
let account: Account
public func body(content: Content) -> some View {
content
if !userPreferences.showAccountPopover {
return AnyView(content)
}
return AnyView(content
.onHover { hovering in
if hovering {
toggleTask.cancel()
@ -177,7 +183,7 @@ public struct AccountPopoverModifier : ViewModifier {
autoDismiss: $autoDismiss,
toggleTask: $toggleTask
)
}
})
}
init(_ account: Account) {

View file

@ -59,6 +59,8 @@ import SwiftUI
@AppStorage("max_reply_indentation") public var maxReplyIndentation: UInt = 7
@AppStorage("show_reply_indentation") public var showReplyIndentation: Bool = true
@AppStorage("show_account_popover") public var showAccountPopover: Bool = true
init() {}
}
@ -313,6 +315,12 @@ import SwiftUI
}
}
public var showAccountPopover: Bool {
didSet {
storage.showAccountPopover = showAccountPopover
}
}
public func getRealMaxIndent() -> UInt {
showReplyIndentation ? maxReplyIndentation : 0
}
@ -485,6 +493,7 @@ import SwiftUI
fastRefreshEnabled = storage.fastRefreshEnabled
maxReplyIndentation = storage.maxReplyIndentation
showReplyIndentation = storage.showReplyIndentation
showAccountPopover = storage.showAccountPopover
}
}