Skip to content

Commit

Permalink
Merge branch 'dev' into sjmarf/app-icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjmarf committed Jan 4, 2024
2 parents 8fcc6c4 + ce2363f commit 7523297
Show file tree
Hide file tree
Showing 82 changed files with 2,578 additions and 2,501 deletions.
158 changes: 53 additions & 105 deletions Mlem.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Mlem/API/Models/Community/APISubscribedStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum APISubscribedStatus: String, Decodable {

var isSubscribed: Bool {
switch self {
case .subscribed:
case .subscribed, .pending:
true
default:
false
Expand Down
4 changes: 2 additions & 2 deletions Mlem/API/Models/Person/APIPersonAggregates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct APIPersonAggregates: Decodable {
let id: Int? // TODO: 0.18 Deprecation remove this field
let personId: Int
let postCount: Int
let postScore: Int?
let postScore: Int? // TODO: 0.18 Deprecation remove this field
let commentCount: Int
let commentScore: Int?
let commentScore: Int? // TODO: 0.18 Deprecation remove this field
}
35 changes: 22 additions & 13 deletions Mlem/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct ContentView: View {
@Dependency(\.errorHandler) var errorHandler
@Dependency(\.personRepository) var personRepository
@Dependency(\.hapticManager) var hapticManager
@Dependency(\.siteInformation) var siteInformation
@Dependency(\.accountsTracker) var accountsTracker

@Environment(\.setAppFlow) private var setFlow
Expand Down Expand Up @@ -41,6 +42,14 @@ struct ContentView: View {

var accessibilityFont: Bool { UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory }

var myUser: UserModel? {
if let person = siteInformation.myUserInfo?.localUserView.person {
return UserModel(from: person)
} else {
return nil
}
}

var body: some View {
FancyTabBar(selection: $tabSelection, navigationSelection: $tabNavigation, dragUpGestureCallback: showAccountSwitcherDragCallback) {
Group {
Expand All @@ -64,20 +73,20 @@ struct ContentView: View {
badgeCount: showInboxUnreadBadge ? unreadTracker.total : 0
)
}
}

ProfileView(userID: account.id)
.fancyTabItem(tag: TabSelection.profile) {
FancyTabBarLabel(
tag: TabSelection.profile,
customText: appState.tabDisplayName,
symbolConfiguration: .init(
symbol: FancyTabBarLabel.SymbolConfiguration.profile.symbol,
activeSymbol: FancyTabBarLabel.SymbolConfiguration.profile.activeSymbol,
remoteSymbolUrl: appState.profileTabRemoteSymbolUrl
)
)
.simultaneousGesture(accountSwitchLongPress)
}
ProfileView(user: myUser)
.fancyTabItem(tag: TabSelection.profile) {
FancyTabBarLabel(
tag: TabSelection.profile,
customText: appState.tabDisplayName,
symbolConfiguration: .init(
symbol: FancyTabBarLabel.SymbolConfiguration.profile.symbol,
activeSymbol: FancyTabBarLabel.SymbolConfiguration.profile.activeSymbol,
remoteSymbolUrl: appState.profileTabRemoteSymbolUrl
)
)
.simultaneousGesture(accountSwitchLongPress)
}

SearchRoot()
Expand Down
12 changes: 0 additions & 12 deletions Mlem/Enums/Errors/Critical Errors.swift

This file was deleted.

42 changes: 34 additions & 8 deletions Mlem/Enums/FeedType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,40 @@
// Created by Jonathan de Jong on 12.06.2023.
//

import Foundation
import SwiftUI

enum FeedType: String, Encodable, SettingsOptions {
enum FeedType: String, Encodable, SettingsOptions, AssociatedColor {
var id: Self { self }

var label: String {
return rawValue
}

var description: String {
switch self {
case .all: return rawValue
case .local: return rawValue
case .subscribed: return rawValue
case .all:
return "Subscribed communities from all instances"
case .local:
return "Local communities from your server"
case .subscribed:
return "All communities that federate with your server"
}
}

case all = "All"
case local = "Local"
var color: Color? {
switch self {
case .all:
return .blue
case .local:
return .green
case .subscribed:
return .red
}
}

case subscribed = "Subscribed"
case local = "Local"
case all = "All"
}

extension FeedType: AssociatedIcon {
Expand All @@ -34,12 +52,20 @@ extension FeedType: AssociatedIcon {

var iconNameFill: String {
switch self {
case .all: return Icons.federatedFeed
case .all: return Icons.federatedFeedFill
case .local: return Icons.localFeedFill
case .subscribed: return Icons.subscribedFeedFill
}
}

var iconNameCircle: String {
switch self {
case .all: return Icons.federatedFeedCircle
case .local: return Icons.localFeedCircle
case .subscribed: return Icons.subscribedFeedCircle
}
}

/// Icon to use in system settings. This should be removed when the "unified symbol handling" is closed
var settingsIconName: String {
switch self {
Expand Down
12 changes: 0 additions & 12 deletions Mlem/Enums/My Vote.swift

This file was deleted.

23 changes: 23 additions & 0 deletions Mlem/Enums/SearchTab.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// SearchTab.swift
// Mlem
//
// Created by Sjmarf on 27/12/2023.
//

enum SearchTab: String, CaseIterable, Identifiable {
case topResults, communities, users

var id: Self { self }

var label: String {
switch self {
case .topResults:
return "Top Results"
default:
return rawValue.capitalized
}
}

static var homePageCases: [SearchTab] = [.communities, .users]
}
10 changes: 5 additions & 5 deletions Mlem/Enums/Settings/PostSortType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ extension PostSortType: SettingsOptions {
var label: String {
switch self {
case .newComments:
return "New comments"
return "New Comments"
case .mostComments:
return "Most comments"
return "Most Comments"
case .topHour:
return "Hour"
case .topSixHour:
return "Six hours"
return "Six Hours"
case .topTwelveHour:
return "Twelve hours"
return "Twelve Hours"
case .topDay:
return "Day"
case .topWeek:
Expand All @@ -182,7 +182,7 @@ extension PostSortType: SettingsOptions {
case .topYear:
return "Year"
case .topAll:
return "All time"
return "All Time"
default:
return rawValue
}
Expand Down
6 changes: 1 addition & 5 deletions Mlem/Enums/User/UserViewTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
import Foundation

enum UserViewTab: String, CaseIterable, Identifiable {
case overview, comments, posts, saved
case overview, comments, posts, communities, saved

var id: Self { self }

var label: String {
rawValue.capitalized
}

var onlyShowInOwnProfile: Bool {
self == UserViewTab.saved
}
}
4 changes: 2 additions & 2 deletions Mlem/Extensions/Date/Date+RelativeTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import SwiftUI

extension Date {
// Returns strings like "3 seconds ago" and "10 days ago"
func getRelativeTime(date: Date) -> String {
func getRelativeTime(date: Date, unitsStyle: RelativeDateTimeFormatter.UnitsStyle = .full) -> String {
let formatter = RelativeDateTimeFormatter()
formatter.unitsStyle = .full
formatter.unitsStyle = unitsStyle

return formatter.localizedString(for: self, relativeTo: date)
}
Expand Down
14 changes: 7 additions & 7 deletions Mlem/Extensions/Mocks/APICommunityAggregates+Mock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ extension APICommunityAggregates {
static func mock(
id: Int = 0,
communityId: Int = 0,
subscribers: Int = 0,
posts: Int = 0,
comments: Int = 0,
subscribers: Int = 42349,
posts: Int = 300,
comments: Int = 5000,
published: Date = .mock,
usersActiveDay: Int = 0,
usersActiveWeek: Int = 0,
usersActiveMonth: Int = 0,
usersActiveHalfYear: Int = 0
usersActiveDay: Int = 3040,
usersActiveWeek: Int = 20044,
usersActiveMonth: Int = 50403,
usersActiveHalfYear: Int = 73032
) -> APICommunityAggregates {
.init(
id: id,
Expand Down
22 changes: 7 additions & 15 deletions Mlem/Extensions/View Modifiers/View+HandleLemmyLinks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,15 @@ struct HandleLemmyLinksDisplay: ViewModifier {
.navigationDestination(for: AppRoute.self) { route in
switch route {
case let .community(community):
FeedView(community: community, feedType: .all)
CommunityView(community: community)
.environmentObject(appState)
.environmentObject(filtersTracker)
.environmentObject(quickLookState)
case let .communityLinkWithContext(context):
FeedView(community: context.community, feedType: context.feedType)
FeedParentView(community: context.community, feedType: context.feedType)
.environmentObject(appState)
.environmentObject(filtersTracker)
.environmentObject(quickLookState)
case let .communitySidebarLinkWithContext(context):
CommunitySidebarView(
community: context.community
)
.environmentObject(filtersTracker)
case let .apiPostView(post):
let postModel = PostModel(from: post)
let postTracker = PostTracker(
Expand All @@ -61,25 +56,22 @@ struct HandleLemmyLinksDisplay: ViewModifier {
LazyLoadExpandedPost(post: post)
.environmentObject(quickLookState)
case let .apiPerson(user):
UserView(userID: user.id)
UserView(user: UserModel(from: user))
.environmentObject(appState)
.environmentObject(quickLookState)
case let .userProfile(user):
UserView(userID: user.userId)
case let .userProfile(user, communityContext):
UserView(user: user, communityContext: communityContext)
.environmentObject(appState)
.environmentObject(quickLookState)
case let .postLinkWithContext(post):
ExpandedPost(post: post.post, scrollTarget: post.scrollTarget)
ExpandedPost(post: post.post, community: post.community, scrollTarget: post.scrollTarget)
.environmentObject(post.postTracker)
.environmentObject(appState)
.environmentObject(quickLookState)
.environmentObject(layoutWidgetTracker)
case let .lazyLoadPostLinkWithContext(post):
LazyLoadExpandedPost(post: post.post, scrollTarget: post.scrollTarget)
.environmentObject(quickLookState)
case let .userModeratorLink(user):
UserModeratorView(userDetails: user.user, moderatedCommunities: user.moderatedCommunities)
.environmentObject(appState)
.environmentObject(quickLookState)
case let .settings(page):
settingsDestination(for: page)
case let .aboutSettings(page):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct NavigationBarColorModifier: ViewModifier {
} else {
content
.toolbarBackground(Color.systemBackground, for: .navigationBar)
.toolbarBackground(.visible, for: .navigationBar)
.toolbarBackground(visibility, for: .navigationBar)
}
}
}
Expand Down
23 changes: 17 additions & 6 deletions Mlem/Icons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,18 @@ struct Icons {
static let largePostFill: String = "text.below.photo.fill"

// feeds
static let federatedFeed: String = "circle.hexagongrid.circle"
static let federatedFeedFill: String = "circle.hexagongrid.circle.fill"
static let localFeed: String = "house.circle"
static let localFeedFill: String = "house.circle.fill"
static let subscribedFeed: String = "newspaper.circle"
static let subscribedFeedFill: String = "newspaper.circle.fill"
static let federatedFeed: String = "circle.hexagongrid"
static let federatedFeedFill: String = "circle.hexagongrid.fill"
static let federatedFeedCircle: String = "circle.hexagongrid.circle.fill"
static let localFeed: String = "house"
static let localFeedFill: String = "house.fill"
static let localFeedCircle: String = "house.circle.fill"
static let subscribedFeed: String = "newspaper"
static let subscribedFeedFill: String = "newspaper.fill"
static let subscribedFeedCircle: String = "newspaper.circle.fill"
static let savedFeed: String = "bookmark"
static let savedFeedFill: String = "bookmark.fill"
static let savedFeedCircle: String = "bookmark.circle.fill"

// sort types
static let activeSort: String = "popcorn"
Expand Down Expand Up @@ -134,8 +140,11 @@ struct Icons {
static let updated: String = "clock.arrow.2.circlepath"
static let favorite: String = "star"
static let favoriteFill: String = "star.fill"
static let unfavorite: String = "star.slash"
static let unfavoriteFill: String = "star.slash.fill"
static let personFill: String = "person.fill"
static let close: String = "multiply"
static let cakeDay: String = "birthday.cake"

// end of feed
static let endOfFeedHobbit: String = "figure.climbing"
Expand All @@ -153,10 +162,12 @@ struct Icons {
static let filter: String = "line.3.horizontal.decrease.circle"
static let filterFill: String = "line.3.horizontal.decrease.circle.fill"
static let menu: String = "ellipsis"
static let menuCircle: String = "ellipsis.circle"
static let `import`: String = "square.and.arrow.down"
static let attachment: String = "paperclip"
static let edit: String = "pencil"
static let delete: String = "trash"
static let copy: String = "doc.on.doc"

// settings
static let upvoteOnSave: String = "arrow.up.heart"
Expand Down
Loading

0 comments on commit 7523297

Please sign in to comment.