Skip to content
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
5 changes: 4 additions & 1 deletion Core/Sources/Account/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public struct Account: Codable, Equatable, Hashable, Identifiable {
public var deletePolicy: DeletePolicy
public var identities: [EmailAddress]
public var servers: [Server]
public var avatarColor: String

public var incomingServer: Server? { server(.jmap) ?? server(.imap) ?? nil }
public var outgoingServer: Server? { server(.jmap) ?? server(.smtp) ?? nil }
Expand Down Expand Up @@ -60,13 +61,15 @@ public struct Account: Codable, Equatable, Hashable, Identifiable {
deletePolicy: DeletePolicy = .never,
identities: [EmailAddress] = [],
servers: [Server] = [],
id: UUID = UUID()
id: UUID = UUID(),
avatar: String = "user-blue"
) {
self.name = name
self.deletePolicy = deletePolicy
self.identities = identities
self.servers = servers
self.id = id
self.avatarColor = avatar
}

// MARK: Identifiable
Expand Down
20 changes: 20 additions & 0 deletions Core/Sources/Account/UnifiedMailboxManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// UnifiedMailboxManager.swift
// Core
//
// Created by Ashley Soucar on 7/9/26.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
//

import Foundation

/// Manage each ``MailboxManager`` for every ``Account``.
@Observable
public final class UnifiedMailboxManager {
public var mailboxManagers: [MailboxManager] = []

public init() {
}
}
3 changes: 3 additions & 0 deletions Thunderbird/Thunderbird.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
142ECC532ECE4D1C00518776 /* Exceptions for "Thunderbird" folder in "ThunderbirdTests" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
Assets.xcassets,
FeatureFlags/Distribution.swift,
FeatureFlags/FeatureFlags.swift,
Util/AvatarView.swift,
Util/SmartDateFormatter.swift,
Util/UtilFunctions.swift,
);
target = 1521D8232D9C4D6300C4DFDF /* ThunderbirdTests */;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,54 @@ import SwiftUI
import Account

struct AccountFolderDisclosureView: View {
var account: Account
@Environment(MailboxManager.self) private var mailboxManager: MailboxManager
@State var isExpanded: Bool = false
@State var unreadCount: Int = 0
var body: some View {
DisclosureGroup {
HStack {
Text("Inbox")
Spacer()
DisclosureGroup(isExpanded: $isExpanded) {
ForEach(mailboxManager.mailboxes) { mailbox in
HStack {
MailboxDropdownRowView(mailbox: mailbox)
}
}
.padding(.horizontal)
.padding(.vertical, 10)
} label: {
Label {
Text(account.name)
} icon: {
Image(systemName: "folder")
.foregroundStyle(Color.random)
HStack {
AvatarView(
displayName: mailboxManager.account.name,
bubbleColor: Color(mailboxManager.account.avatarColor)
)
VStack(alignment: .leading) {
Text(mailboxManager.account.name)
.font(.body)
.truncationMode(.middle)
if (!mailboxManager.account.name.isEmailAddress) {
Text(mailboxManager.account.identities[0].email)
.font(.caption2)
.truncationMode(.middle)
}

}.padding(.horizontal)
.foregroundStyle(.black)
Spacer()
if (!isExpanded && unreadCount > 0) {
UnreadCounter(unreadCount: unreadCount, hasNew: false)
}
}.padding(.vertical, 10)
.safeAreaPadding(.horizontal)
}.task {
for mailbox in mailboxManager.mailboxes {
unreadCount += mailbox.unreadEmails!
}
}
.background {
RoundedRectangle(cornerRadius: 24)
.foregroundStyle(.white)
}
}
}

#Preview {
@Previewable @State var mailboxes: MailboxManager = MailboxManager(account: Account("temp@email.com"))
AccountFolderDisclosureView().environment(mailboxes)
}
38 changes: 13 additions & 25 deletions Thunderbird/Thunderbird/AccountList/DrawerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ struct DrawerView: View {
VStack(alignment: .leading) {
ScrollView {
DrawerContent(showDrawer: $showDrawer)
}
Spacer()
NavigationLink(destination: GeneralSettingsView()) {
Label("settings_header", systemImage: "gearshape")
.foregroundStyle(.black)
}.toolbar {
ToolbarItem(id: "settings", placement: .bottomBar) {
NavigationLink(destination: GeneralSettingsView()) {
Text("settings_header")
.foregroundStyle(.black)
}
}
ToolbarItem(placement: .bottomBar) {
Spacer()
}
}
}
.padding()
.background()
.background(.surface)
Spacer()
}
.transition(.move(edge: .leading))
Expand All @@ -58,32 +63,15 @@ struct DrawerView: View {
DrawerView(showDrawer: $showDrawer).environment(accounts)
}

//TODO: Connect to actual account and folder structure
struct DrawerContent: View {
@Environment(Accounts.self) private var accounts: Accounts
@Binding var showDrawer: Bool
var body: some View {
VStack(alignment: .leading) {
MailboxDropdownRowView(mailboxName: "Inbox", iconName: "tray")
MailboxDropdownRowView(mailboxName: "Sent", iconName: "paperplane")
Divider()
Text("Account Folders")
ForEach(accounts.allAccounts) { account in
AccountFolderDisclosureView(account: account)
let mailboxes: MailboxManager = MailboxManager(account: account)
AccountFolderDisclosureView().environment(mailboxes)
}

}
}
}

//TODO: Remove when account color association happens
//we will associate a color with an account but don't yet
extension Color {
static var random: Color {
return Color(
red: .random(in: 0...1),
green: .random(in: 0...1),
blue: .random(in: 0...1)
)
}
}
Loading
Loading