diff --git a/.swiftformat b/.swiftformat index 21f72f9..2f6ed6f 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,2 +1,2 @@ ---swiftversion 5.8 +--swiftversion 5.7 --disable preferKeyPath \ No newline at end of file diff --git a/Package.swift b/Package.swift index eeb3c51..69f2af7 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.8 +// swift-tools-version: 5.7 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription diff --git a/Sources/OversizeCalendarKit/CreateEventScreen/AttachmentScreen/AttachmentView.swift b/Sources/OversizeCalendarKit/CreateEventScreen/AttachmentScreen/AttachmentView.swift index 78a3809..74fa535 100644 --- a/Sources/OversizeCalendarKit/CreateEventScreen/AttachmentScreen/AttachmentView.swift +++ b/Sources/OversizeCalendarKit/CreateEventScreen/AttachmentScreen/AttachmentView.swift @@ -15,12 +15,12 @@ public struct AttachmentView: View { SectionView { VStack(spacing: .zero) { Row("Add investment") { - Icon(.paperclip) + IconDeprecated(.paperclip) .iconColor(.onSurfaceHighEmphasis) } Row("Add link") { - Icon(.link) + IconDeprecated(.link) .iconColor(.onSurfaceHighEmphasis) } } diff --git a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift index f68aa44..bea12ee 100644 --- a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift +++ b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift @@ -187,7 +187,7 @@ public struct CreateEventView: View { Row(viewModel.repitRule.title, subtitle: repeatSubtitleText) { viewModel.present(.repeat) } leading: { - Icon(.refresh) + IconDeprecated(.refresh) .iconColor(.onSurfaceHighEmphasis) } .rowClearButton(style: .onSurface) { @@ -213,7 +213,7 @@ public struct CreateEventView: View { Row(email) { viewModel.present(.invites) } leading: { - Icon(.user) + IconDeprecated(.user) .iconColor(.onSurfaceHighEmphasis) } .rowClearButton(style: .onSurface) { @@ -247,7 +247,7 @@ public struct CreateEventView: View { Row(alarm.title) { viewModel.present(.alarm) } leading: { - Icon(.bell) + IconDeprecated(.bell) .iconColor(.onSurfaceHighEmphasis) } .rowClearButton(style: .onSurface) { @@ -281,7 +281,7 @@ public struct CreateEventView: View { Row(locationName) { viewModel.present(.location) } leading: { - Icon(.mapPin) + IconDeprecated(.mapPin) .iconColor(.onSurfaceHighEmphasis) } .rowClearButton(style: .onSurface) { @@ -426,7 +426,7 @@ public struct CreateEventView: View { if viewModel.isFetchUpdatePositon { ProgressView() } else { - Icon(.mapPin) + IconDeprecated(.mapPin) // Icon.Solid.NavigationandTravel.location // .renderingMode(.template) } @@ -434,25 +434,25 @@ public struct CreateEventView: View { .disabled(viewModel.isFetchUpdatePositon) Button { viewModel.present(.alarm) } label: { - Icon(.bell) + IconDeprecated(.bell) // Icon.Solid.UserInterface.bell // .renderingMode(.template) } Button { viewModel.present(.repeat) } label: { - Icon(.refresh) + IconDeprecated(.refresh) } /* Button { viewModel.present(.attachment) } label: { - Icon(.moreHorizontal) + IconDeprecated(.moreHorizontal) } */ Spacer() Button { viewModel.present(.invites) } label: { - Icon(.userPlus) + IconDeprecated(.userPlus) } // Icon.Solid.UserInterface.plusCrFr diff --git a/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift b/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift index c39641e..4b9fc71 100644 --- a/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift +++ b/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift @@ -5,11 +5,11 @@ import Contacts import EventKit +import Factory import OversizeContactsService import OversizeCore import OversizeServices import SwiftUI -import Factory @MainActor class AttendeesViewModel: ObservableObject { diff --git a/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift b/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift index 6d62691..f1cac90 100644 --- a/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift +++ b/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift @@ -4,11 +4,11 @@ // import Contacts +import Factory import OversizeContactsService import OversizeCore import OversizeServices import SwiftUI -import Factory @MainActor public class ContactsListsViewModel: ObservableObject { diff --git a/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift b/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift index 31892c1..b4241e4 100644 --- a/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift +++ b/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift @@ -4,11 +4,11 @@ // import Contacts +import Factory import OversizeContactsService import OversizeCore import OversizeServices import SwiftUI -import Factory @MainActor class EmailPickerViewModel: ObservableObject { diff --git a/Sources/OversizeKit/LauncherKit/RateAppScreen.swift b/Sources/OversizeKit/LauncherKit/RateAppScreen.swift index 3c0b699..a762121 100644 --- a/Sources/OversizeKit/LauncherKit/RateAppScreen.swift +++ b/Sources/OversizeKit/LauncherKit/RateAppScreen.swift @@ -3,9 +3,9 @@ // RateAppScreen.swift // +import Factory import OversizeResources import OversizeServices -import Factory import OversizeUI import SwiftUI @@ -36,7 +36,7 @@ struct RateAppScreen: View { if let reviewUrl = Info.url.appStoreReview { HStack(spacing: .large) { Link(destination: reviewUrl) { - Icon(.thumbsUp, color: .onPrimaryHighEmphasis) + IconDeprecated(.thumbsUp, color: .onPrimaryHighEmphasis) } .buttonStyle(.primary(infinityWidth: false)) .accent() @@ -49,7 +49,7 @@ struct RateAppScreen: View { reviewService.estimate(goodRating: false) dismiss() } label: { - Icon(.thumbsDown, color: .onSurfaceHighEmphasis) + IconDeprecated(.thumbsDown, color: .onSurfaceHighEmphasis) } .buttonStyle(.secondary(infinityWidth: false)) } @@ -65,7 +65,7 @@ struct RateAppScreen: View { reviewService.rewiewBunnerClosed() dismiss() } label: { - Icon(.xMini, color: .onSurfaceHighEmphasis) + IconDeprecated(.xMini, color: .onSurfaceHighEmphasis) } .buttonStyle(.tertiary(infinityWidth: false)) .controlSize(.mini) diff --git a/Sources/OversizeKit/LockscreenKit/LockscreenView.swift b/Sources/OversizeKit/LockscreenKit/LockscreenView.swift index 774e2ce..a0ea5e7 100644 --- a/Sources/OversizeKit/LockscreenKit/LockscreenView.swift +++ b/Sources/OversizeKit/LockscreenKit/LockscreenView.swift @@ -226,7 +226,7 @@ public struct LockscreenView: View { } else if pinCode.isEmpty, !biometricEnabled { EmptyView() } else { - Icon(.delete) + IconDeprecated(.delete) } } // .opacity(pinCode.isEmpty && biometricEnabled ? 1 : 0) } diff --git a/Sources/OversizeKit/SettingsKit/Views/About/AboutView.swift b/Sources/OversizeKit/SettingsKit/Views/About/AboutView.swift index 5c3dc4d..f4f9172 100644 --- a/Sources/OversizeKit/SettingsKit/Views/About/AboutView.swift +++ b/Sources/OversizeKit/SettingsKit/Views/About/AboutView.swift @@ -7,7 +7,6 @@ import OversizeComponents import OversizeLocalizable import OversizeResources import OversizeServices - import OversizeUI import SwiftUI @@ -238,7 +237,7 @@ import SwiftUI .foregroundColor(.surfaceSecondary) .frame(width: 74, height: 74) - Icon(.externalLink) + IconDeprecated(.externalLink) } } diff --git a/Sources/OversizeKit/SettingsKit/Views/Apperance/AppearanceSettingView.swift b/Sources/OversizeKit/SettingsKit/Views/Apperance/AppearanceSettingView.swift index b5f1608..0c34573 100644 --- a/Sources/OversizeKit/SettingsKit/Views/Apperance/AppearanceSettingView.swift +++ b/Sources/OversizeKit/SettingsKit/Views/Apperance/AppearanceSettingView.swift @@ -130,9 +130,9 @@ import SwiftUI .padding(.vertical, .medium) if appearance == theme.appearance { - Icon(.checkCircle, color: Color.accent) + IconDeprecated(.checkCircle, color: Color.accent) } else { - Icon(.circle, color: .onSurfaceMediumEmphasis) + IconDeprecated(.circle, color: .onSurfaceMediumEmphasis) } } Spacer() diff --git a/Sources/OversizeKit/SettingsKit/Views/Notifications/NotificationsSettingsView.swift b/Sources/OversizeKit/SettingsKit/Views/Notifications/NotificationsSettingsView.swift index 5b3cbbe..3ad2857 100644 --- a/Sources/OversizeKit/SettingsKit/Views/Notifications/NotificationsSettingsView.swift +++ b/Sources/OversizeKit/SettingsKit/Views/Notifications/NotificationsSettingsView.swift @@ -5,7 +5,6 @@ import OversizeLocalizable import OversizeServices - import OversizeUI import SwiftUI diff --git a/Sources/OversizeKit/SettingsKit/Views/Security/PINCode/SetPINCodeView.swift b/Sources/OversizeKit/SettingsKit/Views/Security/PINCode/SetPINCodeView.swift index a1b894b..8bfb6a8 100644 --- a/Sources/OversizeKit/SettingsKit/Views/Security/PINCode/SetPINCodeView.swift +++ b/Sources/OversizeKit/SettingsKit/Views/Security/PINCode/SetPINCodeView.swift @@ -4,13 +4,12 @@ // import OversizeLocalizable - import OversizeUI import SwiftUI public struct SetPINCodeView: View { @ObservedObject var viewModel: SetPINCodeViewModel - @EnvironmentObject private var hud: HUD + @EnvironmentObject private var hud: HUDDeprecated @Environment(\.dismiss) var dismiss public init(action: PINCodeAction) { @@ -25,7 +24,7 @@ public struct SetPINCodeView: View { Button { dismiss() } label: { - Icon(.xMini, color: .onSurfaceHighEmphasis) + IconDeprecated(.xMini, color: .onSurfaceHighEmphasis) } .buttonStyle(.secondary) diff --git a/Sources/OversizeKit/SettingsKit/Views/Security/SecuritySettingsView.swift b/Sources/OversizeKit/SettingsKit/Views/Security/SecuritySettingsView.swift index 3d5c1e6..f8c6345 100644 --- a/Sources/OversizeKit/SettingsKit/Views/Security/SecuritySettingsView.swift +++ b/Sources/OversizeKit/SettingsKit/Views/Security/SecuritySettingsView.swift @@ -3,11 +3,11 @@ // SecuritySettingsView.swift // +import Factory import OversizeLocalizable import OversizeServices import OversizeUI import SwiftUI -import Factory // swiftlint:disable line_length #if os(iOS) @@ -61,7 +61,7 @@ import Factory }) ) { Row(biometricService.biometricType.rawValue) { - Icon(.file) + IconDeprecated(.file) // leadingType: .systemImage(biometricImageName) } } @@ -80,7 +80,7 @@ import Factory }) ) { Row(biometricService.biometricType.rawValue) { - Icon(.lock) + IconDeprecated(.lock) } }.sheet(item: $isSetPINCodeSheet) { sheet in SetPINCodeView(action: sheet) diff --git a/Sources/OversizeKit/SettingsKit/Views/SettingsView.swift b/Sources/OversizeKit/SettingsKit/Views/SettingsView.swift index e913598..ad5869e 100644 --- a/Sources/OversizeKit/SettingsKit/Views/SettingsView.swift +++ b/Sources/OversizeKit/SettingsKit/Views/SettingsView.swift @@ -18,7 +18,7 @@ import SwiftUI @Environment(\.iconStyle) var iconStyle: IconStyle @Environment(\.theme) var theme: ThemeSettings @StateObject var settingsService = SettingsService() - @EnvironmentObject var hudState: HUD + @EnvironmentObject var hudState: HUDDeprecated let appSection: AppSection let headSection: HeadSection @@ -292,15 +292,6 @@ import SwiftUI FeedbackView() .presentationDetents([.medium]) } - -// -// // Telegramm chat -// if let telegramChatUrl = AppInfo.url.appTelegramChat, let id = AppInfo.app.telegramChatID, !id.isEmpty { -// Link(destination: telegramChatUrl) { -// Row(L10n.Settings.telegramChat, leadingType: .image(chatIcon), trallingType: rowType) -// } -// .buttonStyle(.row) -// } } } } diff --git a/Sources/OversizeKit/SettingsKit/Views/SoundAndVibration/SoundsAndVibrationsSettingsView.swift b/Sources/OversizeKit/SettingsKit/Views/SoundAndVibration/SoundsAndVibrationsSettingsView.swift index eb841c7..1480d8d 100644 --- a/Sources/OversizeKit/SettingsKit/Views/SoundAndVibration/SoundsAndVibrationsSettingsView.swift +++ b/Sources/OversizeKit/SettingsKit/Views/SoundAndVibration/SoundsAndVibrationsSettingsView.swift @@ -60,7 +60,7 @@ import SwiftUI if FeatureFlags.app.sounds.valueOrFalse { Switch(isOn: $settingsService.soundsEnabled) { Row(L10n.Settings.sounds) { - Icon(.music) + IconDeprecated(.music) } } } @@ -68,7 +68,7 @@ import SwiftUI if FeatureFlags.app.vibration.valueOrFalse { Switch(isOn: $settingsService.vibrationEnabled) { Row(L10n.Settings.vibration) { - Icon(.radio) + IconDeprecated(.radio) } } } diff --git a/Sources/OversizeKit/SettingsKit/Views/iCloud/iCloudSettingsView.swift b/Sources/OversizeKit/SettingsKit/Views/iCloud/iCloudSettingsView.swift index 3fc7ff9..c5f71b2 100644 --- a/Sources/OversizeKit/SettingsKit/Views/iCloud/iCloudSettingsView.swift +++ b/Sources/OversizeKit/SettingsKit/Views/iCloud/iCloudSettingsView.swift @@ -5,7 +5,6 @@ import OversizeLocalizable import OversizeServices - import OversizeUI import SwiftUI @@ -48,7 +47,7 @@ import SwiftUI if FeatureFlags.app.сloudKit.valueOrFalse { Switch(isOn: $settingsService.cloudKitEnabled) { Row(L10n.Settings.iCloudSync) { - Icon(.cloud) + IconDeprecated(.cloud) } .premium() .onPremiumTap() @@ -67,7 +66,7 @@ import SwiftUI if FeatureFlags.app.healthKit.valueOrFalse { Switch(isOn: $settingsService.healthKitEnabled) { Row("HealthKit synchronization", subtitle: "After switching on, data from the Health app will be downloaded") { - Icon(.heart) + IconDeprecated(.heart) } } } diff --git a/Sources/OversizeKit/StoreKit/StoreScreen/ViewModel/StoreViewModel.swift b/Sources/OversizeKit/StoreKit/StoreScreen/ViewModel/StoreViewModel.swift index a31aef5..cf25592 100644 --- a/Sources/OversizeKit/StoreKit/StoreScreen/ViewModel/StoreViewModel.swift +++ b/Sources/OversizeKit/StoreKit/StoreScreen/ViewModel/StoreViewModel.swift @@ -3,13 +3,13 @@ // StoreViewModel.swift // +import Factory import OversizeCore import OversizeLocalizable import OversizeServices import OversizeStoreService import StoreKit import SwiftUI -import Factory @MainActor class StoreViewModel: ObservableObject { diff --git a/Sources/OversizeKit/StoreKit/Views/StoreFeatureDetailView.swift b/Sources/OversizeKit/StoreKit/Views/StoreFeatureDetailView.swift index fe496f5..79e0f24 100644 --- a/Sources/OversizeKit/StoreKit/Views/StoreFeatureDetailView.swift +++ b/Sources/OversizeKit/StoreKit/Views/StoreFeatureDetailView.swift @@ -44,7 +44,7 @@ struct StoreFeatureDetailView: View { Button { dismiss() } label: { - Icon(.xMini, color: selection.screenURL != nil ? .onPrimaryHighEmphasis : .onSurfaceDisabled) + IconDeprecated(.xMini, color: selection.screenURL != nil ? .onPrimaryHighEmphasis : .onSurfaceDisabled) .padding(.xxSmall) .background { Circle() diff --git a/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift b/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift index acc2cd2..73ac63e 100644 --- a/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift +++ b/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift @@ -152,7 +152,7 @@ public struct StoreProductView: View { .fill(Color.onPrimaryHighEmphasis) .frame(width: 20, height: 20) .overlay { - Icon(.checkMini, color: topLabelbackgroundColor) + IconDeprecated(.checkMini, color: topLabelbackgroundColor) } .padding(.trailing, .xxSmall) } @@ -210,7 +210,7 @@ public struct StoreProductView: View { .fill(topLabelbackgroundColor) .frame(width: 20, height: 20) .overlay { - Icon(.checkMini, color: Color.onPrimaryHighEmphasis) + IconDeprecated(.checkMini, color: Color.onPrimaryHighEmphasis) } .padding(.top, .xxxSmall) .padding(.trailing, .xxxSmall) diff --git a/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift b/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift index 96dd8e0..10b3274 100644 --- a/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift +++ b/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift @@ -108,6 +108,26 @@ public struct ErrorView: View { } else { return nil } + case let .cloudDocuments(type: type): + if type == .notAccess { + return .accent(L10n.Button.goToSettings, action: { + #if os(iOS) + UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!) + #endif + }) + } else { + return nil + } + case let .fileManager(type: type): + if type == .notAccess { + return .accent(L10n.Button.goToSettings, action: { + #if os(iOS) + UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!) + #endif + }) + } else { + return nil + } } } } diff --git a/Sources/OversizeKit/SystemKit/SystemServices.swift b/Sources/OversizeKit/SystemKit/SystemServices.swift index f74efb6..733abbf 100644 --- a/Sources/OversizeKit/SystemKit/SystemServices.swift +++ b/Sources/OversizeKit/SystemKit/SystemServices.swift @@ -20,7 +20,7 @@ public struct SystemServicesModifier: ViewModifier { @Environment(\.theme) var theme: ThemeSettings @AppStorage("AppState.PremiumState") var isPremium: Bool = false - @StateObject var hudState = HUD() + @StateObject var hudState = HUDDeprecated() @State var blurRadius: CGFloat = 0 @State var oppacity: CGFloat = 1 @@ -70,7 +70,7 @@ public struct SystemServicesModifier: ViewModifier { .premiumStatus(isPremium) .theme(ThemeSettings()) .screenSize(geometry) - .hud(isPresented: $hudState.isPresented, type: $hudState.type) { + .hudDeprecated(isPresented: $hudState.isPresented, type: $hudState.type) { HUDContent(title: hudState.title, image: hudState.image, type: hudState.type) } .environmentObject(hudState) diff --git a/Sources/OversizeLocationKit/AddressField/AddressField.swift b/Sources/OversizeLocationKit/AddressField/AddressField.swift index 0a9a32f..1a8faa4 100644 --- a/Sources/OversizeLocationKit/AddressField/AddressField.swift +++ b/Sources/OversizeLocationKit/AddressField/AddressField.swift @@ -79,7 +79,7 @@ public struct AddressField: View { .lineLimit(1) } Spacer() - Icon(.chevronDown, color: .onSurfaceHighEmphasis) + IconDeprecated(.chevronDown, color: .onSurfaceHighEmphasis) } } .contentShape(Rectangle()) diff --git a/Sources/OversizeLocationKit/AddressPicker/AddressPicker.swift b/Sources/OversizeLocationKit/AddressPicker/AddressPicker.swift index 1858988..33b1775 100644 --- a/Sources/OversizeLocationKit/AddressPicker/AddressPicker.swift +++ b/Sources/OversizeLocationKit/AddressPicker/AddressPicker.swift @@ -111,7 +111,7 @@ public struct AddressPicker: View { onSaveCurrntPosition() } } leading: { - Icon(.navigation) + IconDeprecated(.navigation) .iconOnSurface() } .padding(.bottom, viewModel.searchTerm.isEmpty ? .small : .zero) @@ -128,7 +128,7 @@ public struct AddressPicker: View { onCompleteSearth(seletedAddress: address.address, seletedLocation: nil, seletedPlace: address.place, saveToHistory: false) } } leading: { - Icon(.mapPin) + IconDeprecated(.mapPin) .iconOnSurface() } .rowClearButton { @@ -145,7 +145,7 @@ public struct AddressPicker: View { Row(location.title, subtitle: location.subtitle) { reverseGeo(location: location) } leading: { - Icon(.mapPin) + IconDeprecated(.mapPin) .iconOnSurface() } } diff --git a/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift b/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift index dff7788..239478c 100644 --- a/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift +++ b/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift @@ -5,11 +5,11 @@ import Combine import CoreLocation +import Factory import MapKit import OversizeLocationService import OversizeServices import SwiftUI -import Factory @MainActor class AddressPickerViewModel: NSObject, ObservableObject { diff --git a/Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateView.swift b/Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateView.swift index f6dda80..2939463 100644 --- a/Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateView.swift +++ b/Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateView.swift @@ -77,7 +77,7 @@ public struct MapCoordinateView: View { Button { viewModel.zoomIn() } label: { - Icon(.plus) + IconDeprecated(.plus) .onSurfaceMediumEmphasisForegroundColor() .padding(.xxSmall) } @@ -85,7 +85,7 @@ public struct MapCoordinateView: View { Button { viewModel.zoomOut() } label: { - Icon(.minus) + IconDeprecated(.minus) .onSurfaceMediumEmphasisForegroundColor() .padding(.xxSmall) } @@ -102,7 +102,7 @@ public struct MapCoordinateView: View { viewModel.positionInLocation() } label: { - Icon(.navigation) + IconDeprecated(.navigation) .onSurfaceMediumEmphasisForegroundColor() .padding(.xxSmall) } diff --git a/Sources/OversizeNotificationKit/LocalNotificationView.swift b/Sources/OversizeNotificationKit/LocalNotificationView.swift index b9a7fb0..740ccd9 100644 --- a/Sources/OversizeNotificationKit/LocalNotificationView.swift +++ b/Sources/OversizeNotificationKit/LocalNotificationView.swift @@ -87,7 +87,7 @@ public struct LocalNotificationView: View { isPendingNotification = false dismiss() } trailing: { - Icon(.trash) + IconDeprecated(.trash) .iconColor(Color.error) } } diff --git a/Sources/OversizePhotoKit/PhotoOptionsView.swift b/Sources/OversizePhotoKit/PhotoOptionsView.swift new file mode 100644 index 0000000..0f41b44 --- /dev/null +++ b/Sources/OversizePhotoKit/PhotoOptionsView.swift @@ -0,0 +1,100 @@ +// +// Copyright © 2023 Alexander Romanov +// PhotoOptionsView.swift, created on 08.05.2023 +// + +import OversizeUI +import SwiftUI + +private struct SharePhoto: Transferable { + @available(iOS 16.0, *) + fileprivate static var transferRepresentation: some TransferRepresentation { + ProxyRepresentation(exporting: \.image) + } + + fileprivate var image: Image +} + +public struct PhotoOptionsView: View where A: View { + @Environment(\.dismiss) private var dismiss: DismissAction + private let image: Image + + private let photo: SharePhoto + + private let date: Date? + private let actions: Group? + private let deleteAction: (() -> Void)? + + @State private var isShowAlert: Bool = false + + public init( + image: Image, + date: Date?, + @ViewBuilder actions: @escaping () -> A, + deleteAction: (() -> Void)? = nil + ) { + self.image = image + self.date = date + photo = SharePhoto(image: image) + self.actions = Group { actions() } + self.deleteAction = deleteAction + } + + public var body: some View { + PageView { + content + } + .titleLabel { + Row("Photo", subtitle: date?.formatted(date: .long, time: .omitted)) { + image + } + .rowContentInset(.init(horizontal: .zero, vertical: .xSmall)) + } + .trailingBar { BarButton(.close) } + .backgroundSecondary() + .alert("Are you sure you want to delete?", isPresented: $isShowAlert) { + Button("Delete", role: .destructive) { + deleteAction?() + } + } + } + + private var content: some View { + VStack(spacing: .medium) { + SectionView { + VStack { + if #available(iOS 16.0, *) { + ShareLink( + item: photo, + preview: SharePreview( + "Photo", + image: photo.image + ) + ) { + Row("Share") { + Icon(Icons.Base.upload) + } + } + } + + actions + } + .buttonStyle(.row) + } + .surfaceContentRowInsets() + + if deleteAction != nil { + SectionView { + VStack { + RowButton("Delete", style: .delete, action: { + isShowAlert.toggle() + }) + .multilineTextAlignment(.center) + } + } + .surfaceContentRowInsets() + } + } + .padding(.top, -16) + } +} diff --git a/Sources/OversizePhotoKit/PhotoViewerView.swift b/Sources/OversizePhotoKit/PhotoViewerView.swift index 1c1f223..c5d31e4 100644 --- a/Sources/OversizePhotoKit/PhotoViewerView.swift +++ b/Sources/OversizePhotoKit/PhotoViewerView.swift @@ -3,8 +3,6 @@ // PhotoViewerView.swift // -import SwiftUI - import OversizePhotoComponents import OversizeUI import SwiftUI