-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into swiftui-app
# 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
Showing
44 changed files
with
881 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
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 { mailbox in | ||
DispatchQueue.main.async { | ||
guard let mailbox = mailbox else { return } | ||
(window?.windowScene?.delegate as? SceneDelegate)?.switchMailbox(mailbox) | ||
} | ||
} | ||
} 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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.