Skip to content

Commit

Permalink
Merge pull request #1135 from Infomaniak/use-frame
Browse files Browse the repository at this point in the history
fix(ThreadCell): Use frame instead of Spacer
  • Loading branch information
valentinperignon authored Nov 21, 2023
2 parents d90ba92 + e47f498 commit 2c97dbf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
20 changes: 15 additions & 5 deletions Mail/Components/ThreadCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ struct ThreadCell: View {

HStack(alignment: .top, spacing: UIPadding.verySmall) {
ThreadCellInfoView(subject: dataHolder.subject, preview: dataHolder.preview, density: density)
Spacer()
.frame(maxWidth: .infinity, alignment: .leading)
ThreadCellDetailsView(hasAttachments: thread.hasAttachments, isFlagged: thread.flagged)
}
}
Expand Down Expand Up @@ -209,14 +209,24 @@ struct ThreadCell: View {
}
}

struct ThreadCell_Previews: PreviewProvider {
static var previews: some View {
#Preview {
List {
ThreadCell(thread: PreviewHelper.sampleThread,
density: .large,
accentColor: .blue,
isMultipleSelectionEnabled: false,
isSelected: false)
.previewLayout(.sizeThatFits)
.previewDevice("iPhone 13 Pro")
ThreadCell(thread: PreviewHelper.sampleThread,
density: .normal,
accentColor: .blue,
isMultipleSelectionEnabled: false,
isSelected: false)
ThreadCell(thread: PreviewHelper.sampleThread,
density: .compact,
accentColor: .blue,
isMultipleSelectionEnabled: false,
isSelected: false)
}
.listStyle(.plain)
.environmentObject(PreviewHelper.sampleMailboxManager)
}
3 changes: 1 addition & 2 deletions Mail/Components/ThreadCellHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ struct ThreadCellHeaderView: View, Equatable {
.accessibilityHidden(true)
}

Spacer()

Text(formattedDate)
.textStyle(.bodySmallSecondary)
.lineLimit(1)
.frame(maxWidth: .infinity, alignment: .trailing)
.accessibilityHidden(true)
}
}
Expand Down
21 changes: 20 additions & 1 deletion Mail/Helpers/PreviewHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,27 @@ import RealmSwift
import SwiftUI

enum PreviewHelper {
private class PreviewHelperRefreshTokenDelegate: RefreshTokenDelegate {
func didUpdateToken(newToken: InfomaniakCore.ApiToken, oldToken: InfomaniakCore.ApiToken) {
// No implementation
}

func didFailRefreshToken(_ token: InfomaniakCore.ApiToken) {
// No implementation
}
}

static var sampleMailboxManager: MailboxManager = {
let apiFetcher = MailApiFetcher()
let fakeToken = ApiToken(
accessToken: "",
expiresIn: 0,
refreshToken: "",
scope: "",
tokenType: "",
userId: 0,
expirationDate: Date(timeIntervalSinceNow: 1_000_000)
)
let apiFetcher = MailApiFetcher(token: fakeToken, delegate: PreviewHelperRefreshTokenDelegate())
let contactManager = ContactManager(userId: 0, apiFetcher: apiFetcher)
return MailboxManager(account: PreviewHelper.sampleAccount,
mailbox: sampleMailbox,
Expand Down

0 comments on commit 2c97dbf

Please sign in to comment.