improve app ui for demo

This commit is contained in:
leminlimez committed 2025-05-31 18:55:47 -04:00
1 parent 59670cb841
commit 32da6b41c4
6 files changed
+153 -14

No files matched your search

+15
View File
@@ -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,7 +110,9 @@ class PosterBoardManager {
} }
} }
static func applyTendie(_ url: URL, appHash: String) throws { static func applyTendies(_ urls: [URL], appHash: String) throws {
let _ = try SymHandler.createDescriptorsSymlink(appHash: appHash)
for url in urls {
// scope the resource // scope the resource
let accessing = url.startAccessingSecurityScopedResource() let accessing = url.startAccessingSecurityScopedResource()
defer { defer {
@@ -127,16 +129,16 @@ class PosterBoardManager {
let newURL = SymHandler.getDocumentsDirectory().appendingPathComponent(UUID().uuidString, conformingTo: .directory) let newURL = SymHandler.getDocumentsDirectory().appendingPathComponent(UUID().uuidString, conformingTo: .directory)
try FileManager.default.moveItem(at: descr, to: newURL) try FileManager.default.moveItem(at: descr, to: newURL)
let _ = try SymHandler.createDescriptorsSymlink(appHash: appHash)
do { do {
try FileManager.default.trashItem(at: newURL, resultingItemURL: nil) try FileManager.default.trashItem(at: newURL, resultingItemURL: nil)
} catch { } catch {
print(error.localizedDescription) print(error.localizedDescription)
} }
SymHandler.cleanup()
} }
} }
try? FileManager.default.removeItem(at: descriptors) try? FileManager.default.removeItem(at: descriptors)
} }
SymHandler.cleanup()
}
} }
@@ -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
+45 -11
View File
@@ -13,29 +13,55 @@ 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 {
ScrollView {
Section {
HStack {
Text("App Hash:")
.bold()
Spacer()
}
TextField("App Hash", text: $pbHash) TextField("App Hash", text: $pbHash)
}
.padding(.bottom, 5)
Section {
Button(action: { Button(action: {
showTendiesImporter.toggle() showTendiesImporter.toggle()
}) { }) {
Text("Select Tendie") 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()
}
}
}
} }
if let selectedTendie = selectedTendie { Section {
Text("Selected Tendie: \(selectedTendie)") if let selectedTendies = selectedTendies, pbHash != "" {
if pbHash != "" {
Button(action: { Button(action: {
do { do {
try PosterBoardManager.applyTendie(selectedTendie, appHash: pbHash) try PosterBoardManager.applyTendies(selectedTendies, appHash: pbHash)
lastError = "Success. Delete in files app." lastError = "Please open PosterBoard in the Shortcuts app and then close it from the app switcher."
showErrorAlert.toggle() showSuccessAlert.toggle()
} catch { } catch {
lastError = error.localizedDescription lastError = error.localizedDescription
showErrorAlert.toggle() showErrorAlert.toggle()
@@ -43,14 +69,17 @@ struct ContentView: View {
}) { }) {
Text("Apply") Text("Apply")
} }
.buttonStyle(TintedButton(color: .blue, fullwidth: true))
} }
} }
} }
.padding() .padding()
.fileImporter(isPresented: $showTendiesImporter, allowedContentTypes: [UTType(filenameExtension: "tendies", conformingTo: .data)!], onCompletion: { result in .navigationTitle("Pocket Poster")
}
.fileImporter(isPresented: $showTendiesImporter, allowedContentTypes: [UTType(filenameExtension: "tendies", conformingTo: .data)!], allowsMultipleSelection: true, onCompletion: { result in
switch result { switch result {
case .success(let url): case .success(let url):
selectedTendie = url selectedTendies = url
case .failure(let error): case .failure(let error):
lastError = error.localizedDescription lastError = error.localizedDescription
showErrorAlert.toggle() showErrorAlert.toggle()
@@ -61,6 +90,11 @@ struct ContentView: View {
} message: { } message: {
Text(lastError ?? "???") Text(lastError ?? "???")
} }
.alert("Success!", isPresented: $showSuccessAlert) {
Button("OK") {}
} message: {
Text(lastError ?? "???")
}
} }
} }
+8
View File
@@ -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>