Refresh state of publish button.

This commit is contained in:
Marcin Czachursk 2023-02-22 21:17:11 +01:00
parent e4f5ac0a95
commit 77fbe141a8
2 changed files with 12 additions and 10 deletions

View File

@ -1035,7 +1035,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 26;
CURRENT_PROJECT_VERSION = 27;
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
DEVELOPMENT_TEAM = B2U9FEKYP8;
ENABLE_PREVIEWS = YES;
@ -1072,7 +1072,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 26;
CURRENT_PROJECT_VERSION = 27;
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
DEVELOPMENT_TEAM = B2U9FEKYP8;
ENABLE_PREVIEWS = YES;

View File

@ -159,8 +159,7 @@ struct ComposeView: View {
self.focusedField = .content
}
.onChange(of: self.text) { newValue in
self.publishDisabled = self.isPublishButtonDisabled()
self.interactiveDismissDisabled = self.isInteractiveDismissDisabled()
self.refreshScreenState()
}
.toolbar {
self.keyboardToolbar()
@ -180,13 +179,12 @@ struct ComposeView: View {
item != photoAttachment.photosPickerItem
})
self.photosAreAttached = self.photosAttachment.hasUploadedPhotos()
self.publishDisabled = self.isPublishButtonDisabled()
self.interactiveDismissDisabled = self.isInteractiveDismissDisabled()
self.refreshScreenState()
} upload: {
Task {
photoAttachment.error = nil
await self.upload(photoAttachment)
self.refreshScreenState()
}
}
}
@ -390,14 +388,18 @@ struct ComposeView: View {
// Change state of the screen.
self.photosAreUploading = false
self.photosAreAttached = self.photosAttachment.hasUploadedPhotos()
self.publishDisabled = self.isPublishButtonDisabled()
self.interactiveDismissDisabled = self.isInteractiveDismissDisabled()
self.refreshScreenState()
} catch {
ErrorService.shared.handle(error, message: "Cannot retreive image from library.", showToastr: true)
}
}
private func refreshScreenState() {
self.photosAreAttached = self.photosAttachment.hasUploadedPhotos()
self.publishDisabled = self.isPublishButtonDisabled()
self.interactiveDismissDisabled = self.isInteractiveDismissDisabled()
}
private func upload() async {
for photoAttachment in self.photosAttachment {
await self.upload(photoAttachment)