Skip to content

Commit

Permalink
Merge pull request #777 from Infomaniak/frelatedMailbox
Browse files Browse the repository at this point in the history
fix: Error if click on frelated mailbox
  • Loading branch information
valentinperignon committed Jun 7, 2023
2 parents cfd23c9 + 92789b0 commit df6b791
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 14 deletions.
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.

0 comments on commit df6b791

Please sign in to comment.