Skip to content

Commit

Permalink
Make use SFSafeSymbols for type safe SF Symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
timbms committed Jul 30, 2024
1 parent fd96bd6 commit 2d29d91
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 34 deletions.
25 changes: 25 additions & 0 deletions openHAB.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
DA2E0AA423DC96E9009B0A99 /* EncircledIconWithAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2E0AA323DC96E9009B0A99 /* EncircledIconWithAction.swift */; };
DA2E0B0E23DCC153009B0A99 /* MapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2E0B0D23DCC152009B0A99 /* MapView.swift */; };
DA2E0B1023DCC439009B0A99 /* MapViewRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2E0B0F23DCC439009B0A99 /* MapViewRow.swift */; };
DA3B75AE2C59741800E219AB /* SFSafeSymbols in Frameworks */ = {isa = PBXBuildFile; productRef = DA3B75AD2C59741800E219AB /* SFSafeSymbols */; };
DA3B75B02C59742A00E219AB /* SFSafeSymbols in Frameworks */ = {isa = PBXBuildFile; productRef = DA3B75AF2C59742A00E219AB /* SFSafeSymbols */; };
DA4D4DB5233F9ACB00B37E37 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = DA4D4DB4233F9ACB00B37E37 /* README.md */; };
DA50C7BD2B0A51BD0009F716 /* SliderWithSwitchSupportRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA50C7BC2B0A51BD0009F716 /* SliderWithSwitchSupportRow.swift */; };
DA50C7BF2B0A65300009F716 /* SliderWithSwitchSupportUITableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA50C7BE2B0A652F0009F716 /* SliderWithSwitchSupportUITableViewCell.swift */; };
Expand Down Expand Up @@ -473,6 +475,7 @@
934E592728F16EBA00162004 /* Kingfisher in Frameworks */,
937E4473270B36DD00A98C26 /* OpenHABCore in Frameworks */,
934E592B28F16EBA00162004 /* Alamofire in Frameworks */,
DA3B75B02C59742A00E219AB /* SFSafeSymbols in Frameworks */,
934E592528F16EBA00162004 /* OpenHABCore in Frameworks */,
93F8062F27AE63620035A6B0 /* Alamofire in Frameworks */,
937E448E270B37D200A98C26 /* DeviceKit in Frameworks */,
Expand Down Expand Up @@ -531,6 +534,7 @@
DFB2622D18830A3600D3244D /* CoreGraphics.framework in Frameworks */,
93F8063527AE6C620035A6B0 /* FirebaseCrashlytics in Frameworks */,
937E4488270B37A600A98C26 /* Kingfisher in Frameworks */,
DA3B75AE2C59741800E219AB /* SFSafeSymbols in Frameworks */,
937E4471270B36D000A98C26 /* OpenHABCore in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1085,6 +1089,7 @@
934E592628F16EBA00162004 /* Kingfisher */,
934E592828F16EBA00162004 /* DeviceKit */,
934E592A28F16EBA00162004 /* Alamofire */,
DA3B75AF2C59742A00E219AB /* SFSafeSymbols */,
);
productName = openHABWatchSwift2;
productReference = DA0775152346705D0086C685 /* openHABWatch.app */;
Expand Down Expand Up @@ -1141,6 +1146,7 @@
93F8064F27AE7A830035A6B0 /* SideMenu */,
93F8065227AE7B580035A6B0 /* SVGKit */,
6557AF912C039D140094D0C8 /* FirebaseMessaging */,
DA3B75AD2C59741800E219AB /* SFSafeSymbols */,
);
productName = openHAB;
productReference = DFB2622718830A3600D3244D /* openHAB.app */;
Expand Down Expand Up @@ -1226,6 +1232,7 @@
93F8064827AE7A2E0035A6B0 /* XCRemoteSwiftPackageReference "FlexColorPicker" */,
93F8064E27AE7A820035A6B0 /* XCRemoteSwiftPackageReference "SideMenu" */,
93F8065127AE7B580035A6B0 /* XCRemoteSwiftPackageReference "SVGKit" */,
DA3B75AC2C59729200E219AB /* XCRemoteSwiftPackageReference "SFSafeSymbols" */,
);
productRefGroup = DFB2622818830A3600D3244D /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -2383,6 +2390,14 @@
kind = branch;
};
};
DA3B75AC2C59729200E219AB /* XCRemoteSwiftPackageReference "SFSafeSymbols" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SFSafeSymbols/SFSafeSymbols";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.3.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand Down Expand Up @@ -2491,6 +2506,16 @@
package = 93F8065127AE7B580035A6B0 /* XCRemoteSwiftPackageReference "SVGKit" */;
productName = SVGKit;
};
DA3B75AD2C59741800E219AB /* SFSafeSymbols */ = {
isa = XCSwiftPackageProductDependency;
package = DA3B75AC2C59729200E219AB /* XCRemoteSwiftPackageReference "SFSafeSymbols" */;
productName = SFSafeSymbols;
};
DA3B75AF2C59742A00E219AB /* SFSafeSymbols */ = {
isa = XCSwiftPackageProductDependency;
package = DA3B75AC2C59729200E219AB /* XCRemoteSwiftPackageReference "SFSafeSymbols" */;
productName = SFSafeSymbols;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = DFB2621F18830A3600D3244D /* Project object */;
Expand Down
18 changes: 9 additions & 9 deletions openHAB.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@
"version": "4.9.0"
}
},
{
"package": "DynamicButton",
"repositoryURL": "https://github.com/yannickl/DynamicButton.git",
"state": {
"branch": null,
"revision": "4fbd60e46a548e77fd118483bbb4e58d3c11c5ed",
"version": "6.2.1"
}
},
{
"package": "Firebase",
"repositoryURL": "https://github.com/firebase/firebase-ios-sdk.git",
Expand Down Expand Up @@ -172,6 +163,15 @@
"version": "2.4.0"
}
},
{
"package": "SFSafeSymbols",
"repositoryURL": "https://github.com/SFSafeSymbols/SFSafeSymbols",
"state": {
"branch": null,
"revision": "e2e28f4e56e1769c2ec3c61c9355fc64eb7a535a",
"version": "5.3.0"
}
},
{
"package": "SideMenu",
"repositoryURL": "https://github.com/jonkykong/SideMenu.git",
Expand Down
5 changes: 3 additions & 2 deletions openHAB/OpenHABDrawerTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import OpenHABCore
import os.log
import SafariServices
import SFSafeSymbols
import UIKit

func deriveSitemaps(_ response: Data?) -> [OpenHABSitemap] {
Expand Down Expand Up @@ -236,9 +237,9 @@ class OpenHABDrawerTableViewController: UITableViewController {
cell.customTextLabel?.text = drawerItem.localizedString
switch drawerItem {
case .notifications:
cell.customImageView.image = UIImage(systemName: "bell")
cell.customImageView.image = UIImage(systemSymbol: .bell)
case .settings:
cell.customImageView.image = UIImage(systemName: "gear")
cell.customImageView.image = UIImage(systemSymbol: .gear)
}
default:
break
Expand Down
2 changes: 1 addition & 1 deletion openHAB/OpenHABRootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class OpenHABRootViewController: UIViewController {
fileprivate func setupSideMenu() {
let hamburgerButtonItem: UIBarButtonItem
let imageConfig = UIImage.SymbolConfiguration(textStyle: .largeTitle)
let buttonImage = UIImage(systemName: "line.horizontal.3", withConfiguration: imageConfig)
let buttonImage = UIImage(systemSymbol: .line3Horizontal, withConfiguration: imageConfig)
let button = UIButton(type: .custom)
button.setImage(buttonImage, for: .normal)
button.addTarget(self, action: #selector(OpenHABRootViewController.rightDrawerButtonPress(_:)), for: .touchUpInside)
Expand Down
2 changes: 1 addition & 1 deletion openHAB/OpenHABSitemapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ extension OpenHABSitemapViewController: UITableViewDelegate, UITableViewDataSour
func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
if let cell = tableView.cellForRow(at: indexPath) as? GenericUITableViewCell, cell.widget.type == .text, let text = cell.widget?.labelValue ?? cell.widget?.labelText, !text.isEmpty {
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { _ in
let copy = UIAction(title: NSLocalizedString("copy_label", comment: ""), image: UIImage(systemName: "square.and.arrow.up")) { _ in
let copy = UIAction(title: NSLocalizedString("copy_label", comment: ""), image: UIImage(systemSymbol: .squareAndArrowUp)) { _ in
UIPasteboard.general.string = text
}

Expand Down
5 changes: 3 additions & 2 deletions openHABWatch Extension/Views/Rows/ColorPickerRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct ColorPickerRow: View {
HStack {
Spacer()
EncircledIconWithAction(
systemName: "chevron.down.circle.fill",
systemSymbol: .chevronDownCircleFill,
action: downButtonPressed
)

Expand All @@ -43,7 +43,8 @@ struct ColorPickerRow: View {
Spacer()

EncircledIconWithAction(
systemName: "chevron.up.circle.fill",
systemSymbol:
.chevronUpCircleFill,
action: upButtonPressed
)
Spacer()
Expand Down
2 changes: 1 addition & 1 deletion openHABWatch Extension/Views/Rows/ImageRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct ImageRow: View {
os_log("Failure loading icon: %{PUBLIC}s", log: .notifications, type: .debug, kingfisherError.localizedDescription)
}
.placeholder {
Image(systemName: "arrow.2.circlepath.circle")
Image(systemSymbol: .arrow2CirclepathCircle)
.font(.callout)
.opacity(0.3)
}
Expand Down
6 changes: 3 additions & 3 deletions openHABWatch Extension/Views/Rows/RollershutterRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ struct RollershutterRow: View {
HStack {
Spacer()

EncircledIconWithAction(systemName: "chevron.up.circle.fill") {
EncircledIconWithAction(systemSymbol: .chevronUpCircleFill) {
widget.sendCommand("UP")
}

Spacer()

EncircledIconWithAction(systemName: "square") {
EncircledIconWithAction(systemSymbol: .square) {
widget.sendCommand("STOP")
}

Spacer()

EncircledIconWithAction(systemName: "chevron.down.circle.fill") {
EncircledIconWithAction(systemSymbol: .chevronDownCircleFill) {
widget.sendCommand("DOWN")
}

Expand Down
5 changes: 2 additions & 3 deletions openHABWatch Extension/Views/Rows/SetpointRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ struct SetpointRow: View {
Spacer()

EncircledIconWithAction(
systemName:
"chevron.down.circle.fill",
systemSymbol: .chevronDownCircleFill,
action: decreaseValue
)

Expand All @@ -48,7 +47,7 @@ struct SetpointRow: View {
Spacer()

EncircledIconWithAction(
systemName: "chevron.up.circle.fill",
systemSymbol: .chevronUpCircleFill,
action: increaseValue
)

Expand Down
15 changes: 5 additions & 10 deletions openHABWatch Extension/Views/Utils/EncircledIconWithAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,17 @@
//
// SPDX-License-Identifier: EPL-2.0

import SFSafeSymbols
import SwiftUI

struct EncircledIconWithAction: View {
var systemName: String
var systemSymbol: SFSymbol
var action: () -> Void
var body: some View {
Image(systemName: systemName)
Image(systemSymbol: systemSymbol)
.font(.system(size: 25))
.colorMultiply(.blue)
.saturation(0.8)
// Circle()
// .fill(Color.blue)
// .frame(width: 35, height: 35)
// .overlay(
// Image(systemName: systemName)
// .font(.system(size: 25))
// )
.onTapGesture {
action()
}
Expand All @@ -34,6 +28,7 @@ struct EncircledIconWithAction: View {

struct EncircledIconWithAction_Previews: PreviewProvider {
static var previews: some View {
EncircledIconWithAction(systemName: "chevron.up.circle.fill") {}
EncircledIconWithAction(systemSymbol:
.chevronUpCircleFill) {}
}
}
2 changes: 1 addition & 1 deletion openHABWatch Extension/Views/Utils/IconView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct IconView: View {
os_log("Failure loading icon: %{PUBLIC}s", log: .notifications, type: .debug, kingfisherError.localizedDescription)
}
.placeholder {
Image(systemName: "arrow.2.circlepath.circle")
Image(systemSymbol: .arrowTriangle2CirclepathCircle)
.font(.callout)
.opacity(0.3)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension ObservableOpenHABWidget {
LazyView(
ContentView(viewModel: UserData(url: URL(string: pageUrl)), settings: settings, title: title))
) {
Image(systemName: "chevron.right")
Image(systemSymbol: .chevronRight)
}
} else {
EmptyView()
Expand Down

0 comments on commit 2d29d91

Please sign in to comment.