Skip to content

Commit

Permalink
Merge branch 'dev' into sjmarf/purge-users
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjmarf authored Dec 4, 2024
2 parents b8c9933 + df6760d commit d0a6987
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 15 deletions.
26 changes: 26 additions & 0 deletions Mlem/App/Models/ErrorDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@ struct ErrorDetails: Hashable {
var refresh: (() async -> Bool)?
var autoRefresh: Bool = false

init(
title: String? = nil,
body: String? = nil,
error: Error? = nil,
systemImage: String? = nil,
buttonText: String? = nil,
refresh: (() -> Bool)? = nil,
autoRefresh: Bool = false
) {
self.title = title
self.body = body
self.error = error
self.systemImage = systemImage
self.buttonText = buttonText
self.refresh = refresh
self.autoRefresh = autoRefresh
if let error {
switch error {
case ApiClientError.imageTooLarge:
self.title = self.title ?? "Image too large"
default:
break
}
}
}

func hash(into hasher: inout Hasher) {
hasher.combine(title)
hasher.combine(body)
Expand Down
11 changes: 9 additions & 2 deletions Mlem/App/Models/ImageUploadManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,15 @@ class ImageUploadManager: Hashable {
}

func upload(data: Data, api: ApiClient) async throws {
let image = try await api.uploadImage(data, onProgress: { self.state = .uploading(progress: $0) })
state = .done(image)
do {
let image = try await api.uploadImage(data, onProgress: {
self.state = .uploading(progress: $0)
})
state = .done(image)
} catch {
state = .idle
throw error
}
}

func hash(into hasher: inout Hasher) {
Expand Down
2 changes: 2 additions & 0 deletions Mlem/App/Views/Pages/CommentEditor/CommentEditorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ struct CommentEditorView: View {
)
.padding(.vertical, Constants.main.standardSpacing)
.background(palette.secondaryGroupedBackground, in: .rect(cornerRadius: Constants.main.standardSpacing))
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
.padding(.horizontal, Constants.main.standardSpacing)
contextView
.padding(Constants.main.standardSpacing)
.background(palette.secondaryGroupedBackground, in: .rect(cornerRadius: Constants.main.standardSpacing))
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
.padding(.horizontal, Constants.main.standardSpacing)
}
.animation(.easeOut(duration: 0.2), value: resolutionState == .notFound)
Expand Down
1 change: 1 addition & 0 deletions Mlem/App/Views/Pages/Community/CommunityView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ struct CommunityView: View {
Markdown(description, configuration: .default)
.padding(Constants.main.standardSpacing)
.background(palette.secondaryGroupedBackground, in: .rect(cornerRadius: Constants.main.standardSpacing))
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
}
}
.padding([.horizontal, .bottom], Constants.main.standardSpacing)
Expand Down
2 changes: 0 additions & 2 deletions Mlem/App/Views/Pages/Instance/FediseerOpinionListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ struct FediseerOpinionListView: View {

ForEach(items, id: \.domain) { opinion in
FediseerOpinionView(opinion: opinion)
.background(palette.secondaryGroupedBackground)
.cornerRadius(Constants.main.standardSpacing)
}
}
.padding(16)
Expand Down
3 changes: 3 additions & 0 deletions Mlem/App/Views/Pages/Instance/FediseerOpinionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ struct FediseerOpinionView: View {
.frame(maxWidth: .infinity)
.padding(.vertical, 10)
.font(.callout)
.background(palette.secondaryGroupedBackground)
.cornerRadius(Constants.main.standardSpacing)
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
}

@ViewBuilder
Expand Down
3 changes: 2 additions & 1 deletion Mlem/App/Views/Pages/Instance/InstanceSafetyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct InstanceSafetyView: View {
destination: items.count > 5 ? destination : nil
)
ForEach(items.prefix(5), id: \.domain) { item in
section { FediseerOpinionView(opinion: item) }
FediseerOpinionView(opinion: item)
.padding(.bottom, 9)
}
}
Expand All @@ -121,6 +121,7 @@ struct InstanceSafetyView: View {
.frame(maxWidth: .infinity)
.background(palette.secondaryGroupedBackground)
.cornerRadius(Constants.main.standardSpacing)
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
}
}

Expand Down
6 changes: 2 additions & 4 deletions Mlem/App/Views/Pages/Instance/InstanceUptimeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ struct InstanceUptimeView: View {
.padding(.leading, 12)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.vertical, 10)
.background(
RoundedRectangle(cornerRadius: Constants.main.standardSpacing)
.fill(palette.secondaryGroupedBackground)
)
.background(palette.secondaryGroupedBackground, in: .rect(cornerRadius: Constants.main.standardSpacing))
}
.buttonStyle(EmptyButtonStyle())

Expand Down Expand Up @@ -218,6 +215,7 @@ struct InstanceUptimeView: View {
.frame(maxWidth: .infinity)
.background(palette.secondaryGroupedBackground)
.cornerRadius(Constants.main.standardSpacing)
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
}
}

Expand Down
1 change: 1 addition & 0 deletions Mlem/App/Views/Pages/Instance/InstanceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct InstanceView: View {
Markdown(description, configuration: .default)
.padding(Constants.main.standardSpacing)
.background(palette.secondaryGroupedBackground, in: .rect(cornerRadius: Constants.main.standardSpacing))
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
.padding([.horizontal, .bottom], Constants.main.standardSpacing)
}
case .details:
Expand Down
2 changes: 1 addition & 1 deletion Mlem/App/Views/Pages/PostEditor/PostEditorTargetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct PostEditorTargetView: View {
callback: { target.community = .init($0) }
))
} label: {
var singleAccount = AccountsTracker.main.userAccounts.count == 1
let singleAccount = AccountsTracker.main.userAccounts.count == 1
HStack(spacing: 0) {
if let community = target.community as? any Community {
FullyQualifiedLabelView(
Expand Down
5 changes: 5 additions & 0 deletions Mlem/App/Views/Root/Tabs/Settings/SortingSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import MlemMiddleware
import SwiftUI

struct SortingSettingsView: View {
@Environment(Palette.self) var palette

@Setting(\.defaultPostSort) var defaultPostSort
@Setting(\.fallbackPostSort) var fallbackPostSort
@Setting(\.commentSort) var commentSort
Expand All @@ -20,6 +22,7 @@ struct SortingSettingsView: View {
Text("Posts")
Spacer()
FeedSortPicker(sort: $defaultPostSort)
.foregroundStyle(palette.accent)
.frame(minHeight: 50)
.buttonStyle(.bordered)
}
Expand All @@ -28,6 +31,7 @@ struct SortingSettingsView: View {
Text("Fallback")
Spacer()
FeedSortPicker(sort: $fallbackPostSort, filters: [.alwaysAvailable])
.foregroundStyle(palette.accent)
.frame(minHeight: 50)
.buttonStyle(.bordered)
}
Expand All @@ -50,6 +54,7 @@ struct SortingSettingsView: View {
}
}
}
.foregroundStyle(palette.accent)
.frame(minHeight: 50)
.buttonStyle(.bordered)
}
Expand Down
4 changes: 3 additions & 1 deletion Mlem/App/Views/Shared/FooterLinkView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ struct FooterLinkView: View {

let title: String
let subtitle: String?

var body: some View {
VStack(alignment: .leading, spacing: 5) {
Text(title)
.frame(maxWidth: .infinity, alignment: .leading)
.font(.subheadline)
.fontWeight(.semibold)
.multilineTextAlignment(.leading)
.lineLimit(2)

if let subtitle {
Text(subtitle)
Expand Down
3 changes: 2 additions & 1 deletion Mlem/App/Views/Shared/Form/FormSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct FormSection<Content: View>: View {
content
.frame(maxWidth: .infinity)
.background(palette.secondaryGroupedBackground)
.clipShape(.rect(cornerRadius: 10))
.clipShape(.rect(cornerRadius: Constants.main.standardSpacing))
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
}
}
4 changes: 2 additions & 2 deletions Mlem/App/Views/Shared/Palette Components/Form.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ struct Form<Content: View>: View {
.tint(palette.accent)
.buttonStyle(PaletteButton())
}
.listStyle(InsetListStyle())
.listStyle(.insetGrouped)
.scrollContentBackground(.hidden)
.background(palette.groupedBackground)
.shadow(color: palette.primary.opacity(palette.bordered ? 0.2 : 0.0), radius: 5)
.shadow(color: palette.primary.opacity(palette.bordered ? 0.4 : 0.0), radius: 1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ struct CommunityListRow<Content2: View>: View {
.contentShape(.contextMenuPreview, .rect(cornerRadius: Constants.main.standardSpacing))
.contextMenu { community.menuActions(navigation: navigation) }
.quickSwipes(community.swipeActions(behavior: .standard))
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
}
}
1 change: 1 addition & 0 deletions Mlem/App/Views/Shared/Search/Results/InstanceListRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ struct InstanceListRow<Content2: View>: View {
.contextMenu {
instanceStub?.menuActions(allowExternalBlocking: true) ?? []
}
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
}
}
1 change: 1 addition & 0 deletions Mlem/App/Views/Shared/Search/Results/PersonListRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ struct PersonListRow<Content2: View>: View {
.background(palette.secondaryGroupedBackground, in: .rect(cornerRadius: Constants.main.standardSpacing))
.contentShape(.contextMenuPreview, .rect(cornerRadius: Constants.main.standardSpacing))
.contextMenu { person.menuActions(navigation: navigation) }
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
}
}
1 change: 0 additions & 1 deletion Mlem/App/Views/Shared/Search/SearchResultsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ struct SearchResultsView<Item: Identifiable, Content: View>: View {
var body: some View {
ForEach(results) { item in
content(item)
.paletteBorder(cornerRadius: Constants.main.standardSpacing)
.padding(.horizontal, Constants.main.standardSpacing)
.padding(.bottom, Constants.main.halfSpacing)
}
Expand Down

0 comments on commit d0a6987

Please sign in to comment.