Skip to content

Commit 107db95

Browse files
committed
feat: load icons
1 parent b207296 commit 107db95

File tree

6 files changed

+52
-0
lines changed

6 files changed

+52
-0
lines changed

Loader.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
331D48B92DA858B1006A37B2 /* UITableView+image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331D48B82DA858B1006A37B2 /* UITableView+image.swift */; };
1011
3331318D2D8EAB50001B35CE /* LRBootstrapViewController+transition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3331318C2D8EAB50001B35CE /* LRBootstrapViewController+transition.swift */; };
1112
336FA5982D8C381500E28B8F /* NimbleAnimations in Frameworks */ = {isa = PBXBuildFile; productRef = 336FA5972D8C381500E28B8F /* NimbleAnimations */; };
1213
336FA59A2D8C381500E28B8F /* NimbleExtensions in Frameworks */ = {isa = PBXBuildFile; productRef = 336FA5992D8C381500E28B8F /* NimbleExtensions */; };
@@ -47,6 +48,7 @@
4748
/* End PBXBuildFile section */
4849

4950
/* Begin PBXFileReference section */
51+
331D48B82DA858B1006A37B2 /* UITableView+image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+image.swift"; sourceTree = "<group>"; };
5052
3331318C2D8EAB50001B35CE /* LRBootstrapViewController+transition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LRBootstrapViewController+transition.swift"; sourceTree = "<group>"; };
5153
336FA59D2D8C385900E28B8F /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS18.2.sdk/System/Library/Frameworks/CoreFoundation.framework; sourceTree = DEVELOPER_DIR; };
5254
3388438F2D7D8A26002D07FD /* Loader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Loader.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -169,6 +171,7 @@
169171
AF966A6E2D8C6840001BA405 /* Extensions */ = {
170172
isa = PBXGroup;
171173
children = (
174+
331D48B82DA858B1006A37B2 /* UITableView+image.swift */,
172175
AF966A682D8C6840001BA405 /* UIApplication */,
173176
AF966A6B2D8C6840001BA405 /* UIDevice */,
174177
AF966A6C2D8C6840001BA405 /* String+prefix.swift */,
@@ -443,6 +446,7 @@
443446
AF966AB42D8C6840001BA405 /* LRBootstrapper+download.swift in Sources */,
444447
AF966AB52D8C6840001BA405 /* LRBootstrapper+status.swift in Sources */,
445448
AF966AB62D8C6840001BA405 /* LRConfig.swift in Sources */,
449+
331D48B92DA858B1006A37B2 /* UITableView+image.swift in Sources */,
446450
AF966AB72D8C6840001BA405 /* LREnvironment.swift in Sources */,
447451
3331318D2D8EAB50001B35CE /* LRBootstrapViewController+transition.swift in Sources */,
448452
AF966AB82D8C6840001BA405 /* LREnvironment+prefixes.swift in Sources */,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// UITableView+image.swift
3+
// Loader
4+
//
5+
// Created by samara on 10.04.2025.
6+
//
7+
8+
import UIKit.UITableViewCell
9+
10+
extension UITableViewCell {
11+
/// Applies a properly sized and styled image to the cell's imageView
12+
/// - Parameter originalImage: The original image to resize and apply
13+
func setSectionImage(with originalImage: UIImage) {
14+
let imageSize = CGSize(width: 30, height: 30)
15+
16+
let resizedImage = UIGraphicsImageRenderer(size: imageSize).image { context in
17+
originalImage.draw(in: CGRect(origin: .zero, size: imageSize))
18+
}
19+
20+
self.imageView?.image = resizedImage
21+
self.imageView?.layer.cornerRadius = 7
22+
self.imageView?.clipsToBounds = true
23+
self.imageView?.layer.borderWidth = 0.7
24+
self.imageView?.layer.cornerCurve = .continuous
25+
self.imageView?.layer.borderColor = UIColor.lightGray.withAlphaComponent(0.3).cgColor
26+
}
27+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "unknown2.png",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
36.4 KB
Loading

Loader/Utilities/Config/Models/LRConfig.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ struct LRManager: Codable {
122122
/// Package manager install path
123123
/// Useful for detecting if it is installed, due to them having a common path we're able to keep track of
124124
let filePath: URL
125+
126+
func loadIconImage() -> UIImage {
127+
guard let data = try? Data(contentsOf: icon),
128+
let image = UIImage(data: data) else {
129+
return UIImage(named: "unknown")
130+
}
131+
return image
132+
}
125133
}
126134

127135
struct LRRepository: Codable {

Loader/Views/Selection/LRBootstrapViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ extension LRBootstrapViewController {
149149

150150
cell.textLabel?.text = manager?.name
151151
cell.accessoryType = .disclosureIndicator
152+
cell.setSectionImage(with: manager?.loadIconImage())
152153

153154
return cell
154155
}

0 commit comments

Comments
 (0)