Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Error if click on frelated mailbox #777

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Mail/Views/Menu Drawer/MailboxManagement/MailboxCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ struct MailboxCell: View {
icon: MailResourcesAsset.envelope,
text: mailbox.email,
detailNumber: detailNumber,
isSelected: isSelected
isSelected: isSelected,
isPasswordValid: mailbox.isPasswordValid
) {
guard !isSelected else { return }
guard mailbox.isPasswordValid else {
IKSnackBar.showSnackBar(message: MailResourcesStrings.Localizable.frelatedMailbox)
return
}
@InjectService var matomo: MatomoUtils
switch style {
case .menuDrawer:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ struct MailboxesManagementButtonView: View {
let detailNumber: Int?
let handleAction: () -> Void
let isSelected: Bool
let isPasswordValid: Bool

init(
icon: MailResourcesImages,
text: String,
detailNumber: Int? = nil,
isSelected: Bool,
isPasswordValid: Bool,
handleAction: @escaping () -> Void
) {
self.icon = icon.swiftUIImage
self.text = text
self.detailNumber = detailNumber
self.isSelected = isSelected
self.isPasswordValid = isPasswordValid
self.handleAction = handleAction
}

Expand All @@ -59,17 +62,21 @@ struct MailboxesManagementButtonView: View {
}
.frame(maxWidth: .infinity, alignment: .leading)

switch style {
case .menuDrawer:
if let detailNumber {
Text(detailNumber < 100 ? "\(detailNumber)" : "99+")
.textStyle(.bodySmallMediumAccent)
}
case .account:
if isSelected {
MailResourcesAsset.check.swiftUIImage
.frame(width: 16, height: 16)
.foregroundColor(.accentColor)
if !isPasswordValid {
MailResourcesAsset.warning.swiftUIImage
} else {
switch style {
case .menuDrawer:
if let detailNumber {
Text(detailNumber < 100 ? "\(detailNumber)" : "99+")
.textStyle(.bodySmallMediumAccent)
}
case .account:
if isSelected {
MailResourcesAsset.check.swiftUIImage
.frame(width: 16, height: 16)
.foregroundColor(.accentColor)
}
}
}
}
Expand All @@ -80,14 +87,15 @@ struct MailboxesManagementButtonView: View {

struct MailboxesManagementButtonView_Previews: PreviewProvider {
static var previews: some View {
MailboxesManagementButtonView(icon: MailResourcesAsset.folder, text: "Hello", isSelected: false) {
MailboxesManagementButtonView(icon: MailResourcesAsset.folder, text: "Hello", isSelected: false, isPasswordValid: true) {
/* Empty for test */
}
MailboxesManagementButtonView(
icon: MailResourcesAsset.folder,
text: "Hello",
detailNumber: 10,
isSelected: false
isSelected: false,
isPasswordValid: true
) {
/* Empty for test */
}
Expand Down
16 changes: 16 additions & 0 deletions MailResources/Assets.xcassets/warning.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "warning.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "original"
}
}
3 changes: 3 additions & 0 deletions MailResources/Assets.xcassets/warning.imageset/warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified MailResources/Localizable/de.lproj/Localizable.strings
Binary file not shown.
Binary file modified MailResources/Localizable/en.lproj/Localizable.strings
Binary file not shown.
Binary file modified MailResources/Localizable/es.lproj/Localizable.strings
Binary file not shown.
Binary file modified MailResources/Localizable/fr.lproj/Localizable.strings
Binary file not shown.
Binary file modified MailResources/Localizable/it.lproj/Localizable.strings
Binary file not shown.