Skip to content

Commit

Permalink
Improved Use of SFSymbols (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBAndrews authored Sep 25, 2023
1 parent e775be9 commit b82c176
Show file tree
Hide file tree
Showing 75 changed files with 435 additions and 366 deletions.
4 changes: 4 additions & 0 deletions Mlem.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@
CDF842682A49FB9000723DA0 /* Inbox View Logic.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF842672A49FB9000723DA0 /* Inbox View Logic.swift */; };
CDF8426B2A4A2AB600723DA0 /* Inbox Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF8426A2A4A2AB600723DA0 /* Inbox Item.swift */; };
CDF8426F2A4A385A00723DA0 /* Inbox Item Type.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF8426E2A4A385A00723DA0 /* Inbox Item Type.swift */; };
CDF9EF332AB2845C003F885B /* Icons.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF9EF322AB2845C003F885B /* Icons.swift */; };
E40E018C2AABF85500410B2C /* NavigationRoutes.swift in Sources */ = {isa = PBXBuildFile; fileRef = E40E018B2AABF85500410B2C /* NavigationRoutes.swift */; };
E40E018E2AABFBDE00410B2C /* NavigationRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = E40E018D2AABFBDE00410B2C /* NavigationRouter.swift */; };
E40E01902AABFC9300410B2C /* AnyNavigationPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = E40E018F2AABFC9300410B2C /* AnyNavigationPath.swift */; };
Expand Down Expand Up @@ -866,6 +867,7 @@
CDF842672A49FB9000723DA0 /* Inbox View Logic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Inbox View Logic.swift"; sourceTree = "<group>"; };
CDF8426A2A4A2AB600723DA0 /* Inbox Item.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Inbox Item.swift"; sourceTree = "<group>"; };
CDF8426E2A4A385A00723DA0 /* Inbox Item Type.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Inbox Item Type.swift"; sourceTree = "<group>"; };
CDF9EF322AB2845C003F885B /* Icons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Icons.swift; sourceTree = "<group>"; };
E40E018B2AABF85500410B2C /* NavigationRoutes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationRoutes.swift; sourceTree = "<group>"; };
E40E018D2AABFBDE00410B2C /* NavigationRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationRouter.swift; sourceTree = "<group>"; };
E40E018F2AABFC9300410B2C /* AnyNavigationPath.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyNavigationPath.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1488,6 +1490,7 @@
503422572AAB798600EFE88D /* AppFlow.swift */,
6386E02B2A03D1EC006B3C1D /* App State.swift */,
63DF71F02A02999C002AC14E /* App Constants.swift */,
CDF9EF322AB2845C003F885B /* Icons.swift */,
B1B78D632A51D53900F72485 /* AppDelegate.swift */,
6363D5C827EE196A00E34822 /* Assets.xcassets */,
6363D5CA27EE196A00E34822 /* Preview Content */,
Expand Down Expand Up @@ -2680,6 +2683,7 @@
CD04D5DF2A361585008EF95B /* Empty Button Style.swift in Sources */,
CD69F55B2A400D820028D4F7 /* App Theme.swift in Sources */,
CDEBC3392A9ADE6C00518D9D /* APIClient+Post.swift in Sources */,
CDF9EF332AB2845C003F885B /* Icons.swift in Sources */,
B14E93C22A45D3B300D6DA93 /* Community Link.swift in Sources */,
637218712A3A2AAD008C4816 /* GetSite.swift in Sources */,
CD0BE42F2A65A73600314B24 /* Haptic Manager.swift in Sources */,
Expand Down
18 changes: 18 additions & 0 deletions Mlem/API/Models/ScoringOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,21 @@ enum ScoringOperation: Int, Decodable {
case downvote = -1
case resetVote = 0
}

extension ScoringOperation: AssociatedIcon {
var iconName: String {
switch self {
case .upvote: return Icons.upvoteSquare
case .downvote: return Icons.downvoteSquare
case .resetVote: return Icons.resetVoteSquare
}
}

var iconNameFill: String {
switch self {
case .upvote: return Icons.upvoteSquareFill
case .downvote: return Icons.downvoteSquareFill
case .resetVote: return Icons.resetVoteSquareFill
}
}
}
101 changes: 0 additions & 101 deletions Mlem/App Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,107 +55,6 @@ struct AppConstants {
static let editorOverscroll: CGFloat = 30
static let expandedPostOverscroll: CGFloat = 80

// MARK: - SFSymbols

// votes
static let generalVoteSymbolName: String = "arrow.up.arrow.down.square"

static let plainUpvoteSymbolName: String = "arrow.up"
static let emptyUpvoteSymbolName: String = "arrow.up.square"
static let fullUpvoteSymbolName: String = "arrow.up.square.fill"

static let plainDownvoteSymbolName: String = "arrow.down"
static let emptyDownvoteSymbolName: String = "arrow.down.square"
static let fullDownvoteSymbolName: String = "arrow.down.square.fill"

static let emptyResetVoteSymbolName: String = "minus.square"
static let fullResetVoteSymbolName: String = "minus.square.fill"
static let scoringOpToVoteImage: [ScoringOperation?: String] = [.upvote: "arrow.up.square.fill",
.resetVote: "arrow.up.square",
.downvote: "arrow.down.square.fill"]

// reply/send
static let emptyReplySymbolName: String = "arrowshape.turn.up.left"
static let fullReplySymbolName: String = "arrowshape.turn.up.left.fill"
static let sendSymbolName: String = "paperplane"
static let sendSymbolNameFill: String = "paperplane.fill"

// save
static let emptySaveSymbolName: String = "bookmark"
static let fullSaveSymbolName: String = "bookmark.fill"
static let emptyUndoSaveSymbolName: String = "bookmark.slash"
static let fullUndoSaveSymbolName: String = "bookmark.slash.fill"

// mark read
static let emptyMarkReadSymbolName: String = "envelope"
static let fullMarkReadSymbolName: String = "envelope.open.fill"
static let emptyMarkUnreadSymbolName: String = "envelope.open"
static let fullMarkUnreadSymbolName: String = "envelope.fill"

// report/block
static let reportSymbolName: String = "exclamationmark.shield"
static let blockUserSymbolName: String = "person.fill.xmark"

// post sizes
static let postSizeSettingsSymbolName: String = "rectangle.expand.vertical"
static let compactSymbolName: String = "rectangle.grid.1x2"
static let compactSymbolNameFill: String = "rectangle.grid.1x2.fill"
static let headlineSymbolName: String = "rectangle"
static let headlineSymbolNameFill: String = "rectangle.fill"
static let largeSymbolName: String = "text.below.photo"
static let largeSymbolNameFill: String = "text.below.photo.fill"
static let blurNsfwSymbolName: String = "eye.trianglebadge.exclamationmark"

// feeds
static let federatedFeedSymbolName: String = "circle.hexagongrid.circle" // "arrow.left.arrow.right.circle"
static let federatedFeedSymbolNameFill: String = "circle.hexagongrid.circle.fill" // "arrow.left.arrow.right.circle.fill"
static let localFeedSymbolName: String = "house.circle"
static let localFeedSymbolNameFill: String = "house.circle.fill"
static let subscribedFeedSymbolName: String = "newspaper.circle"
static let subscribedFeedSymbolNameFill: String = "newspaper.circle.fill"
static let limitImageHeightInFeedSymbolName: String = "rectangle.compress.vertical"

// sort types
static let activeSortSymbolName: String = "popcorn" // not married to this idea
static let activeSortSymbolNameFill: String = "popcorn.fill"
static let hotSortSymbolName: String = "flame"
static let hotSortSymbolNameFill: String = "flame.fill"
// we can workshop new/old--books is already used for documentation and there's an issue open saying that "new" needs a better symbol. I thought these two were funny together.
static let newSortSymbolName: String = "hare"
static let newSortSymbolNameFill: String = "hare.fill"
static let oldSortSymbolName: String = "tortoise"
static let oldSortSymbolNameFill: String = "tortoise.fill"
static let newCommentsSymbolName: String = "exclamationmark.bubble"
static let newCommentsSymbolNameFill: String = "exclamationmark.bubble.fill"
static let mostCommentsSymbolName: String = "bubble.left.and.bubble.right"
static let mostCommentsSymbolNameFill: String = "bubble.left.and.bubble.right.fill"
static let topSymbolName: String = "trophy"
static let topSymbolNameFill: String = "trophy.fill"
static let timeSymbolName: String = "calendar.day.timeline.leading"
static let timeSymbolNameFill: String = "calendar.day.timeline.leading.fill"

// common operations
static let shareSymbolName: String = "square.and.arrow.up"
static let subscribeSymbolName: String = "plus.circle"
static let unsubscribeSymbolName: String = "multiply.circle"
static let blockSymbolName: String = "eye.slash"
static let unblockSymbolName: String = "eye"
static let filterSymbolName: String = "line.3.horizontal.decrease.circle"
static let filterSymbolNameFill: String = "line.3.horizontal.decrease.circle.fill"

// misc
static let switchUserSymbolName: String = "person.crop.circle.badge.plus"
static let missingSymbolName: String = "questionmark.square.dashed"
static let connectionSymbolName: String = "antenna.radiowaves.left.and.right"
static let hapticSymbolName: String = "hand.tap"
static let transparencySymbolName: String = "square.on.square.intersection.dashed"
static let presentSymbolName: String = "circle.fill"
static let absentSymbolName: String = "circle"
static let iconSymbolName: String = "fleuron"
static let userSymbolName: String = "person.circle"
static let bannerSymbolName: String = "flag"
static let communitySymbolName: String = "building.2.crop.circle"

// MARK: - Other

static let pictureEmoji: [String] = ["🎆", "🎇", "🌠", "🌅", "🌆", "🌁", "🌃", "🌄", "🌉", "🌌", "🌇", "🖼️", "🎑", "🏞️", "🗾", "🏙️"]
Expand Down
10 changes: 5 additions & 5 deletions Mlem/Custom Tab Bar/FancyTabBarLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ struct FancyTabBarLabel: View {
let activeSymbol: String
let remoteSymbolUrl: URL?

static var feed: Self { .init(symbol: "scroll", activeSymbol: "scroll.fill", remoteSymbolUrl: nil) }
static var inbox: Self { .init(symbol: "mail.stack", activeSymbol: "mail.stack.fill", remoteSymbolUrl: nil) }
static var profile: Self { .init(symbol: "person.circle", activeSymbol: "person.circle.fill", remoteSymbolUrl: nil) }
static var search: Self { .init(symbol: "magnifyingglass", activeSymbol: "text.magnifyingglass", remoteSymbolUrl: nil) }
static var settings: Self { .init(symbol: "gear", activeSymbol: "gear", remoteSymbolUrl: nil) }
static var feed: Self { .init(symbol: Icons.feeds, activeSymbol: Icons.feedsFill, remoteSymbolUrl: nil) }
static var inbox: Self { .init(symbol: Icons.inbox, activeSymbol: Icons.inboxFill, remoteSymbolUrl: nil) }
static var profile: Self { .init(symbol: Icons.user, activeSymbol: Icons.userFill, remoteSymbolUrl: nil) }
static var search: Self { .init(symbol: Icons.search, activeSymbol: Icons.searchActive, remoteSymbolUrl: nil) }
static var settings: Self { .init(symbol: Icons.settings, activeSymbol: Icons.settings, remoteSymbolUrl: nil) }
}

@Environment(\.tabSelectionHashValue) private var selectedTagHashValue
Expand Down
12 changes: 6 additions & 6 deletions Mlem/Enums/FeedType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ enum FeedType: String, Encodable, SettingsOptions {
extension FeedType: AssociatedIcon {
var iconName: String {
switch self {
case .all: return AppConstants.federatedFeedSymbolName
case .local: return AppConstants.localFeedSymbolName
case .subscribed: return AppConstants.subscribedFeedSymbolName
case .all: return Icons.federatedFeed
case .local: return Icons.localFeed
case .subscribed: return Icons.subscribedFeed
}
}

var iconNameFill: String {
switch self {
case .all: return AppConstants.federatedFeedSymbolName
case .local: return AppConstants.localFeedSymbolNameFill
case .subscribed: return AppConstants.subscribedFeedSymbolNameFill
case .all: return Icons.federatedFeed
case .local: return Icons.localFeedFill
case .subscribed: return Icons.subscribedFeedFill
}
}

Expand Down
12 changes: 6 additions & 6 deletions Mlem/Enums/Settings/PostSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ extension PostSize: SettingsOptions {
extension PostSize: AssociatedIcon {
var iconName: String {
switch self {
case .compact: return AppConstants.compactSymbolName
case .headline: return AppConstants.headlineSymbolName
case .large: return AppConstants.largeSymbolName
case .compact: return Icons.compactPost
case .headline: return Icons.headlinePost
case .large: return Icons.largePost
}
}

var iconNameFill: String {
switch self {
case .compact: return AppConstants.compactSymbolNameFill
case .headline: return AppConstants.headlineSymbolNameFill
case .large: return AppConstants.largeSymbolNameFill
case .compact: return Icons.compactPostFill
case .headline: return Icons.headlinePostFill
case .large: return Icons.largePostFill
}
}
}
28 changes: 14 additions & 14 deletions Mlem/Enums/Settings/PostSortType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,25 @@ extension PostSortType: SettingsOptions {
extension PostSortType: AssociatedIcon {
var iconName: String {
switch self {
case .active: return AppConstants.activeSortSymbolName
case .hot: return AppConstants.hotSortSymbolName
case .new: return AppConstants.newSortSymbolName
case .old: return AppConstants.oldSortSymbolName
case .newComments: return AppConstants.newCommentsSymbolName
case .mostComments: return AppConstants.mostCommentsSymbolName
default: return AppConstants.timeSymbolName
case .active: return Icons.activeSort
case .hot: return Icons.hotSort
case .new: return Icons.newSort
case .old: return Icons.oldSort
case .newComments: return Icons.newCommentsSort
case .mostComments: return Icons.mostCommentsSort
default: return Icons.timeSort
}
}

var iconNameFill: String {
switch self {
case .active: return AppConstants.activeSortSymbolNameFill
case .hot: return AppConstants.hotSortSymbolNameFill
case .new: return AppConstants.newSortSymbolNameFill
case .old: return AppConstants.oldSortSymbolNameFill
case .newComments: return AppConstants.newCommentsSymbolNameFill
case .mostComments: return AppConstants.mostCommentsSymbolNameFill
default: return AppConstants.timeSymbolNameFill
case .active: return Icons.activeSortFill
case .hot: return Icons.hotSortFill
case .new: return Icons.newSortFill
case .old: return Icons.oldSortFill
case .newComments: return Icons.newCommentsSortFill
case .mostComments: return Icons.mostCommentsSortFill
default: return Icons.timeSortFill
}
}
}
4 changes: 2 additions & 2 deletions Mlem/Extensions/AlternativeIconCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct AlternativeIconCell: View {
}
Spacer()
if icon.selected {
Image(systemName: "checkmark")
Image(systemName: Icons.success)
}
}
}.accessibilityElement(children: .combine)
Expand All @@ -51,7 +51,7 @@ struct AlternativeIconCell: View {
.flatMap { UIImage(named: $0) }
.map {
Image(uiImage: $0)
} ?? Image(systemName: "questionmark.folder")
} ?? Image(systemName: Icons.noFile)
}
return Image(uiImage: UIImage(named: id) ?? UIImage(imageLiteralResourceName: id))
}
Expand Down
4 changes: 2 additions & 2 deletions Mlem/Extensions/NSFW Overlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct NSFWOverlay: ViewModifier {
var nsfwOverlay: some View {
if showNsfwFilter {
VStack {
Image(systemName: "exclamationmark.triangle")
Image(systemName: Icons.warning)
.font(.largeTitle)
Text("NSFW")
.fontWeight(.black)
Expand All @@ -50,7 +50,7 @@ struct NSFWOverlay: ViewModifier {
.background(.thinMaterial)
.cornerRadius(AppConstants.largeItemCornerRadius)
} else if isNsfw, shouldBlurNsfw {
Image(systemName: "eye.slash")
Image(systemName: Icons.hide)
.foregroundColor(.white)
.padding(4)
.background(.thinMaterial)
Expand Down
4 changes: 2 additions & 2 deletions Mlem/Extensions/Swipey Actions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ struct SwipeyView: ViewModifier {
dragBackground
.overlay {
HStack(spacing: 0) {
Image(systemName: leadingSwipeSymbol ?? "exclamationmark.triangle")
Image(systemName: leadingSwipeSymbol ?? Icons.warning)
.font(.title)
.frame(width: 20, height: 20)
.foregroundColor(.white)
.padding(.horizontal, 20)
Spacer()
Image(systemName: trailingSwipeSymbol ?? "exclamationmark.triangle")
Image(systemName: trailingSwipeSymbol ?? Icons.warning)
.font(.title)
.frame(width: 20, height: 20)
.foregroundColor(.white)
Expand Down
Loading

0 comments on commit b82c176

Please sign in to comment.