-
Notifications
You must be signed in to change notification settings - Fork 6
Attachments Helper #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 27 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
baafffe
wip attachments
stevensJourney 282ed06
wip: Add unit tests
stevensJourney 18bcd4c
cleanup docs
stevensJourney 7055b08
Add image preview to demo
stevensJourney 671761b
format
stevensJourney 4843623
update demo. Allow deleting attachments.
stevensJourney 528f8c8
camera
stevensJourney 1c12ddf
update secrets
stevensJourney 74d3688
Merge remote-tracking branch 'origin/main' into attachmentshelper
stevensJourney 52096f4
Add logger
stevensJourney aa60917
remove comma
stevensJourney 71c1ad0
cleanup
stevensJourney 2b361e6
Add readme and photo capability.
stevensJourney 0a81d64
Allow gallery image picker
stevensJourney ec1eba1
fix test
stevensJourney f5e791d
improve locking for attachment syncing
stevensJourney 4787b8c
Cleanup Attachment State enums. Better Errors.
stevensJourney a64555a
cleanup
stevensJourney 156b31f
cleanup
stevensJourney 9825bc8
Merge remote-tracking branch 'origin/main' into attachmentshelper
stevensJourney 8c0e08d
fix build
stevensJourney 2b4fc91
add changelog
stevensJourney 4765bb2
cleanup
stevensJourney 22c96e9
improve concurrency and closing of queues
stevensJourney 495ce97
cleanup
stevensJourney d405ddd
Cleanup demo. Verify local storage.
stevensJourney 2bdef94
Improve demo
stevensJourney 7d7d9a9
update locks
stevensJourney 88dbb16
update readme
stevensJourney 75eb7ea
update locks in syncing service
stevensJourney bdf5444
update test directory
stevensJourney 1cf4042
Merge remote-tracking branch 'origin/main' into attachmentshelper
stevensJourney e5d3aec
improve cancellations
stevensJourney ba03b37
test
stevensJourney f801ec1
Offload Image loading from main thread
stevensJourney e124ce3
improve camera detection. Better support for cancellations.
stevensJourney 0cad9a4
updated changelog
stevensJourney f9a3d10
Attachments readme polish
benitav 330d4bf
cleanup
stevensJourney ad7423c
Merge branch 'attachmentshelper' of github.com:powersync-ja/powersync…
stevensJourney f8e3d61
skip archiving attachments pendingUpload
stevensJourney 5206c16
code cleanup. Update archiving logid
stevensJourney 5821dff
update template
stevensJourney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
Demo/PowerSyncExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,110 @@ | ||
import SwiftUI | ||
|
||
struct TodoListRow: View { | ||
let todo: Todo | ||
let completeTapped: () -> Void | ||
|
||
var body: some View { | ||
HStack { | ||
Text(todo.description) | ||
Spacer() | ||
Button { | ||
completeTapped() | ||
} label: { | ||
Image(systemName: todo.isComplete ? "checkmark.circle.fill" : "circle") | ||
} | ||
.buttonStyle(.plain) | ||
let todo: Todo | ||
let isCameraAvailable: Bool | ||
let completeTapped: () -> Void | ||
let deletePhotoTapped: () -> Void | ||
let capturePhotoTapped: () -> Void | ||
let selectPhotoTapped: () -> Void | ||
|
||
@State private var image: UIImage? = nil | ||
|
||
var body: some View { | ||
HStack { | ||
Text(todo.description) | ||
Group { | ||
if let image = image { | ||
Image(uiImage: image) | ||
.resizable() | ||
.scaledToFit() | ||
|
||
} else if todo.photoUri != nil { | ||
// Show progress while loading the image | ||
ProgressView() | ||
.onAppear { | ||
loadImage() | ||
} | ||
} else if todo.photoId != nil { | ||
// Show progres, wait for a URI to be present | ||
ProgressView() | ||
} else { | ||
EmptyView() | ||
} | ||
} | ||
Spacer() | ||
VStack { | ||
if todo.photoId == nil { | ||
HStack { | ||
if isCameraAvailable { | ||
Button { | ||
capturePhotoTapped() | ||
} label: { | ||
Image(systemName: "camera.fill") | ||
} | ||
.buttonStyle(.plain) | ||
} | ||
Button { | ||
selectPhotoTapped() | ||
} label: { | ||
Image(systemName: "photo.on.rectangle") | ||
} | ||
.buttonStyle(.plain) | ||
} | ||
} else { | ||
Button { | ||
deletePhotoTapped() | ||
} label: { | ||
Image(systemName: "trash.fill") | ||
} | ||
.buttonStyle(.plain) | ||
} | ||
Spacer() | ||
Button { | ||
completeTapped() | ||
} label: { | ||
Image(systemName: todo.isComplete ? "checkmark.circle.fill" : "circle") | ||
} | ||
.buttonStyle(.plain) | ||
}.onChange(of: todo.photoId) { _, newPhotoId in | ||
if newPhotoId == nil { | ||
// Clear the image when photoId becomes nil | ||
image = nil | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private func loadImage() { | ||
guard let urlString = todo.photoUri else { | ||
return | ||
} | ||
|
||
if let imageData = try? Data(contentsOf: URL(fileURLWithPath: urlString)), | ||
let loadedImage = UIImage(data: imageData) | ||
{ | ||
image = loadedImage | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
TodoListRow( | ||
todo: .init( | ||
id: UUID().uuidString.lowercased(), | ||
listId: UUID().uuidString.lowercased(), | ||
photoId: nil, | ||
description: "description", | ||
isComplete: false, | ||
createdAt: "", | ||
completedAt: nil, | ||
createdBy: UUID().uuidString.lowercased(), | ||
completedBy: nil | ||
) | ||
todo: .init( | ||
id: UUID().uuidString.lowercased(), | ||
listId: UUID().uuidString.lowercased(), | ||
photoId: nil, | ||
description: "description", | ||
isComplete: false, | ||
createdAt: "", | ||
completedAt: nil, | ||
createdBy: UUID().uuidString.lowercased(), | ||
completedBy: nil, | ||
|
||
), | ||
isCameraAvailable: true, | ||
completeTapped: {}, | ||
deletePhotoTapped: {}, | ||
capturePhotoTapped: {} | ||
) {} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.