Merge pull request #2591 from stuartbreckenridge/main

Buttons states
This commit is contained in:
Maurice Parker 2020-11-18 22:07:49 -06:00 committed by GitHub
commit ca54e0a394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 38 deletions

View File

@ -14,33 +14,24 @@ struct AddAccountHelpView: View {
let accountTypes: [AccountType] = AddAccountSections.allOrdered.sectionContent
var delegate: AccountsPreferencesAddAccountDelegate?
var helpText: String
@State private var hoveringId: String? = nil
@State private var iCloudUnavailableError: Bool = false
var body: some View {
VStack {
HStack {
ForEach(accountTypes, id: \.self) { account in
account.image()
.resizable()
.frame(width: 20, height: 20, alignment: .center)
.onTapGesture {
if account == .cloudKit && AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit }) {
iCloudUnavailableError = true
} else {
delegate?.presentSheetForAccount(account)
}
hoveringId = nil
Button(action: {
if account == .cloudKit && AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit }) {
iCloudUnavailableError = true
} else {
delegate?.presentSheetForAccount(account)
}
.onHover(perform: { hovering in
if hovering {
hoveringId = account.localizedAccountName()
} else {
hoveringId = nil
}
})
.scaleEffect(hoveringId == account.localizedAccountName() ? 1.2 : 1)
.shadow(radius: hoveringId == account.localizedAccountName() ? 0.8 : 0)
}, label: {
account.image()
.resizable()
.frame(width: 20, height: 20, alignment: .center)
})
.buttonStyle(PlainButtonStyle())
}
}

View File

@ -20,28 +20,18 @@ struct EnableExtensionPointHelpView: View {
var helpText: String
weak var preferencesController: ExtensionPointPreferencesViewController?
@State private var hoveringId: String?
var body: some View {
VStack {
HStack {
ForEach(0..<extensionPoints.count, content: { i in
Image(nsImage: extensionPoints[i].image)
.resizable()
.frame(width: 20, height: 20, alignment: .center)
.onTapGesture {
preferencesController?.enableExtensionPointFromSelection(extensionPoints[i])
hoveringId = nil
}
.onHover(perform: { hovering in
if hovering {
hoveringId = extensionPoints[i].title
} else {
hoveringId = nil
}
})
.scaleEffect(hoveringId == extensionPoints[i].title ? 1.2 : 1)
.shadow(radius: hoveringId == extensionPoints[i].title ? 0.8 : 0)
Button(action: {
preferencesController?.enableExtensionPointFromSelection(extensionPoints[i])
}, label: {
Image(nsImage: extensionPoints[i].image)
.resizable()
.frame(width: 20, height: 20, alignment: .center)
})
.buttonStyle(PlainButtonStyle())
})
if ExtensionPointManager.shared.availableExtensionPointTypes.count == 0 {