Skip to content

Commit

Permalink
Refactor: SFSafeSymbols
Browse files Browse the repository at this point in the history
  • Loading branch information
autoreleasefool committed Aug 11, 2023
1 parent cb738bd commit 113fd4e
Show file tree
Hide file tree
Showing 25 changed files with 66 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
"version" : "6.16.0"
}
},
{
"identity" : "sfsafesymbols",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SFSafeSymbols/SFSafeSymbols.git",
"state" : {
"revision" : "7cca2d60925876b5953a2cf7341cd80fbeac983c",
"version" : "4.1.1"
}
},
{
"identity" : "swift-algorithms",
"kind" : "remoteSourceControl",
Expand Down
7 changes: 5 additions & 2 deletions ios/Approach/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ let package = Package(
.package(url: "https://github.com/pointfreeco/swift-identified-collections.git", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing.git", from: "1.11.1"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay.git", from: "1.0.0"),
.package(url: "https://github.com/SFSafeSymbols/SFSafeSymbols.git", from: "4.1.1"),
.package(url: "https://github.com/TelemetryDeck/SwiftClient.git", from: "1.4.4"),
],
targets: [
Expand Down Expand Up @@ -398,7 +399,6 @@ let package = Package(
"PreferenceServiceInterface",
"RecentlyUsedServiceInterface",
"SeriesListFeature",
"SortOrderLibrary",
"StatisticsWidgetsLayoutFeature",
]
),
Expand Down Expand Up @@ -500,6 +500,7 @@ let package = Package(
dependencies: [
"GamesListFeature",
"SeriesEditorFeature",
"SortOrderLibrary",
]
),
.testTarget(
Expand Down Expand Up @@ -1166,7 +1167,9 @@ let package = Package(
// MARK: - Libraries
.target(
name: "AssetsLibrary",
dependencies: [],
dependencies: [
.product(name: "SFSafeSymbols", package: "SFSafeSymbols"),
],
resources: [
.process("Resources"),
]
Expand Down
7 changes: 6 additions & 1 deletion ios/Approach/Package.swift.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ libraries = [ "Equatable", "Form", "ModelsViews", "ResourcePicker", "SwiftUIExte
[features.LeaguesList]
features = [ "LeagueEditor", "SeriesList", "StatisticsWidgetsLayout" ]
services = [ "Preference", "RecentlyUsed" ]
libraries = [ "SortOrder" ]

[features.OpponentDetails]
features = [ "BowlerEditor" ]
Expand All @@ -105,6 +104,7 @@ libraries = [ "DateTime", "Equatable", "Form", "ModelsViews", "ResourcePicker",

[features.SeriesList]
features = [ "GamesList", "SeriesEditor" ]
libraries = [ "SortOrder" ]

[features.Settings]
features = [ "FeatureFlagsList", "OpponentsList" ]
Expand Down Expand Up @@ -236,6 +236,7 @@ libraries = [ "Tips" ]

[libraries.Assets]
skip_tests = true
dependencies = [ "SFSafeSymbols" ]
[libraries.Assets.resources]
processed = [ "Resources" ]

Expand Down Expand Up @@ -368,6 +369,10 @@ from = "1.0.0"
url = "https://github.com/pointfreeco/swift-identified-collections.git"
from = "1.0.0"

[dependencies.SFSafeSymbols]
url = "https://github.com/SFSafeSymbols/SFSafeSymbols.git"
from = "4.1.1"

[dependencies.SnapshotTesting]
suitable_for_dependents_matching = "\\w+Tests$"
url = "https://github.com/pointfreeco/swift-snapshot-testing.git"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public struct AccessoriesOverviewView: View {
ForEach(row.group) { kind in
Button { viewStore.send(.didTapGearKind(kind)) } label: {
HStack {
Image(systemName: kind.systemImage)
.resizable()
Image(systemSymbol: kind.systemSymbol)
.scaledToFit()
.frame(width: .smallIcon, height: .smallIcon)
Text(kind.pluralDescription)
Expand Down Expand Up @@ -116,7 +115,7 @@ public struct AccessoriesOverviewView: View {
Button(Strings.Alley.List.add) { viewStore.send(.didTapAddAlley) }
Button(Strings.Gear.List.add) { viewStore.send(.didTapAddGear) }
} label: {
Image(systemName: "plus")
Image(systemSymbol: .plus)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public struct AlleyEditorView: View {
Spacer()
if viewStore.location != nil {
Button { viewStore.send(.didTapRemoveAddressButton) } label: {
Image(systemName: "x.circle.fill")
Image(systemSymbol: .xCircleFill)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AssetsLibrary
import ComposableArchitecture
import FeatureActionLibrary
import LaneEditorFeature
Expand Down Expand Up @@ -47,11 +48,11 @@ public struct AlleyLanesEditorView: View {

Section {
Button { viewStore.send(.didTapAddLaneButton) } label: {
Label(Strings.Lane.List.add, systemImage: "plus.square")
Label(Strings.Lane.List.add, systemSymbol: .plusSquare)
}

Button { viewStore.send(.didTapAddMultipleLanesButton) } label: {
Label(Strings.Lane.List.addMultiple, systemImage: "plus.square.on.square")
Label(Strings.Lane.List.addMultiple, systemSymbol: .plusSquareOnSquare)
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions ios/Approach/Sources/AppFeature/TabbedContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public struct TabbedContentView: View {
}
.tag(tab)
.tabItem {
Label(tab.name, systemImage: tab.image)
Label(tab.name, systemSymbol: tab.symbol)
}
}
}
Expand Down Expand Up @@ -84,16 +84,16 @@ extension TabbedContent.Tab {
}
}

var image: String {
var symbol: SFSymbol {
switch self {
case .accessories:
return "bag"
return .bag
case .settings:
return "gear"
return .gear
case .overview:
return "figure.bowling"
return .figureBowling
case .statistics:
return "chart.bar"
return .chartBar
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@_exported import SFSafeSymbols
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AssetsLibrary
import AvatarServiceInterface
import ComposableArchitecture
import ModelsLibrary
Expand Down Expand Up @@ -26,7 +27,7 @@ public struct AvatarEditorView: View {
VStack {
AvatarView(viewStore.avatar, size: .extraLargeIcon)
LazyVGrid(columns: [.init(), .init(), .init()]) {
Image(systemName: "camera")
Image(systemSymbol: .camera)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: .smallIcon, height: .smallIcon)
Expand All @@ -36,7 +37,7 @@ public struct AvatarEditorView: View {
.frame(width: .largeIcon, height: .largeIcon)
}

Image(systemName: "photo.on.rectangle")
Image(systemSymbol: .photoOnRectangle)
.resizable()
.frame(width: .standardIcon, height: .standardIcon)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public struct GameDetailsHeaderView: View {
HStack {
Text(String(describing: next))
.font(.caption)
Image(systemName: "chevron.forward")
Image(systemSymbol: .chevronForward)
.resizable()
.scaledToFit()
.frame(width: .tinyIcon, height: .tinyIcon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public struct GameDetailsView: View {
Strings.Opponent.title,
value: viewStore.game.matchPlay?.opponent?.name ?? Strings.none
)
Image(systemName: "chevron.forward")
Image(systemSymbol: .chevronForward)
.resizable()
.scaledToFit()
.frame(width: .tinyIcon, height: .tinyIcon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ public struct GamesHeaderView: View {
public var body: some View {
WithViewStore(store, observe: { $0 }, send: { .view($0) }, content: { viewStore in
HStack {
headerButton(systemName: "chevron.backward") { viewStore.send(.didTapCloseButton) }
headerButton(systemSymbol: .chevronBackward) { viewStore.send(.didTapCloseButton) }
Spacer()
Text(Strings.Game.titleWithOrdinal(viewStore.currentGameIndex + 1))
.font(.caption)
.foregroundColor(.white)
Spacer()
headerButton(systemName: "gear") { viewStore.send(.didTapSettingsButton) }
headerButton(systemSymbol: .gear) { viewStore.send(.didTapSettingsButton) }
}
})
}

private func headerButton(systemName: String, action: @escaping () -> Void) -> some View {
private func headerButton(systemSymbol: SFSymbol, action: @escaping () -> Void) -> some View {
Button(action: action) {
Image(systemName: systemName)
Image(systemSymbol: systemSymbol)
.resizable()
.scaledToFit()
.frame(width: .smallIcon, height: .smallIcon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public struct RollEditorView: View {
HStack(spacing: .smallSpacing) {
Text(Strings.Roll.Properties.Foul.title)
.foregroundColor(viewStore.didFoul ? Asset.Colors.Error.default.swiftUIColor : .white)
Image(systemName: viewStore.didFoul ? "f.cursive.circle.fill" : "f.cursive.circle")
Image(systemSymbol: viewStore.didFoul ? .fCursiveCircleFill : .fCursiveCircle)
.resizable()
.frame(width: .smallIcon, height: .smallIcon)
.foregroundColor(viewStore.didFoul ? Asset.Colors.Error.default.swiftUIColor : .white)
Expand Down
13 changes: 7 additions & 6 deletions ios/Approach/Sources/ModelsViewsLibrary/Gear+View.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AssetsLibrary
import ModelsLibrary
import SwiftUI

Expand All @@ -10,18 +11,18 @@ extension Gear {
}

public var body: some SwiftUI.View {
Label(gear.name, systemImage: gear.kind.systemImage)
Label(gear.name, systemSymbol: gear.kind.systemSymbol)
}
}
}

extension Gear.Kind {
public var systemImage: String {
public var systemSymbol: SFSymbol {
switch self {
case .bowlingBall: return "poweroutlet.type.h"
case .shoes: return "shoeprints.fill"
case .towel: return "square.split.bottomrightquarter"
case .other: return "questionmark.app"
case .bowlingBall: return .poweroutletTypeH
case .shoes: return .shoeprintsFill
case .towel: return .squareSplitBottomrightquarter
case .other: return .questionmarkApp
}
}
}
2 changes: 1 addition & 1 deletion ios/Approach/Sources/ModelsViewsLibrary/Lane+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension Lane {
.frame(maxWidth: .infinity, alignment: .leading)
// TODO: choose a better icon for the wall indicator
if position != .noWall {
Image(systemName: "decrease.quotelevel")
Image(systemSymbol: .decreaseQuotelevel)
.opacity(0.7)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public struct ResourcePickerView<Resource: PickableResource, Query: Equatable, R
viewStore.send(.didTapResource(resource))
} label: {
HStack(alignment: .center, spacing: .standardSpacing) {
Image(systemName: viewStore.selected.contains(resource.id) ? "checkmark.circle.fill" : "circle")
Image(systemSymbol: viewStore.selected.contains(resource.id) ? .checkmarkCircleFill : .circle)
.resizable()
.frame(width: .smallIcon, height: .smallIcon)
.foregroundColor(Asset.Colors.Action.default)
Expand Down
4 changes: 2 additions & 2 deletions ios/Approach/Sources/SeriesListFeature/SeriesListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ public struct SeriesListItem: View {

VStack(spacing: .standardSpacing) {
HStack {
Label(series.date.longFormat, systemImage: "calendar")
Label(series.date.longFormat, systemSymbol: .calendar)
.font(.subheadline)
.labelStyle(.titleAndIcon)

Spacer()

Image(systemName: "chevron.right")
Image(systemSymbol: .chevronForward)
.scaledToFit()
.frame(width: .tinyIcon, height: .tinyIcon)
}
Expand Down
2 changes: 1 addition & 1 deletion ios/Approach/Sources/SortOrderLibrary/SortOrderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public struct SortOrderView<Ordering: Orderable>: View {
viewStore.send(.didTapOption(ordering))
} label: {
HStack(alignment: .center, spacing: .standardSpacing) {
Image(systemName: viewStore.selected == ordering ? "checkmark.circle.fill" : "circle")
Image(systemSymbol: viewStore.selected == ordering ? .checkmarkCircleFill : .circle)
.resizable()
.frame(width: .smallIcon, height: .smallIcon)
.foregroundColor(Asset.Colors.Action.default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct MoveableWidget: View {
.fill(Asset.Colors.Destructive.default.swiftUIColor)
.frame(width: .smallerIcon, height: .smallerIcon)

Image(systemName: "xmark")
Image(systemSymbol: .xmark)
.resizable()
.scaledToFit()
.frame(width: .tinyIcon, height: .tinyIcon)
Expand Down
3 changes: 2 additions & 1 deletion ios/Approach/Sources/TipsLibrary/Views/BasicTipView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AssetsLibrary
import SwiftUI
import ViewsLibrary

Expand All @@ -17,7 +18,7 @@ public struct BasicTipView: View {
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
Button(action: onDismiss) {
Image(systemName: "xmark")
Image(systemSymbol: .xmark)
.resizable()
.scaledToFit()
.frame(width: .smallIcon, height: .smallSpacing)
Expand Down
3 changes: 2 additions & 1 deletion ios/Approach/Sources/ViewsLibrary/Buttons/AddButton.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AssetsLibrary
import SwiftUI

public struct AddButton: View {
Expand All @@ -9,7 +10,7 @@ public struct AddButton: View {

public var body: some View {
Button(action: perform) {
Image(systemName: "plus")
Image(systemSymbol: .plus)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct DeleteButton: View {

public var body: some View {
Button(role: .destructive, action: perform) {
Label(Strings.Action.delete, systemImage: "trash")
Label(Strings.Action.delete, systemSymbol: .trash)
.foregroundColor(Asset.Colors.Destructive.default)
}
.tint(Asset.Colors.Destructive.default)
Expand Down
2 changes: 1 addition & 1 deletion ios/Approach/Sources/ViewsLibrary/Buttons/EditButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct EditButton: View {

public var body: some View {
Button(action: perform) {
Label(Strings.Action.edit, systemImage: "pencil")
Label(Strings.Action.edit, systemSymbol: .pencil)
}
.tint(Asset.Colors.Action.default)
}
Expand Down
3 changes: 2 additions & 1 deletion ios/Approach/Sources/ViewsLibrary/Buttons/FilterButton.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AssetsLibrary
import SwiftUI

public struct FilterButton: View {
Expand All @@ -11,7 +12,7 @@ public struct FilterButton: View {

public var body: some View {
Button(action: perform) {
Image(systemName: isActive ? "line.3.horizontal.decrease.circle.fill" : "line.3.horizontal.decrease.circle")
Image(systemSymbol: isActive ? .line3HorizontalDecreaseCircleFill : .line3HorizontalDecreaseCircle)
}
}
}
3 changes: 2 additions & 1 deletion ios/Approach/Sources/ViewsLibrary/Buttons/SortButton.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AssetsLibrary
import SwiftUI

public struct SortButton: View {
Expand All @@ -11,7 +12,7 @@ public struct SortButton: View {

public var body: some View {
Button(action: perform) {
Image(systemName: isActive ? "arrow.up.arrow.down.square.fill" : "arrow.up.arrow.down.square")
Image(systemSymbol: isActive ? .arrowUpArrowDownSquareFill : .arrowUpArrowDownSquare)
}
}
}

0 comments on commit 113fd4e

Please sign in to comment.