Skip to content

Commit

Permalink
open debs in app again + fix icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Lrdsnow committed May 4, 2024
1 parent fe7c41e commit 1b79dfc
Show file tree
Hide file tree
Showing 45 changed files with 399 additions and 47 deletions.
Binary file added PrettyIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions PurePKG.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
65839F002BCE4BEE00068B7A /* URLExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65839EFF2BCE4BEE00068B7A /* URLExtensions.swift */; };
65839F022BCE4C2B00068B7A /* ListRowExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65839F012BCE4C2B00068B7A /* ListRowExtensions.swift */; };
659D79D82BD4409200398B74 /* DeviceViewModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 659D79D72BD4409200398B74 /* DeviceViewModifiers.swift */; };
65BBF02E2BE5C9D700C722B8 /* PrettyIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 65BBF02D2BE5C9D600C722B8 /* PrettyIcon.png */; };
65D427CB2BD4FAE9008D8A2C /* ColorExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65D427CA2BD4FAE9008D8A2C /* ColorExtensions.swift */; };
65D427CD2BD4FFEF008D8A2C /* UserDefaultsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65D427CC2BD4FFEF008D8A2C /* UserDefaultsExtensions.swift */; };
65D427CF2BD503C5008D8A2C /* ThemingViewModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65D427CE2BD503C5008D8A2C /* ThemingViewModifiers.swift */; };
Expand Down Expand Up @@ -61,6 +62,7 @@
65839EFF2BCE4BEE00068B7A /* URLExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLExtensions.swift; sourceTree = "<group>"; };
65839F012BCE4C2B00068B7A /* ListRowExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRowExtensions.swift; sourceTree = "<group>"; };
659D79D72BD4409200398B74 /* DeviceViewModifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceViewModifiers.swift; sourceTree = "<group>"; };
65BBF02D2BE5C9D600C722B8 /* PrettyIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = PrettyIcon.png; sourceTree = "<group>"; };
65D0169E2BA949C9003F11E4 /* PurePKG.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PurePKG.app; sourceTree = BUILT_PRODUCTS_DIR; };
65D427CA2BD4FAE9008D8A2C /* ColorExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorExtensions.swift; sourceTree = "<group>"; };
65D427CC2BD4FFEF008D8A2C /* UserDefaultsExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsExtensions.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -114,6 +116,7 @@
65D016952BA949C9003F11E4 = {
isa = PBXGroup;
children = (
65BBF02D2BE5C9D600C722B8 /* PrettyIcon.png */,
65DC66EC2BCCF31600EBFE82 /* RootHelper */,
65DC66D42BCCF0F900EBFE82 /* Shared */,
65DC66BE2BCCEC5300EBFE82 /* PurePKG */,
Expand Down Expand Up @@ -296,6 +299,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
65BBF02E2BE5C9D700C722B8 /* PrettyIcon.png in Resources */,
65DC66CA2BCCEC5300EBFE82 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
25 changes: 24 additions & 1 deletion PurePKG/Extentions/Compat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Combine

#if os(macOS)
typealias UIColor = NSColor
typealias UIImage = NSImage
typealias UIApplication = NSWorkspace
extension NSColor {
static var secondaryLabel: NSColor {
Expand Down Expand Up @@ -39,6 +40,16 @@ struct NavigationViewC<Content: View>: View {
}
}

extension Image {
init(uiImageC: UIImage) {
#if os(macOS)
self = Image(nsImage: uiImageC)
#else
self = Image(uiImage: uiImageC)
#endif
}
}

extension View {
@ViewBuilder
func tintC(_ tint: Color) -> some View {
Expand Down Expand Up @@ -106,7 +117,19 @@ extension View {
self
#endif
}
@ViewBuilder
@ViewBuilder
func onOpenURLC(_ action: @escaping (URL) -> Void) -> some View {
#if os(iOS)
if #available(iOS 14.0, *) {
self.onOpenURL { url in action(url) }
} else {
self
}
#else
self
#endif
}
@ViewBuilder
func onChangeC<T: Equatable>(of: T, perform: @escaping (T) -> Void) -> some View {
if #available(iOS 14.0, tvOS 14.0, *) {
self.onChange(of: of, perform: perform)
Expand Down
2 changes: 1 addition & 1 deletion PurePKG/Extentions/ThemingViewModifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extension View {
if UserDefaults.standard.bool(forKey: "useCustomBackground"),
let uiimage = UserDefaults.standard.imageForKey("customBackground") {
self.background(VStack {
Image(uiImage: uiimage)
Image(uiImageC: uiimage)
}.edgesIgnoringSafeArea(.top)
.edgesIgnoringSafeArea(.bottom)
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.nativeBounds.height).clipped())
Expand Down
61 changes: 61 additions & 0 deletions PurePKG/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>$(PRODUCT_NAME) Deb Package</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>org.debian.deb-archive</string>
</array>
</dict>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLIconFile</key>
<string>PrettyIcon</string>
<key>CFBundleURLName</key>
<string>uwu.lrdsnow.purepkg</string>
<key>CFBundleURLSchemes</key>
<array>
<string>purepkg</string>
</array>
</dict>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
Expand All @@ -12,5 +44,34 @@
<string></string>
</dict>
</dict>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.archive</string>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>$(PRODUCT_NAME) Deb Package</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>org.debian.deb-archive</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>deb</string>
</array>
<key>public.mime-type</key>
<array>
<string>application/x-debian-package</string>
<string>application/x-deb</string>
<string>application/vnd.debian.binary-package</string>
</array>
</dict>
</dict>
</array>
</dict>
</plist>
26 changes: 25 additions & 1 deletion PurePKG/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ struct ContentView: View {
}
.tag(3)
}
}.onAppear() { startup() }
}.onAppear() { startup() }.onOpenURLC { url in
handleIncomingURL(url)
}
} else {
ZStack(alignment: .bottom) {
TabView(selection: $tab) {
Expand All @@ -152,6 +154,8 @@ struct ContentView: View {
.tag(1)
SearchView(preview: preview)
.tag(2)
}.onOpenURLC { url in
handleIncomingURL(url)
}
#if os(iOS)
.edgesIgnoringSafeArea(.bottom)
Expand Down Expand Up @@ -183,6 +187,26 @@ struct ContentView: View {
}
}

private func handleIncomingURL(_ url: URL) {
print("App was opened via URL: \(url)")
if url.absoluteString.contains("purepkg://addrepo/") {
let repourl = url.absoluteString.replacingOccurrences(of: "purepkg://addrepo/", with: "")
print("Adding Repo: \(repourl)")
RepoHandler.addRepo(repourl)
} else if url.pathExtension == "deb" {
let info = APTWrapper.spawn(command: "\(Jailbreak.path())/\(Jailbreak.type() == .macos ? "" : "usr/")bin/dpkg-deb", args: ["dpkg-deb", "--field", url.path])
if info.0 == 0 {
let dict = RepoHandler.genDict(info.1)
var tweak = RepoHandler.createPackageStruct(dict)
tweak.debPath = url.path
importedPackage = tweak
showPackage = true
} else {
showPopup("Error", "There was an error reading the imported file")
}
}
}

#if !os(tvOS) && !os(macOS)
struct tabbar: View {
@Binding var selectedTab: Int
Expand Down
3 changes: 2 additions & 1 deletion PurePKG/Views/BrowseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ struct BrowseView: View {
}.listRowBackground(Color.clear).listRowSeparatorC(false)
}
}
if let importedPackage = importedPackage {
if let importedPackage = importedPackage,
showPackage == true {
NavigationLink(destination: TweakView(pkg: importedPackage, preview: preview), isActive: $showPackage, label: {})
}
}.appBG().navigationBarTitleC("Browse").listStyle(.plain).refreshableC { refreshRepos(appData) }
Expand Down
8 changes: 4 additions & 4 deletions PurePKG/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct SettingsView: View {
Section {
VStack(alignment: .leading) {
HStack(alignment: .center) {
Image("DisplayAppIcon").resizable().scaledToFit().frame(width: 90, height: 90).cornerRadius(20).padding(.trailing, 5).shadow(color: Color.black.opacity(0.5), radius: 3, x: 1, y: 2)
Image(uiImageC: UIImage(named: "AppIcon") ?? UIImage(named: "App Icon")!).resizable().scaledToFit().frame(width: 90, height: 90).cornerRadius(20).padding(.trailing, 5).shadow(color: Color.black.opacity(0.5), radius: 3, x: 1, y: 2)
Text("PurePKG").font(.system(size: 40, weight: .bold, design: .rounded))
}
}.padding(.leading, 5)
Expand Down Expand Up @@ -695,7 +695,7 @@ struct UISettingsView: View {
UIApplication.shared.setAlternateIconName(nil, completionHandler: nil)
}, label: {
HStack {
Image(uiImage: UIImage(named: "AppIcon")!)
Image(uiImageC: UIImage(named: "AppIcon")!)
.resizable()
.frame(width: 85, height: 85)
.cornerRadius(15)
Expand All @@ -710,7 +710,7 @@ struct UISettingsView: View {
UIApplication.shared.setAlternateIconName("AppIcon1", completionHandler: nil)
}, label: {
HStack {
Image(uiImage: UIImage(named: "AppIcon1")!)
Image(uiImageC: UIImage(named: "AppIcon1")!)
.resizable()
.frame(width: 85, height: 85)
.cornerRadius(15)
Expand All @@ -725,7 +725,7 @@ struct UISettingsView: View {
UIApplication.shared.setAlternateIconName("AppIcon2", completionHandler: nil)
}, label: {
HStack {
Image(uiImage: UIImage(named: "AppIcon2")!)
Image(uiImageC: UIImage(named: "AppIcon2")!)
.resizable()
.frame(width: 85, height: 85)
.cornerRadius(15)
Expand Down
38 changes: 23 additions & 15 deletions PurePKG/Views/SubViews/BrowseRows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ struct PlaceHolderRow: View {
if !UserDefaults.standard.bool(forKey: "hideIcons") {
VStack(alignment: .center) {
Spacer()
Image("DisplayAppIcon")
Image(uiImageC: UIImage(named: "AppIcon") ?? UIImage(named: "App Icon")!)
.resizable()
.scaledToFit()
.scaledToFill()
#if os(tvOS)
.frame(width: 70, height: 70)
.customRadius(15)
.clipShape(RoundedRectangle(cornerRadius: 15, style: .continuous))
#else
.frame(width: 50, height: 50)
#if os(macOS)
.clipShape(RoundedRectangle(cornerRadius: 11, style: .continuous))
#else
.customRadius(11)
#endif
#endif
Spacer()
}
Expand Down Expand Up @@ -74,24 +78,26 @@ struct RepoRow: View {
if let image = state.image {
image
.resizable()
.aspectRatio(contentMode: .fit)
.scaledToFit()
.scaledToFill()
} else if state.error != nil {
Image("DisplayAppIcon")
Image(uiImageC: UIImage(named: "AppIcon") ?? UIImage(named: "App Icon")!)
.resizable()
.aspectRatio(contentMode: .fit)
.scaledToFit()
.scaledToFill()
} else {
ProgressView()
.scaledToFit()
}
}
#if os(tvOS)
.frame(width: 70, height: 70)
.customRadius(15)
.clipShape(RoundedRectangle(cornerRadius: 15, style: .continuous))
#else
.frame(width: 50, height: 50)
#if os(macOS)
.clipShape(RoundedRectangle(cornerRadius: 11, style: .continuous))
#else
.customRadius(11)
#endif
#endif
Spacer()
}
Expand Down Expand Up @@ -170,24 +176,26 @@ struct TweakRow: View {
if let image = state.image {
image
.resizable()
.aspectRatio(contentMode: .fit)
.scaledToFit()
.scaledToFill()
} else if state.error != nil {
Image("DisplayAppIcon")
Image(uiImageC: UIImage(named: "AppIcon") ?? UIImage(named: "App Icon")!)
.resizable()
.aspectRatio(contentMode: .fit)
.scaledToFit()
.scaledToFill()
} else {
ProgressView()
.scaledToFit()
}
}
#if os(tvOS)
.frame(width: 85, height: 85)
.customRadius(15)
.clipShape(RoundedRectangle(cornerRadius: 15, style: .continuous))
#else
.frame(width: 50, height: 50)
#if os(macOS)
.clipShape(RoundedRectangle(cornerRadius: 11, style: .continuous))
#else
.customRadius(11)
#endif
#endif
Spacer()
}
Expand Down
2 changes: 1 addition & 1 deletion PurePKG/Views/TweakView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct TweakView: View {
.aspectRatio(contentMode: .fit)
.scaledToFit()
} else if state.error != nil {
Image("DisplayAppIcon")
Image(uiImageC: UIImage(named: "AppIcon") ?? UIImage(named: "App Icon")!)
.resizable()
.aspectRatio(contentMode: .fit)
.scaledToFit()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1b79dfc

Please sign in to comment.