Skip to content

Commit

Permalink
Merge branch 'master' into swiftui-app
Browse files Browse the repository at this point in the history
# Conflicts:
#	Mail/AppDelegate.swift
#	Mail/SceneDelegate.swift
#	Mail/Views/NoMailboxView.swift
#	Mail/Views/Switch User/AccountView.swift
#	Mail/Views/Thread List/ThreadListModifiers.swift
  • Loading branch information
PhilippeWeidmann committed Jul 7, 2023
2 parents d93b65f + d51c456 commit 48788aa
Show file tree
Hide file tree
Showing 44 changed files with 871 additions and 328 deletions.
22 changes: 11 additions & 11 deletions .package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Infomaniak/ios-core",
"state" : {
"revision" : "e5fe8e03aa06375f20c8e40f4fae3a6af6e4d75e"
"revision" : "ef2811a288a3a4b94dd5d04c5f47ddd771e4176c"
}
},
{
Expand Down Expand Up @@ -139,8 +139,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/kean/Nuke",
"state" : {
"revision" : "282b9562c84d76cebbbecd1cc3aaf430448a0cce",
"version" : "12.1.1"
"revision" : "f67266f176af4add9f7a7020486826d82d562473",
"version" : "12.1.2"
}
},
{
Expand All @@ -157,17 +157,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/realm-core.git",
"state" : {
"revision" : "93cc224680a520a84e1c01aa8866042c52eb7958",
"version" : "13.15.0"
"revision" : "f1434caadda443b4ed2261b91ea4f43ab1ee2aa5",
"version" : "13.15.1"
}
},
{
"identity" : "realm-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/realm-swift",
"state" : {
"revision" : "2d7d1463a765c8835262dc09da83906e7cea166c",
"version" : "10.40.2"
"revision" : "b287dc102036ff425bd8a88483f0a5596871f05e",
"version" : "10.41.0"
}
},
{
Expand Down Expand Up @@ -237,17 +237,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/scinfu/SwiftSoup",
"state" : {
"revision" : "0e96a20ffd37a515c5c963952d4335c89bed50a6",
"version" : "2.6.0"
"revision" : "8b6cf29eead8841a1fa7822481cb3af4ddaadba6",
"version" : "2.6.1"
}
},
{
"identity" : "swiftui-introspect",
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect",
"state" : {
"revision" : "dafd88cf0cc09d906dcef9d042743ae13fcff0d4",
"version" : "0.6.3"
"revision" : "8bf15ad33a529359200bd419a72ca2dda841089b",
"version" : "0.8.0"
}
},
{
Expand Down
74 changes: 74 additions & 0 deletions Mail/Components/MailboxListView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
Infomaniak Mail - iOS App
Copyright (C) 2022 Infomaniak Network SA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import MailCore
import MailResources
import RealmSwift
import SwiftUI

struct MailboxListView: View {
@Environment(\.window) private var window

@AppStorage(UserDefaults.shared.key(.accentColor)) private var accentColor = DefaultPreferences.accentColor

@ObservedResults(
Mailbox.self,
configuration: MailboxInfosManager.instance.realmConfiguration,
where: { $0.userId == AccountManager.instance.currentUserId },
sortDescriptor: SortDescriptor(keyPath: \Mailbox.mailboxId)
) private var mailboxes

private var otherMailboxes: [Mailbox] {
return mailboxes.filter { $0.mailboxId != currentMailbox?.mailboxId }
}

let currentMailbox: Mailbox?

var body: some View {
VStack(alignment: .leading, spacing: 12) {
HStack(alignment: .center) {
Text(MailResourcesStrings.Localizable.buttonAccountAssociatedEmailAddresses)
.textStyle(.bodySmallSecondary)

Spacer()

NavigationLink {
AddMailboxView()
} label: {
MailResourcesAsset.addCircle.swiftUIImage
.resizable()
.foregroundColor(accentColor.primary)
.frame(width: 16, height: 16)
}
}
.padding(.bottom, 16)

if let currentMailbox {
MailboxCell(mailbox: currentMailbox, isSelected: true)
.mailboxCellStyle(.account)
}

ForEach(otherMailboxes) { mailbox in
MailboxCell(mailbox: mailbox)
.mailboxCellStyle(.account)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 24)
}
}
78 changes: 78 additions & 0 deletions Mail/Components/UnavailableMailboxListView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
Infomaniak Mail - iOS App
Copyright (C) 2022 Infomaniak Network SA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import MailCore
import MailResources
import RealmSwift
import SwiftUI

struct UnavailableMailboxListView: View {
@Environment(\.window) private var window

@AppStorage(UserDefaults.shared.key(.accentColor)) private var accentColor = DefaultPreferences.accentColor

@ObservedResults(
Mailbox.self,
configuration: MailboxInfosManager.instance.realmConfiguration,
where: { $0.userId == AccountManager.instance.currentUserId && $0.isPasswordValid == false },
sortDescriptor: SortDescriptor(keyPath: \Mailbox.mailboxId)
) private var passwordBlockedMailboxes

@ObservedResults(
Mailbox.self,
configuration: MailboxInfosManager.instance.realmConfiguration,
where: { $0.userId == AccountManager.instance.currentUserId && $0.isLocked == true },
sortDescriptor: SortDescriptor(keyPath: \Mailbox.mailboxId)
) private var lockedMailboxes

var body: some View {
VStack(alignment: .leading, spacing: 32) {
if !passwordBlockedMailboxes.isEmpty {
VStack(alignment: .leading, spacing: 12) {
Text(MailResourcesStrings.Localizable.blockedPasswordTitlePlural)
ForEach(passwordBlockedMailboxes) { mailbox in
MailboxCell(mailbox: mailbox)
.mailboxCellStyle(.setPassword)
}
}
}

if !lockedMailboxes.isEmpty {
VStack(alignment: .leading, spacing: 12) {
Text(MailResourcesStrings.Localizable.lockedMailboxTitlePlural)
ForEach(lockedMailboxes) { mailbox in
MailboxesManagementButtonView(
icon: MailResourcesAsset.envelope,
text: mailbox.email,
isSelected: false,
isInMaintenance: false
)
}
}
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 24)
}
}

struct UnavailableMailboxListView_Previews: PreviewProvider {
static var previews: some View {
UnavailableMailboxListView()
}
}
3 changes: 2 additions & 1 deletion Mail/Components/UnreadIndicatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import MailCore
import SwiftUI

struct UnreadIndicatorView: View {
let hidden: Bool
var hidden = false

var body: some View {
Circle()
.frame(width: UIConstants.unreadIconSize, height: UIConstants.unreadIconSize)
Expand Down
8 changes: 1 addition & 7 deletions Mail/Helpers/PreviewHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,17 @@ enum PreviewHelper {
children: [])

static let sampleThread = Thread(uid: "",
messagesCount: 2,
deletedMessagesCount: 0,
messages: [sampleMessage],
unseenMessages: 1,
from: [sampleRecipient1],
to: [sampleRecipient2],
cc: [],
bcc: [],
subject: "Test thread",
date: SentryDebug.knownDebugDate,
hasAttachments: true,
hasSwissTransferAttachments: false,
hasDrafts: false,
flagged: true,
answered: true,
forwarded: true,
size: 0)
forwarded: true)

static let sampleMessage = Message(uid: "",
msgId: "",
Expand Down
11 changes: 8 additions & 3 deletions Mail/Views/Menu Drawer/Folders/FolderCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,14 @@ struct FolderCellContent: View {
@ViewBuilder
private var accessory: some View {
if cellType == .link {
if folder.role != .sent {
Text(folder.formattedUnreadCount)
.textStyle(.bodySmallMediumAccent)
if folder.role != .sent && folder.role != .trash {
if !folder.formattedUnreadCount.isEmpty {
Text(folder.formattedUnreadCount)
.textStyle(.bodySmallMediumAccent)
} else if folder.remoteUnreadCount > 0 {
UnreadIndicatorView()
.accessibilityLabel(MailResourcesStrings.Localizable.contentDescriptionUnreadPastille)
}
}
} else if isCurrentFolder {
MailResourcesAsset.check.swiftUIImage
Expand Down
27 changes: 19 additions & 8 deletions Mail/Views/Menu Drawer/MailboxManagement/MailboxCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ struct MailboxCell: View {
@Environment(\.mailboxCellStyle) private var style: Style
@EnvironmentObject private var navigationDrawerState: NavigationDrawerState

let mailbox: Mailbox
@State private var isShowingLockedView = false
@State private var isShowingUpdatePasswordView = false

private var isSelected: Bool {
return AccountManager.instance.currentMailboxManager?.mailbox.objectId == mailbox.objectId
}
let mailbox: Mailbox
var isSelected = false

private var detailNumber: Int? {
return mailbox.unseenMessages > 0 ? mailbox.unseenMessages : nil
}

enum Style {
case menuDrawer, account
case menuDrawer, account, setPassword
}

var body: some View {
Expand All @@ -64,15 +64,20 @@ struct MailboxCell: View {
text: mailbox.email,
detailNumber: detailNumber,
isSelected: isSelected,
isPasswordValid: mailbox.isPasswordValid
isInMaintenance: !mailbox.isAvailable
) {
guard !isSelected else { return }
guard mailbox.isPasswordValid else {
IKSnackBar.showSnackBar(message: MailResourcesStrings.Localizable.frelatedMailbox)
isShowingUpdatePasswordView = true
return
}
guard !mailbox.isLocked else {
isShowingLockedView = true
return
}
@InjectService var matomo: MatomoUtils
switch style {
case .setPassword: break
case .menuDrawer:
matomo.track(eventWithCategory: .menuDrawer, name: "switchMailbox")
case .account:
Expand All @@ -81,11 +86,17 @@ struct MailboxCell: View {
AccountManager.instance.switchMailbox(newMailbox: mailbox)
navigationDrawerState.close()
}
.floatingPanel(isPresented: $isShowingLockedView) {
LockedMailboxView(lockedMailbox: mailbox)
}
.sheet(isPresented: $isShowingUpdatePasswordView) {
UpdateMailboxPasswordView(mailbox: mailbox)
}
}
}

struct MailboxCell_Previews: PreviewProvider {
static var previews: some View {
MailboxCell(mailbox: PreviewHelper.sampleMailbox)
MailboxCell(mailbox: PreviewHelper.sampleMailbox, isSelected: true)
}
}
Loading

0 comments on commit 48788aa

Please sign in to comment.