Fix ios17 warnings

This commit is contained in:
Marcin Czachurski 2023-10-19 09:29:49 +02:00
parent df3ae90c94
commit 27cba57c38
25 changed files with 69 additions and 77 deletions

View File

@ -7,9 +7,7 @@ let package = Package(
name: "ClientKit",
defaultLocalization: "en",
platforms: [
.iOS(.v16),
.macOS(.v12),
.watchOS(.v8)
.iOS(.v17)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.

View File

@ -7,9 +7,7 @@ let package = Package(
name: "EnvironmentKit",
defaultLocalization: "en",
platforms: [
.iOS(.v16),
.macOS(.v12),
.watchOS(.v8)
.iOS(.v17)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.

View File

@ -7,9 +7,7 @@ let package = Package(
name: "PixelfedKit",
defaultLocalization: "en",
platforms: [
.iOS(.v16),
.macOS(.v12),
.watchOS(.v8)
.iOS(.v17)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.

View File

@ -46,7 +46,7 @@ From time to time you have to come back and translate lines which has been added
Things that should be implemented in version 2.0:
- [ ] Use auto generated resources (Color/Images) instead static extensions (how to do this in separete Swift Packages?)
- [ ] Move to xcstring (new Xcode transaction system)
- [x] Move to xcstring (new Xcode transaction system)
- [ ] Move to new Observable macro (iOS 17)
- [ ] Migrate to SwiftData (iOS 17)
- [ ] Use ViewModels

View File

@ -7,9 +7,7 @@ let package = Package(
name: "ServicesKit",
defaultLocalization: "en",
platforms: [
.iOS(.v16),
.macOS(.v12),
.watchOS(.v8)
.iOS(.v17)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.

View File

@ -33,7 +33,7 @@ struct AnimatePlaceholderModifier: AnimatableModifier {
guard isLoading else { return }
isAnim.toggle()
}
.onChange(of: isLoading) { _ in
.onChange(of: isLoading) {
isAnim.toggle()
}
}

View File

@ -78,24 +78,24 @@ struct VernissageApp: App {
await self.calculateNewPhotosInBackground()
}
}
.onChange(of: applicationState.theme) { newValue in
.onChange(of: applicationState.theme) { oldValue, newValue in
self.theme = newValue.colorScheme()
}
.onChange(of: applicationState.tintColor) { newValue in
.onChange(of: applicationState.tintColor) { oldValue, newValue in
self.tintColor = newValue.color()
}
.onChange(of: applicationState.account) { newValue in
.onChange(of: applicationState.account) { oldValue, newValue in
if newValue == nil {
self.applicationViewMode = .signIn
}
}
.onChange(of: applicationState.showStatusId) { newValue in
.onChange(of: applicationState.showStatusId) { oldValue, newValue in
if let statusId = newValue {
self.routerPath.navigate(to: .status(id: statusId))
self.applicationState.showStatusId = nil
}
}
.onChange(of: applicationState.showAccountId) { newValue in
.onChange(of: applicationState.showAccountId) { oldValue, newValue in
if let accountId = newValue {
self.routerPath.navigate(to: .userProfile(accountId: accountId, accountDisplayName: nil, accountUserName: ""))
self.applicationState.showAccountId = nil

View File

@ -93,7 +93,7 @@ struct EditProfileView: View {
}
}
}
.onChange(of: self.selectedItems) { _ in
.onChange(of: self.selectedItems) {
Task {
await self.getAvatar()
}
@ -168,9 +168,9 @@ struct EditProfileView: View {
private func formView() -> some View {
Section {
TextField("", text: $displayName)
.onChange(of: self.displayName, perform: { _ in
.onChange(of: self.displayName) {
self.displayName = String(self.displayName.prefix(self.displayNameMaxLength))
})
}
} header: {
Text("editProfile.title.displayName", comment: "Display name")
} footer: {
@ -183,9 +183,9 @@ struct EditProfileView: View {
Section {
TextField("", text: $bio, axis: .vertical)
.lineLimit(5, reservesSpace: true)
.onChange(of: self.bio, perform: { _ in
.onChange(of: self.bio) {
self.bio = String(self.bio.prefix(self.bioMaxLength))
})
}
} header: {
Text("editProfile.title.bio", comment: "Bio")
} footer: {
@ -200,9 +200,9 @@ struct EditProfileView: View {
.autocapitalization(.none)
.keyboardType(.URL)
.autocorrectionDisabled()
.onChange(of: self.website, perform: { _ in
.onChange(of: self.website) {
self.website = String(self.website.prefix(self.websiteMaxLength))
})
}
} header: {
Text("editProfile.title.website", comment: "Website")
} footer: {

View File

@ -98,7 +98,7 @@ struct HomeFeedView: View {
await self.refreshData()
HapticService.shared.fireHaptic(of: .dataRefresh(intensity: 0.7))
}
.onChange(of: self.applicationState.amountOfNewStatuses) { _ in
.onChange(of: self.applicationState.amountOfNewStatuses) {
self.calculateOffset()
}.onAppear {
self.calculateOffset()

View File

@ -102,8 +102,8 @@ struct MainView: View {
self.getTrailingToolbar()
}
}
.onChange(of: tipsStore.status) { status in
if status == .successful {
.onChange(of: tipsStore.status) { oldStatus, newStatus in
if newStatus == .successful {
withAnimation(.spring()) {
self.routerPath.presentedOverlay = .successPayment
self.tipsStore.reset()

View File

@ -75,17 +75,17 @@ struct SettingsView: View {
.withAppRouteur()
.withOverlayDestinations(overlayDestinations: $routerPath.presentedOverlay)
}
.onChange(of: self.applicationState.theme) { _ in
.onChange(of: self.applicationState.theme) {
// Change theme of current modal screen (unformtunatelly it's not changed autmatically.
self.theme = self.applicationState.theme.colorScheme() ?? self.getSystemColorScheme()
}
.onChange(of: applicationState.account) { newValue in
.onChange(of: applicationState.account) { oldValue, newValue in
if newValue == nil {
self.dismiss()
}
}
.onChange(of: tipsStore.status) { status in
if status == .successful {
.onChange(of: tipsStore.status) { oldStatus, newStatus in
if newStatus == .successful {
withAnimation(.spring()) {
self.routerPath.presentedOverlay = .successPayment
self.tipsStore.reset()

View File

@ -57,9 +57,9 @@ struct GeneralSectionView: View {
Text("settings.title.applicationIcon", comment: "Application icon")
}
.pickerStyle(.navigationLink)
.onChange(of: self.applicationState.activeIcon) { iconName in
ApplicationSettingsHandler.shared.set(activeIcon: iconName)
UIApplication.shared.setAlternateIconName(iconName == "Default" ? nil : iconName)
.onChange(of: self.applicationState.activeIcon) { oldIncomeName, newIconName in
ApplicationSettingsHandler.shared.set(activeIcon: newIconName)
UIApplication.shared.setAlternateIconName(newIconName == "Default" ? nil : newIconName)
}
// Application theme.
@ -71,8 +71,8 @@ struct GeneralSectionView: View {
} label: {
Text("settings.title.theme", comment: "Theme")
}
.onChange(of: self.applicationState.theme) { theme in
ApplicationSettingsHandler.shared.set(theme: theme)
.onChange(of: self.applicationState.theme) { oldTheme, newTheme in
ApplicationSettingsHandler.shared.set(theme: newTheme)
}
// Menu position.
@ -84,8 +84,8 @@ struct GeneralSectionView: View {
} label: {
Text("settings.title.menuPosition", comment: "Menu position")
}
.onChange(of: self.applicationState.menuPosition) { menuPosition in
ApplicationSettingsHandler.shared.set(menuPosition: menuPosition)
.onChange(of: self.applicationState.menuPosition) { oldMenuPosition, newMenuPosition in
ApplicationSettingsHandler.shared.set(menuPosition: newMenuPosition)
}
}
}

View File

@ -21,25 +21,25 @@ struct HapticsSectionView: View {
Section("settings.title.haptics") {
Toggle("settings.title.hapticsTabSelection", isOn: $hapticTabSelectionEnabled)
.onChange(of: hapticTabSelectionEnabled) { newValue in
.onChange(of: hapticTabSelectionEnabled) { oldValue, newValue in
self.applicationState.hapticTabSelectionEnabled = newValue
ApplicationSettingsHandler.shared.set(hapticTabSelectionEnabled: newValue)
}
Toggle("settings.title.hapticsButtonPress", isOn: $hapticButtonPressEnabled)
.onChange(of: hapticButtonPressEnabled) { newValue in
.onChange(of: hapticButtonPressEnabled) { oldValue, newValue in
self.applicationState.hapticButtonPressEnabled = newValue
ApplicationSettingsHandler.shared.set(hapticButtonPressEnabled: newValue)
}
Toggle("settings.title.hapticsListRefresh", isOn: $hapticRefreshEnabled)
.onChange(of: hapticRefreshEnabled) { newValue in
.onChange(of: hapticRefreshEnabled) { oldValue, newValue in
self.applicationState.hapticRefreshEnabled = newValue
ApplicationSettingsHandler.shared.set(hapticRefreshEnabled: newValue)
}
Toggle("settings.title.hapticsAnimationFinished", isOn: $hapticAnimationEnabled)
.onChange(of: hapticAnimationEnabled) { newValue in
.onChange(of: hapticAnimationEnabled) { oldValue, newValue in
self.applicationState.hapticAnimationEnabled = newValue
ApplicationSettingsHandler.shared.set(hapticAnimationEnabled: newValue)
}

View File

@ -22,7 +22,7 @@ struct MediaSettingsView: View {
.foregroundColor(.customGrayColor)
}
}
.onChange(of: self.applicationState.showSensitive) { newValue in
.onChange(of: self.applicationState.showSensitive) { oldValue, newValue in
ApplicationSettingsHandler.shared.set(showSensitive: newValue)
}
@ -34,7 +34,7 @@ struct MediaSettingsView: View {
.foregroundColor(.customGrayColor)
}
}
.onChange(of: self.applicationState.showPhotoDescription) { newValue in
.onChange(of: self.applicationState.showPhotoDescription) { oldValue, newValue in
ApplicationSettingsHandler.shared.set(showPhotoDescription: newValue)
}
@ -46,7 +46,7 @@ struct MediaSettingsView: View {
.foregroundColor(.customGrayColor)
}
}
.onChange(of: self.applicationState.showAvatarsOnTimeline) { newValue in
.onChange(of: self.applicationState.showAvatarsOnTimeline) { oldValue, newValue in
ApplicationSettingsHandler.shared.set(showAvatarsOnTimeline: newValue)
}
@ -58,7 +58,7 @@ struct MediaSettingsView: View {
.foregroundColor(.customGrayColor)
}
}
.onChange(of: self.applicationState.showFavouritesOnTimeline) { newValue in
.onChange(of: self.applicationState.showFavouritesOnTimeline) { oldValue, newValue in
ApplicationSettingsHandler.shared.set(showFavouritesOnTimeline: newValue)
}
@ -70,7 +70,7 @@ struct MediaSettingsView: View {
.foregroundColor(.customGrayColor)
}
}
.onChange(of: self.applicationState.showAltIconOnTimeline) { newValue in
.onChange(of: self.applicationState.showAltIconOnTimeline) { oldValue, newValue in
ApplicationSettingsHandler.shared.set(showAltIconOnTimeline: newValue)
}
@ -82,7 +82,7 @@ struct MediaSettingsView: View {
.foregroundColor(.customGrayColor)
}
}
.onChange(of: self.applicationState.warnAboutMissingAlt) { newValue in
.onChange(of: self.applicationState.warnAboutMissingAlt) { oldValue, newValue in
ApplicationSettingsHandler.shared.set(warnAboutMissingAlt: newValue)
}
@ -94,7 +94,7 @@ struct MediaSettingsView: View {
.foregroundColor(.customGrayColor)
}
}
.onChange(of: self.applicationState.showReboostedStatuses) { newValue in
.onChange(of: self.applicationState.showReboostedStatuses) { oldValue, newValue in
ApplicationSettingsHandler.shared.set(showReboostedStatuses: newValue)
}
@ -106,7 +106,7 @@ struct MediaSettingsView: View {
.foregroundColor(.customGrayColor)
}
}
.onChange(of: self.applicationState.hideStatusesWithoutAlt) { newValue in
.onChange(of: self.applicationState.hideStatusesWithoutAlt) { oldValue, newValue in
ApplicationSettingsHandler.shared.set(hideStatusesWithoutAlt: newValue)
}
}

View File

@ -54,7 +54,7 @@ struct CommentsSectionView: View {
}
}
}
.onChange(of: self.applicationState.newComment) { _ in
.onChange(of: self.applicationState.newComment) {
self.commentViewModels = nil
Task {
await self.loadComments()

View File

@ -143,7 +143,7 @@ struct StatusesView: View {
ErrorService.shared.handle(error, message: "statuses.error.loadingStatusesFailed", showToastr: !Task.isCancelled)
}
}
.onChange(of: self.applicationState.showReboostedStatuses) { _ in
.onChange(of: self.applicationState.showReboostedStatuses) {
if self.listType != .home {
return
}

View File

@ -36,7 +36,7 @@ struct TrendStatusesView: View {
}
.padding()
.pickerStyle(SegmentedPickerStyle())
.onChange(of: tabSelectedValue) { _ in
.onChange(of: tabSelectedValue) {
Task {
do {
self.state = .loading

View File

@ -74,8 +74,8 @@ struct ImageRow: View {
.onFirstAppear {
self.selected = self.attachmentsData.first?.id ?? String.empty()
}
.onChange(of: selected, perform: { attachmentId in
if let attachment = attachmentsData.first(where: { item in item.id == attachmentId }) {
.onChange(of: selected) { oldAttachmentId, newAttachmentId in
if let attachment = attachmentsData.first(where: { item in item.id == newAttachmentId }) {
let size = ImageSizeService.shared.calculate(width: Double(attachment.metaImageWidth),
height: Double(attachment.metaImageHeight),
andContainerWidth: UIScreen.main.bounds.size.width)
@ -87,7 +87,7 @@ struct ImageRow: View {
}
}
}
})
}
.frame(width: self.imageWidth, height: self.imageHeight)
.tabViewStyle(.page(indexDisplayMode: .never))
.overlay(CustomPageTabViewStyleView(pages: self.attachmentsData, currentId: $selected))

View File

@ -77,7 +77,7 @@ struct ImageRowAsync: View {
}
.frame(width: self.clipToRectangle ? self.containerWidth : self.imageWidth,
height: self.clipToRectangle ? self.containerWidth : self.imageHeight)
.onChange(of: self.containerWidth) { newContainerWidth in
.onChange(of: self.containerWidth) { oldContainerWidth, newContainerWidth in
let calculatedSize = ImageSizeService.shared.calculate(width: self.imageWidth,
height: self.imageHeight,
andContainerWidth: newContainerWidth)
@ -109,7 +109,7 @@ struct ImageRowAsync: View {
.tag(attachment.id)
}
}
.onChange(of: self.containerWidth) { newContainerWidth in
.onChange(of: self.containerWidth) { oldContainerWidth, newContainerWidth in
let calculatedSize = ImageSizeService.shared.calculate(width: self.imageWidth,
height: self.imageHeight,
andContainerWidth: newContainerWidth)
@ -119,8 +119,8 @@ struct ImageRowAsync: View {
.onFirstAppear {
self.selected = self.statusViewModel.mediaAttachments.first?.id ?? String.empty()
}
.onChange(of: selected, perform: { attachmentId in
if let attachment = self.statusViewModel.mediaAttachments.first(where: { item in item.id == attachmentId }) {
.onChange(of: selected) { oldAttachmentId, newAttachmentId in
if let attachment = self.statusViewModel.mediaAttachments.first(where: { item in item.id == newAttachmentId }) {
if let size = ImageSizeService.shared.get(for: attachment.url) {
let calculatedSize = ImageSizeService.shared.calculate(width: size.width,
height: size.height,
@ -134,7 +134,7 @@ struct ImageRowAsync: View {
}
}
}
})
}
.frame(width: self.clipToRectangle ? self.containerWidth : self.imageWidth,
height: self.clipToRectangle ? self.containerWidth : self.imageHeight)
.tabViewStyle(.page(indexDisplayMode: .never))

View File

@ -89,8 +89,8 @@ struct ImagesCarousel: View {
.padding(0)
.frame(height: self.imageHeight)
.tabViewStyle(PageTabViewStyle())
.onChange(of: selected, perform: { index in
if let attachment = attachments.first(where: { item in item.id == index }) {
.onChange(of: selected) { oldIndex, newIndex in
if let attachment = attachments.first(where: { item in item.id == newIndex }) {
self.selectedAttachment = attachment
self.exifCamera = attachment.exifCamera
self.exifExposure = attachment.exifExposure
@ -98,7 +98,7 @@ struct ImagesCarousel: View {
self.exifLens = attachment.exifLens
self.description = attachment.description
}
})
}
Spacer(minLength: 0)
}
.padding(0)

View File

@ -48,10 +48,10 @@ struct WaterfallGrid<Data, ID, Content>: View where Data: RandomAccessCollection
.onFirstAppear {
self.recalculateArrays()
}
.onChange(of: self.refreshId) { _ in
.onChange(of: self.refreshId) {
self.shouldRecalculate = true
}
.onChange(of: self.data) { _ in
.onChange(of: self.data) {
if self.shouldRecalculate {
self.recalculateArrays()
self.shouldRecalculate = false
@ -59,7 +59,7 @@ struct WaterfallGrid<Data, ID, Content>: View where Data: RandomAccessCollection
self.appendToArrays()
}
}
.onChange(of: self.columns) { _ in
.onChange(of: self.columns) {
self.recalculateArrays()
}
}

View File

@ -7,9 +7,7 @@ let package = Package(
name: "WidgetsKit",
defaultLocalization: "en",
platforms: [
.iOS(.v16),
.macOS(.v12),
.watchOS(.v8)
.iOS(.v17)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.

View File

@ -47,9 +47,9 @@ struct DeviceImageGallery: ViewModifier {
self.action(galleryProperties)
}
}
.onChange(of: self.horizontalSizeClass) { horizontalSize in
.onChange(of: self.horizontalSizeClass) { oldHorizontalSize, newHorizontalSize in
asyncAfter(0.1) {
let galleryProperties = self.getGalleryProperties(geometry: geometry, horizontalSize: horizontalSize ?? .compact)
let galleryProperties = self.getGalleryProperties(geometry: geometry, horizontalSize: newHorizontalSize ?? .compact)
self.action(galleryProperties)
}
}

View File

@ -134,10 +134,10 @@ public struct BaseComposeView: View {
await self.loadPhotos()
}
}
.onChange(of: self.textModel.text) { _ in
.onChange(of: self.textModel.text) {
self.refreshScreenState()
}
.onChange(of: self.selectedItems) { _ in
.onChange(of: self.selectedItems) {
Task {
await self.loadPhotos()
}

View File

@ -25,7 +25,9 @@ struct ExpandableText: View {
}
}
// Re-calculate isTruncated for the new text
.onChange(of: text, perform: { _ in isTruncated = nil })
.onChange(of: text) {
isTruncated = nil
}
}
func calculateTruncation(text: String) -> some View {