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: Show collapsed folders in MoveEmailView #896

Merged
merged 1 commit into from
Jul 26, 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
18 changes: 9 additions & 9 deletions Mail/Views/Menu Drawer/Folders/FolderCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import MailResources
import SwiftUI

struct FolderCellTypeEnvironment: EnvironmentKey {
static var defaultValue = FolderCell.CellType.link
static var defaultValue = FolderCell.CellType.menuDrawer
}

extension EnvironmentValues {
Expand All @@ -36,7 +36,7 @@ extension EnvironmentValues {

struct FolderCell: View {
enum CellType {
case link, indicator
case menuDrawer, move
}

@Environment(\.folderCellType) private var cellType
Expand All @@ -60,7 +60,7 @@ struct FolderCell: View {

var body: some View {
Group {
if cellType == .indicator || isCompactWindow {
if cellType == .move || isCompactWindow {
Button(action: didTapButton) {
FolderCellContent(
folder: folder.content,
Expand Down Expand Up @@ -92,7 +92,7 @@ struct FolderCell: View {
}
}

if folder.content.isExpanded {
if folder.content.isExpanded || cellType == .move {
ForEach(folder.children) { child in
FolderCell(
folder: child,
Expand All @@ -107,7 +107,7 @@ struct FolderCell: View {
}

private func didTapButton() {
if cellType == .indicator {
if cellType == .move {
customCompletion?(folder.content)
} else {
updateFolder()
Expand Down Expand Up @@ -140,15 +140,15 @@ struct FolderCellContent: View {
}

private var textStyle: MailTextStyle {
if cellType == .link {
if cellType == .menuDrawer {
return isCurrentFolder ? .bodyMediumAccent : .bodyMedium
}
return .body
}

var body: some View {
HStack(spacing: UIConstants.menuDrawerHorizontalItemSpacing) {
if canCollapseSubFolders && cellType == .link {
if canCollapseSubFolders && cellType == .menuDrawer {
Button(action: collapseFolder) {
ChevronIcon(style: folder.isExpanded ? .up : .down, color: .secondary)
}
Expand Down Expand Up @@ -177,7 +177,7 @@ struct FolderCellContent: View {

@ViewBuilder
private var accessory: some View {
if cellType == .link {
if cellType == .menuDrawer {
if folder.role != .sent && folder.role != .trash {
if !folder.formattedUnreadCount.isEmpty {
Text(folder.formattedUnreadCount)
Expand All @@ -196,7 +196,7 @@ struct FolderCellContent: View {

@ViewBuilder
private var background: some View {
if cellType == .link {
if cellType == .menuDrawer {
SelectionBackground(selectionType: isCurrentFolder ? .folder : .none)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/Menu Drawer/MenuDrawerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ struct MenuDrawerView: View {
}
}
.background(MailResourcesAsset.backgroundSecondaryColor.swiftUIColor.ignoresSafeArea())
.environment(\.folderCellType, .link)
.environment(\.folderCellType, .menuDrawer)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/Thread/MoveEmailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct MoveEmailView: View {
}
}
}
.environment(\.folderCellType, .indicator)
.environment(\.folderCellType, .move)
.matomoView(view: ["MoveEmailView"])
.customAlert(isPresented: $isShowingCreateFolderAlert) {
CreateFolderView(mode: .move { newFolder in
Expand Down
Loading