Skip to content

Commit

Permalink
Merge branch 'dev' into eric/compact-pinned-posts
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBAndrews committed Jan 31, 2025
2 parents 8a528a3 + e98a43a commit 1d5f902
Show file tree
Hide file tree
Showing 18 changed files with 228 additions and 64 deletions.
10 changes: 9 additions & 1 deletion Mlem.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@
03A630EF2D497143009A47A6 /* TappableLinksSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A630EE2D497143009A47A6 /* TappableLinksSettingsView.swift */; };
03A630F12D497674009A47A6 /* ShieldsBadgeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A630F02D497674009A47A6 /* ShieldsBadgeView.swift */; };
03A630F42D4976EB009A47A6 /* ShieldsBadgeView+Logic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A630F32D4976EB009A47A6 /* ShieldsBadgeView+Logic.swift */; };
03A6315E2D4D1A1B009A47A6 /* DefaultFeedSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A6315D2D4D1A1B009A47A6 /* DefaultFeedSettingsView.swift */; };
03A631602D4D1CBB009A47A6 /* HapticSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A6315F2D4D1CBB009A47A6 /* HapticSettingsView.swift */; };
03A82FA12C0D1E8500D01A5C /* ApiClient+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A82FA02C0D1E8500D01A5C /* ApiClient+Extensions.swift */; };
03A82FA32C0D1F2400D01A5C /* View+ExternalApiWarning.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A82FA22C0D1F2400D01A5C /* View+ExternalApiWarning.swift */; };
03AB484F2CBAE33500567FF9 /* MarkdownWithLinkList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03AB484E2CBAE33500567FF9 /* MarkdownWithLinkList.swift */; };
Expand Down Expand Up @@ -726,6 +728,8 @@
03A630EE2D497143009A47A6 /* TappableLinksSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TappableLinksSettingsView.swift; sourceTree = "<group>"; };
03A630F02D497674009A47A6 /* ShieldsBadgeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShieldsBadgeView.swift; sourceTree = "<group>"; };
03A630F32D4976EB009A47A6 /* ShieldsBadgeView+Logic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ShieldsBadgeView+Logic.swift"; sourceTree = "<group>"; };
03A6315D2D4D1A1B009A47A6 /* DefaultFeedSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFeedSettingsView.swift; sourceTree = "<group>"; };
03A6315F2D4D1CBB009A47A6 /* HapticSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticSettingsView.swift; sourceTree = "<group>"; };
03A6315C2D4D15F1009A47A6 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
03A82FA02C0D1E8500D01A5C /* ApiClient+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ApiClient+Extensions.swift"; sourceTree = "<group>"; };
03A82FA22C0D1F2400D01A5C /* View+ExternalApiWarning.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+ExternalApiWarning.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1070,6 +1074,8 @@
CDEE15532D22364500EB9D7B /* ErrorLogView.swift */,
CD45CB0C2D1880E3008BC729 /* FiltersSettingsView.swift */,
039F58892C7B54FE00C61658 /* GeneralSettingsView.swift */,
03A6315F2D4D1CBB009A47A6 /* HapticSettingsView.swift */,
03A6315D2D4D1A1B009A47A6 /* DefaultFeedSettingsView.swift */,
036FFA2E2D45197300998D8A /* PrivacySettingsView.swift */,
038188982D43E0F30073E88D /* SafetySettingsView.swift */,
03600D922D4531DF00C704CB /* PrivacyBypassImageProxySettingsView.swift */,
Expand Down Expand Up @@ -2398,6 +2404,7 @@
0315B1C12C74C71A006D4F82 /* CommentEditorView+Context.swift in Sources */,
03D283FE2D25EEC500A6659B /* SearchView+Views.swift in Sources */,
03AFD0DF2C3B2E000054B8AD /* PersonListRow.swift in Sources */,
03A6315E2D4D1A1B009A47A6 /* DefaultFeedSettingsView.swift in Sources */,
0315B1CA2C767847006D4F82 /* InteractionBarTracker.swift in Sources */,
03DAEA772C64074E0064DE64 /* SubscriptionListItemView.swift in Sources */,
0324FA772C1F0AE100F6247D /* Readout.swift in Sources */,
Expand Down Expand Up @@ -2799,6 +2806,7 @@
0397D4642C676CA8002C6CDC /* FeedSortPicker.swift in Sources */,
0355F9462C150B2300605248 /* ExternalApiInfoView.swift in Sources */,
03D0273C2CD3BA5100984519 /* PersonContent+Extensions.swift in Sources */,
03A631602D4D1CBB009A47A6 /* HapticSettingsView.swift in Sources */,
03F9672B2CE221220081C9A3 /* Label+Profile1.swift in Sources */,
CD13CC612C5D262E001AF428 /* MediaLoadingState.swift in Sources */,
03CBD1932C61369A00E870BC /* Interactable2Providing+Extensions.swift in Sources */,
Expand Down Expand Up @@ -3197,7 +3205,7 @@
repositoryURL = "https://github.com/mlemgroup/LemmyMarkdownUI";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.6.0;
minimumVersion = 0.7.0;
};
};
0392826E2BC84E480097F91A /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mlemgroup/LemmyMarkdownUI",
"state" : {
"revision" : "ab579f496b1acaa3230dcc5ae16fa804f53ed504",
"version" : "0.6.0"
"revision" : "ef959bfe8f20a2ca78ced88e91073b5b5768a18d",
"version" : "0.7.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Mlem/App/Configuration/Icons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ enum Icons {
static let switchUser: String = "person.crop.circle.badge.plus"
static let missing: String = "questionmark.square.dashed"
static let connection: String = "antenna.radiowaves.left.and.right"
static let haptics: String = "hand.tap"
static let haptics: String = "circle.dotted.and.circle"
static let transparency: String = "square.on.square.intersection.dashed"
static let icon: String = "fleuron"
static let banner: String = "flag"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import Foundation
/// - high: denotes a haptic that always plays if the user has selected any degree of haptic feedback
/// - low: denotes a haptic that only plays if the user has selected "all" haptic feedback
enum HapticPriority: String, CaseIterable, Comparable, Codable {
case sentinel, high, low
case low
case high
case sentinel

var intValue: Int {
switch self {
Expand Down
17 changes: 13 additions & 4 deletions Mlem/App/Utility/Extensions/ApiSortType+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ extension ApiSortType: @retroactive CaseIterable {
case .old:
.init(localized: "Old")
case .topAll:
.init(localized: "All Time")
// swiftlint:disable:next void_function_in_ternary
abbreviateUnits ? .init(localized: "All") : .init(localized: "All Time")
case .mostComments:
.init(localized: "Most Comments")
case .newComments:
Expand All @@ -76,7 +77,15 @@ extension ApiSortType: @retroactive CaseIterable {
case .scaled:
.init(localized: "Scaled")
default:
formatter(unitsStyle: abbreviateUnits ? .abbreviated : .full)
dateComponentsLabel(abbreviateUnits: abbreviateUnits)
}
}

private func dateComponentsLabel(abbreviateUnits: Bool) -> String {
if abbreviateUnits {
formatter(unitsStyle: .abbreviated).string(for: dateComponents) ?? ""
} else {
formatter(unitsStyle: .full)
.string(for: dateComponents)?
.capitalized ?? ""
}
Expand All @@ -88,7 +97,7 @@ extension ApiSortType: @retroactive CaseIterable {
case .topOnly:
return String(localized: "Top")
case .topAndTimescale:
return String(localized: "Top: \(basicLabel(abbreviateUnits: true))")
return String(localized: "Top: \(basicLabel(abbreviateUnits: false))")
default: break
}
}
Expand Down Expand Up @@ -136,7 +145,7 @@ extension ApiSortType: @retroactive CaseIterable {

private func formatter(unitsStyle: DateComponentsFormatter.UnitsStyle) -> DateComponentsFormatter {
let formatter = DateComponentsFormatter()
formatter.unitsStyle = .full
formatter.unitsStyle = unitsStyle
formatter.maximumUnitCount = 1
return formatter
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ extension MarkdownConfiguration {
) }

static var dimmed: MarkdownConfiguration { .init(
inlineImageLoader: { _ in },
imagePresentationMode: .inline,
inlineImageLoader: { _ in }, // Don't load inline images; they will remain as placeholders
imageBlockView: { imageView($0, shouldBlur: false) },
wrapCodeBlockLines: Settings.main.wrapCodeBlockLines,
primaryColor: Palette.main.secondary,
Expand Down
30 changes: 29 additions & 1 deletion Mlem/App/Views/Pages/Community/FeedSortPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SwiftUI
struct FeedSortPicker: View {
@Environment(AppState.self) var appState
@Environment(NavigationLayer.self) var navigation
@Environment(Palette.self) var palette

@Binding var sort: ApiSortType

Expand Down Expand Up @@ -46,7 +47,7 @@ struct FeedSortPicker: View {
}

var body: some View {
Menu(sort.label(topFormat: topSortTypes.count == 1 ? .topOnly : .topAndTimescale), systemImage: sort.systemImage) {
Menu {
Section {
ForEach(nonTopSortTypes, id: \.self) { type in
Toggle(
Expand Down Expand Up @@ -77,6 +78,26 @@ struct FeedSortPicker: View {
navigation.openSheet(.advancedSorting($sort))
}
}
} label: {
if ApiSortType.topCases.contains(sort) {
HStack {
Image(systemName: Icons.topSort)
.imageScale(.small)
Text(sort.label(topFormat: .timescaleAbbreviated))
.font(.footnote)
.fontDesign(.rounded)
}
.padding(.horizontal, 10)
.padding(.vertical, 5)
.background {
Capsule()
// 1.51 is intentional - iOS doesn't render it quite right at 1.5 (iPhone 12)
.strokeBorder(palette.accent, lineWidth: 1.51)
}
.accessibilityLabel(sort.label(topFormat: .topAndTimescale))
} else {
Label(sort.label(topFormat: topSortTypes.count == 1 ? .topOnly : .topAndTimescale), systemImage: sort.systemImage)
}
}
.disabled(appState.firstApi.fetchedVersion == nil)
.popover(isPresented: $topSortPopupPresented) {
Expand All @@ -88,4 +109,11 @@ struct FeedSortPicker: View {
.presentationCompactAdaptation(.popover)
}
}

var formatter: DateComponentsFormatter {
let formatter = DateComponentsFormatter()
formatter.unitsStyle = .abbreviated
formatter.maximumUnitCount = 1
return formatter
}
}
9 changes: 1 addition & 8 deletions Mlem/App/Views/Pages/Community/TopSortPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct TopSortPicker: View {
Text("All Time")
}
} else {
Text(formatter.string(from: type.dateComponents ?? .init()) ?? "")
Text(type.label(topFormat: .timescaleAbbreviated))
}
}
.frame(maxWidth: .infinity)
Expand All @@ -69,11 +69,4 @@ struct TopSortPicker: View {
}
.foregroundStyle(palette.primary)
}

var formatter: DateComponentsFormatter {
let formatter = DateComponentsFormatter()
formatter.unitsStyle = .abbreviated
formatter.maximumUnitCount = 1
return formatter
}
}
4 changes: 4 additions & 0 deletions Mlem/App/Views/Root/Tabs/Feeds/FeedSelection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ enum FeedSelection: String, CaseIterable, Codable {
}
}

var label: LocalizedStringResource {
description.label
}

var description: FeedDescription {
switch self {
case .all: .all
Expand Down
24 changes: 17 additions & 7 deletions Mlem/App/Views/Root/Tabs/Settings/AccessibilitySettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import SwiftUI

struct AccessibilitySettingsView: View {
@Environment(Palette.self) var palette
@Environment(\.accessibilityDifferentiateWithoutColor) var differentiateWithoutColor: Bool

@Setting(\.readPostIndicator) var readPostIndicator
Expand All @@ -16,13 +17,22 @@ struct AccessibilitySettingsView: View {

var body: some View {
Form {
SettingsHeaderView(
title: "Accessibility",
description: "Customize Mlem to work best for you. Some features are tied to system-wide accessibility settings.",
systemImage: "hand.point.up.braille.fill"
)
.tint(palette.colorfulAccent(2))
if differentiateWithoutColor {
NavigationLink(
"Post Read Indicator",
value: .init(localized: readPostIndicator.label),
fallbackValue: "",
destination: .settings(.postReadIndicator)
)
Section {
NavigationLink(
"Post Read Indicator",
value: .init(localized: readPostIndicator.label),
fallbackValue: "",
systemImage: Icons.read,
destination: .settings(.postReadIndicator)
)
}
}

Section {
Expand All @@ -31,6 +41,6 @@ struct AccessibilitySettingsView: View {
}
}
.labelStyle(.conditional)
.navigationTitle("Accessibility")
.contentMargins(.top, 16)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct CommentJumpButtonSettingsView: View {
}
}
.labelStyle(.conditional)
.contentMargins(.top, 16)
.animation(.easeOut(duration: 0.1), value: jumpButton == .none)
}

Expand Down
33 changes: 33 additions & 0 deletions Mlem/App/Views/Root/Tabs/Settings/DefaultFeedSettingsView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// DefaultFeedSettingsView.swift
// Mlem
//
// Created by Sjmarf on 2025-01-31.
//

import SwiftUI

struct DefaultFeedSettingsView: View {
@Setting(\.defaultFeed) var defaultFeed

var body: some View {
Form {
SettingsHeaderView(
title: "Default Feed",
description: "Choose which feed is shown when the app opens."
) {}
Picker("Default Feed", selection: $defaultFeed) {
ForEach(FeedSelection.allCases, id: \.self) { item in
Label {
Text(item.description.label)
} icon: {
FeedIconView(feedDescription: item.description, size: 30)
}
}
}
.pickerStyle(.inline)
.labelsHidden()
}
.contentMargins(.top, 16)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct EmbeddingSettingsView: View {
var body: some View {
Form {
SettingsHeaderView(
title: "Embeddings",
title: "Embedded Content",
description: "Display linked media from supported hosts in-app rather than as a link.",
systemImage: Icons.embedding
)
Expand Down
Loading

0 comments on commit 1d5f902

Please sign in to comment.