improve app ui for demo
This commit is contained in:
1 parent
59670cb841
commit
32da6b41c4
6 files changed
+200
-61
No files matched your search
@@ -14,9 +14,22 @@
|
|||||||
6F09B79D2DEB694B00CDE89C /* Pocket Poster.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Pocket Poster.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
6F09B79D2DEB694B00CDE89C /* Pocket Poster.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Pocket Poster.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||||
|
6F09B7F72DEBBFEB00CDE89C /* Exceptions for "Pocket Poster" folder in "Pocket Poster" target */ = {
|
||||||
|
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||||
|
membershipExceptions = (
|
||||||
|
"Pocket-Poster-Info.plist",
|
||||||
|
);
|
||||||
|
target = 6F09B79C2DEB694B00CDE89C /* Pocket Poster */;
|
||||||
|
};
|
||||||
|
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||||
|
|
||||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||||
6F09B79F2DEB694B00CDE89C /* Pocket Poster */ = {
|
6F09B79F2DEB694B00CDE89C /* Pocket Poster */ = {
|
||||||
isa = PBXFileSystemSynchronizedRootGroup;
|
isa = PBXFileSystemSynchronizedRootGroup;
|
||||||
|
exceptions = (
|
||||||
|
6F09B7F72DEBBFEB00CDE89C /* Exceptions for "Pocket Poster" folder in "Pocket Poster" target */,
|
||||||
|
);
|
||||||
path = "Pocket Poster";
|
path = "Pocket Poster";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
@@ -267,6 +280,7 @@
|
|||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_FILE = "Pocket-Poster-Info.plist";
|
INFOPLIST_FILE = "Pocket-Poster-Info.plist";
|
||||||
|
INFOPLIST_KEY_LSSupportsOpeningDocumentsInPlace = YES;
|
||||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||||
@@ -298,6 +312,7 @@
|
|||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_FILE = "Pocket-Poster-Info.plist";
|
INFOPLIST_FILE = "Pocket-Poster-Info.plist";
|
||||||
|
INFOPLIST_KEY_LSSupportsOpeningDocumentsInPlace = YES;
|
||||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||||
|
|||||||
@@ -110,33 +110,35 @@ class PosterBoardManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func applyTendie(_ url: URL, appHash: String) throws {
|
static func applyTendies(_ urls: [URL], appHash: String) throws {
|
||||||
// scope the resource
|
let _ = try SymHandler.createDescriptorsSymlink(appHash: appHash)
|
||||||
let accessing = url.startAccessingSecurityScopedResource()
|
for url in urls {
|
||||||
defer {
|
// scope the resource
|
||||||
if accessing {
|
let accessing = url.startAccessingSecurityScopedResource()
|
||||||
url.stopAccessingSecurityScopedResource()
|
defer {
|
||||||
}
|
if accessing {
|
||||||
}
|
url.stopAccessingSecurityScopedResource()
|
||||||
|
|
||||||
guard let descriptors = try getDescriptorsFromTendie(url) else { return } // TODO: Add error handling
|
|
||||||
// create the folder
|
|
||||||
for descr in try FileManager.default.contentsOfDirectory(at: descriptors, includingPropertiesForKeys: nil, options: .skipsHiddenFiles) {
|
|
||||||
if descr.lastPathComponent != "__MACOSX" {
|
|
||||||
try randomizeWallpaperId(url: descr)
|
|
||||||
let newURL = SymHandler.getDocumentsDirectory().appendingPathComponent(UUID().uuidString, conformingTo: .directory)
|
|
||||||
try FileManager.default.moveItem(at: descr, to: newURL)
|
|
||||||
|
|
||||||
let _ = try SymHandler.createDescriptorsSymlink(appHash: appHash)
|
|
||||||
do {
|
|
||||||
try FileManager.default.trashItem(at: newURL, resultingItemURL: nil)
|
|
||||||
} catch {
|
|
||||||
print(error.localizedDescription)
|
|
||||||
}
|
}
|
||||||
SymHandler.cleanup()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guard let descriptors = try getDescriptorsFromTendie(url) else { return } // TODO: Add error handling
|
||||||
|
// create the folder
|
||||||
|
for descr in try FileManager.default.contentsOfDirectory(at: descriptors, includingPropertiesForKeys: nil, options: .skipsHiddenFiles) {
|
||||||
|
if descr.lastPathComponent != "__MACOSX" {
|
||||||
|
try randomizeWallpaperId(url: descr)
|
||||||
|
let newURL = SymHandler.getDocumentsDirectory().appendingPathComponent(UUID().uuidString, conformingTo: .directory)
|
||||||
|
try FileManager.default.moveItem(at: descr, to: newURL)
|
||||||
|
|
||||||
|
do {
|
||||||
|
try FileManager.default.trashItem(at: newURL, resultingItemURL: nil)
|
||||||
|
} catch {
|
||||||
|
print(error.localizedDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try? FileManager.default.removeItem(at: descriptors)
|
||||||
}
|
}
|
||||||
|
SymHandler.cleanup()
|
||||||
try? FileManager.default.removeItem(at: descriptors)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// MaterialView.swift
|
||||||
|
// Pocket Poster
|
||||||
|
//
|
||||||
|
// Created by lemin on 5/31/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct MaterialView: UIViewRepresentable {
|
||||||
|
let material: UIBlurEffect.Style
|
||||||
|
|
||||||
|
init(_ material: UIBlurEffect.Style) {
|
||||||
|
self.material = material
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUIView(context: Context) -> UIVisualEffectView {
|
||||||
|
UIVisualEffectView(effect: UIBlurEffect(style: material))
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateUIView(_ uiView: UIVisualEffectView, context: Context) {
|
||||||
|
uiView.effect = UIBlurEffect(style: material)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
//
|
||||||
|
// TintedButton.swift
|
||||||
|
// Pocket Poster
|
||||||
|
//
|
||||||
|
// Created by lemin on 5/31/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct TintedButton: ButtonStyle {
|
||||||
|
var color: Color
|
||||||
|
var material: UIBlurEffect.Style?
|
||||||
|
var fullwidth: Bool = false
|
||||||
|
|
||||||
|
func makeBody(configuration: Configuration) -> some View {
|
||||||
|
ZStack {
|
||||||
|
if fullwidth {
|
||||||
|
configuration.label
|
||||||
|
.padding(15)
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.background(material == nil ? AnyView(color.opacity(0.2)) : AnyView(MaterialView(material!)))
|
||||||
|
.cornerRadius(8)
|
||||||
|
.foregroundColor(color)
|
||||||
|
} else {
|
||||||
|
configuration.label
|
||||||
|
.padding(15)
|
||||||
|
.background(material == nil ? AnyView(color.opacity(0.2)) : AnyView(MaterialView(material!)))
|
||||||
|
.cornerRadius(8)
|
||||||
|
.foregroundColor(color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init(color: Color = .blue, fullwidth: Bool = false) {
|
||||||
|
self.color = color
|
||||||
|
self.fullwidth = fullwidth
|
||||||
|
}
|
||||||
|
init(color: Color = .blue, material: UIBlurEffect.Style, fullwidth: Bool = false) {
|
||||||
|
self.color = color
|
||||||
|
self.material = material
|
||||||
|
self.fullwidth = fullwidth
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
struct FullwidthTintedButton_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
Button("Exaple") {
|
||||||
|
|
||||||
|
}
|
||||||
|
.buttonStyle(TintedButton(color: .red, fullwidth: true))
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -13,54 +13,88 @@ struct ContentView: View {
|
|||||||
@AppStorage("pbHash") var pbHash: String = ""
|
@AppStorage("pbHash") var pbHash: String = ""
|
||||||
|
|
||||||
@State var showTendiesImporter: Bool = false
|
@State var showTendiesImporter: Bool = false
|
||||||
@State var selectedTendie: URL? = nil
|
@State var selectedTendies: [URL]? = nil
|
||||||
|
|
||||||
@State var showErrorAlert = false
|
@State var showErrorAlert = false
|
||||||
|
@State var showSuccessAlert = false
|
||||||
@State var lastError: String?
|
@State var lastError: String?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
NavigationStack {
|
||||||
TextField("App Hash", text: $pbHash)
|
ScrollView {
|
||||||
|
Section {
|
||||||
Button(action: {
|
HStack {
|
||||||
showTendiesImporter.toggle()
|
Text("App Hash:")
|
||||||
}) {
|
.bold()
|
||||||
Text("Select Tendie")
|
Spacer()
|
||||||
}
|
}
|
||||||
|
TextField("App Hash", text: $pbHash)
|
||||||
if let selectedTendie = selectedTendie {
|
}
|
||||||
Text("Selected Tendie: \(selectedTendie)")
|
.padding(.bottom, 5)
|
||||||
if pbHash != "" {
|
|
||||||
|
Section {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
do {
|
showTendiesImporter.toggle()
|
||||||
try PosterBoardManager.applyTendie(selectedTendie, appHash: pbHash)
|
|
||||||
lastError = "Success. Delete in files app."
|
|
||||||
showErrorAlert.toggle()
|
|
||||||
} catch {
|
|
||||||
lastError = error.localizedDescription
|
|
||||||
showErrorAlert.toggle()
|
|
||||||
}
|
|
||||||
}) {
|
}) {
|
||||||
Text("Apply")
|
Text("Select Tendies")
|
||||||
|
}
|
||||||
|
.buttonStyle(TintedButton(color: .green, fullwidth: true))
|
||||||
|
|
||||||
|
if let selectedTendies = selectedTendies {
|
||||||
|
HStack {
|
||||||
|
Text("Selected Tendies:")
|
||||||
|
.bold()
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
ForEach(selectedTendies, id: \.self) { tendie in
|
||||||
|
HStack {
|
||||||
|
Text("- \(tendie.deletingPathExtension().lastPathComponent)")
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Section {
|
||||||
|
if let selectedTendies = selectedTendies, pbHash != "" {
|
||||||
|
Button(action: {
|
||||||
|
do {
|
||||||
|
try PosterBoardManager.applyTendies(selectedTendies, appHash: pbHash)
|
||||||
|
lastError = "Please open PosterBoard in the Shortcuts app and then close it from the app switcher."
|
||||||
|
showSuccessAlert.toggle()
|
||||||
|
} catch {
|
||||||
|
lastError = error.localizedDescription
|
||||||
|
showErrorAlert.toggle()
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
Text("Apply")
|
||||||
|
}
|
||||||
|
.buttonStyle(TintedButton(color: .blue, fullwidth: true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.padding()
|
||||||
|
.navigationTitle("Pocket Poster")
|
||||||
}
|
}
|
||||||
.padding()
|
.fileImporter(isPresented: $showTendiesImporter, allowedContentTypes: [UTType(filenameExtension: "tendies", conformingTo: .data)!], allowsMultipleSelection: true, onCompletion: { result in
|
||||||
.fileImporter(isPresented: $showTendiesImporter, allowedContentTypes: [UTType(filenameExtension: "tendies", conformingTo: .data)!], onCompletion: { result in
|
switch result {
|
||||||
switch result {
|
case .success(let url):
|
||||||
case .success(let url):
|
selectedTendies = url
|
||||||
selectedTendie = url
|
case .failure(let error):
|
||||||
case .failure(let error):
|
lastError = error.localizedDescription
|
||||||
lastError = error.localizedDescription
|
showErrorAlert.toggle()
|
||||||
showErrorAlert.toggle()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.alert("Error", isPresented: $showErrorAlert) {
|
|
||||||
Button("OK") {}
|
|
||||||
} message: {
|
|
||||||
Text(lastError ?? "???")
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.alert("Error", isPresented: $showErrorAlert) {
|
||||||
|
Button("OK") {}
|
||||||
|
} message: {
|
||||||
|
Text(lastError ?? "???")
|
||||||
|
}
|
||||||
|
.alert("Success!", isPresented: $showSuccessAlert) {
|
||||||
|
Button("OK") {}
|
||||||
|
} message: {
|
||||||
|
Text(lastError ?? "???")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>UIFileSharingEnabled</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
Reference in new issue
Block a user