From 23dc9bb8c874436497465714a1bf8a9d5eec4875 Mon Sep 17 00:00:00 2001 From: Alexander Romanov Date: Thu, 30 Mar 2023 19:46:26 +0300 Subject: [PATCH 1/6] Add NotificationsKit --- Package.swift | 1 + .../LocalNotificationSetScreenViewModel.swift | 75 +++++++++ .../LocalNotificationView.swift | 114 +++++++++++++ .../LocalNotificationAlertsTimes.swift | 4 +- .../NotificationSetScreen.swift | 154 +++++++----------- 5 files changed, 247 insertions(+), 101 deletions(-) create mode 100644 Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift create mode 100644 Sources/OversizeNotificationKit/LocalNotificationView.swift rename Sources/OversizeNotificationKit/{ => Model}/LocalNotificationAlertsTimes.swift (84%) diff --git a/Package.swift b/Package.swift index 72d36a1..83cb9d1 100644 --- a/Package.swift +++ b/Package.swift @@ -113,6 +113,7 @@ let package = Package( "OversizeKit", .product(name: "OversizeUI", package: "OversizeUI"), .product(name: "OversizeServices", package: "OversizeServices"), + .product(name: "OversizeNotificationService", package: "OversizeServices"), ] ), .target( diff --git a/Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift b/Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift new file mode 100644 index 0000000..9440ea3 --- /dev/null +++ b/Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift @@ -0,0 +1,75 @@ +// +// Copyright © 2023 Alexander Romanov +// LocalNotificationSetScreenViewModel.swift +// + +import OversizeCore +import OversizeNotificationService +import OversizeServices +import SwiftUI + +@MainActor +class LocalNotificationSetScreenViewModel: ObservableObject { + @Injected(Container.localNotificationService) var localNotificationService: LocalNotificationServiceProtocol + @Published var state = State.initial + + public let id: UUID + private let date: Date + private let title: String + private let body: String + private let userInfo: [AnyHashable: Any]? + + init( + id: UUID, + date: Date, + title: String, + body: String, + userInfo: [AnyHashable: Any]? = nil + ) { + self.id = id + self.date = date + self.title = title + self.body = body + self.userInfo = userInfo + } + + func setNotification(timeBefore: LocalNotificationTime) async { + let notificationTime = date.addingTimeInterval(timeBefore.timeInterval) + let dateComponents = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute], from: notificationTime) + await localNotificationService.schedule(localNotification: .init( + id: id, + title: title, + body: body, + dateComponents: dateComponents, + repeats: false, + userInfo: userInfo + )) + } + + func fetchPandingNotification() async -> Bool { + let ids = await localNotificationService.fetchPendingIds() + return ids.contains(id.uuidString) + } + + func deleteNotification() { + localNotificationService.removeRequest(withIdentifier: id.uuidString) + } + + func requestAccsess() async { + let result = await localNotificationService.requestAccess() + switch result { + case .success: + state = .result + case let .failure(error): + state = .error(error) + } + } +} + +extension LocalNotificationSetScreenViewModel { + enum State { + case initial + case result + case error(AppError) + } +} diff --git a/Sources/OversizeNotificationKit/LocalNotificationView.swift b/Sources/OversizeNotificationKit/LocalNotificationView.swift new file mode 100644 index 0000000..b9a7fb0 --- /dev/null +++ b/Sources/OversizeNotificationKit/LocalNotificationView.swift @@ -0,0 +1,114 @@ +// +// Copyright © 2023 Alexander Romanov +// LocalNotificationView.swift +// + +import OversizeKit +import OversizeNotificationService +import OversizeUI +import SwiftUI +import UserNotifications + +public struct LocalNotificationView: View { + @Environment(\.dismiss) var dismiss + @Binding private var selection: LocalNotificationTime + @State private var isPendingNotification: Bool = false + @StateObject var viewModel: LocalNotificationSetScreenViewModel + private let saveAction: ((UUID?) -> Void)? + + public init( + _ selection: Binding, + id: UUID, + title: String, + body: String, + date: Date, + userInfo: [AnyHashable: Any]? = nil, + saveAction: ((UUID?) -> Void)? = nil + ) { + _viewModel = StateObject(wrappedValue: LocalNotificationSetScreenViewModel( + id: id, + date: date, + title: title, + body: body, + userInfo: userInfo + )) + _selection = selection + self.saveAction = saveAction + } + + public var body: some View { + switch viewModel.state { + case .initial: + contnent + .task { + await viewModel.requestAccsess() + } + case .result: + contnent + .task { + let pendingStatus = await viewModel.fetchPandingNotification() + if pendingStatus { + isPendingNotification = true + } + } + case let .error(error): + PageView("Notification") { + ErrorView(error) + } + .leadingBar { + BarButton(.close) + } + } + } + + public var contnent: some View { + // let notificationDate = viewModel.date.addingTimeInterval(selection.timeInterval) + PageView("Notification") { + VStack(spacing: .zero) { + SectionView { + LazyVStack(spacing: .zero) { + ForEach(LocalNotificationTime.allCases) { notificationTime in +// let notificationDate = viewModel.date.addingTimeInterval(notificationTime.timeInterval) +// if notificationDate viewModel.date { + Radio(notificationTime.title, isOn: selection.id == notificationTime.id) { + selection = notificationTime + } + // } + } + } + } + .surfaceContentRowInsets() + if isPendingNotification { + SectionView { + VStack(spacing: .zero) { + Row("Delete notification") { + viewModel.deleteNotification() + saveAction?(nil) + isPendingNotification = false + dismiss() + } trailing: { + Icon(.trash) + .iconColor(Color.error) + } + } + } + .surfaceContentRowInsets() + } + } + } + .backgroundSecondary() + .leadingBar { + BarButton(.close) + } + .trailingBar { + BarButton(.accent("Done", action: { + Task { + await viewModel.setNotification(timeBefore: selection) + saveAction?(viewModel.id) + isPendingNotification = true + dismiss() + } + })) + } + } +} diff --git a/Sources/OversizeNotificationKit/LocalNotificationAlertsTimes.swift b/Sources/OversizeNotificationKit/Model/LocalNotificationAlertsTimes.swift similarity index 84% rename from Sources/OversizeNotificationKit/LocalNotificationAlertsTimes.swift rename to Sources/OversizeNotificationKit/Model/LocalNotificationAlertsTimes.swift index b80cd26..2c45852 100644 --- a/Sources/OversizeNotificationKit/LocalNotificationAlertsTimes.swift +++ b/Sources/OversizeNotificationKit/Model/LocalNotificationAlertsTimes.swift @@ -6,7 +6,7 @@ import EventKit import Foundation -public enum LocalNotificationAlertsTimes: CaseIterable, Equatable, Identifiable { +public enum LocalNotificationTime: CaseIterable, Equatable, Identifiable { case oneMinuteBefore, fiveMinutesBefore, tenMinutesBefore, thirtyMinutesBefore, oneHourBefore, twoHoursBefore, oneDayBefore, twoDaysBefore, oneWeekBefore public var title: String { @@ -59,5 +59,5 @@ public enum LocalNotificationAlertsTimes: CaseIterable, Equatable, Identifiable title } - public static var allCases: [LocalNotificationAlertsTimes] = [.oneMinuteBefore, .fiveMinutesBefore, .tenMinutesBefore, .thirtyMinutesBefore, .oneHourBefore, .twoHoursBefore, .oneDayBefore, .twoDaysBefore, .oneWeekBefore] + public static var allCases: [LocalNotificationTime] = [.oneMinuteBefore, .fiveMinutesBefore, .tenMinutesBefore, .thirtyMinutesBefore, .oneHourBefore, .twoHoursBefore, .oneDayBefore, .twoDaysBefore, .oneWeekBefore] } diff --git a/Sources/OversizeNotificationKit/NotificationSetScreen.swift b/Sources/OversizeNotificationKit/NotificationSetScreen.swift index d8fb24d..afa386e 100644 --- a/Sources/OversizeNotificationKit/NotificationSetScreen.swift +++ b/Sources/OversizeNotificationKit/NotificationSetScreen.swift @@ -3,102 +3,58 @@ // NotificationSetScreen.swift // -import EventKit -import OversizeUI -import UserNotifications - -import SwiftUI - -public struct LocalNotificationSetScreen: View { - @Environment(\.dismiss) var dismiss - // @Binding private var selection: [LocalNotificationAlertsTimes] - // @State private var selectedAlerts: [LocalNotificationAlertsTimes] = [] - - public init( /* selection: Binding<[LocalNotificationAlertsTimes]> */ ) { - // _selection = selection - // _selectedAlerts = State(wrappedValue: selection.wrappedValue) - } - - public var body: some View { - PageView("Alarm") { - SectionView { - VStack(spacing: .zero) { - Button("Schedule Notification") {} - .buttonStyle(.borderedProminent) - } - } - .surfaceContentRowInsets() - } - .backgroundSecondary() - .leadingBar { - BarButton(.close) - } - // .trailingBar { - // if selectedAlerts.isEmpty { - // BarButton(.disabled("Done")) - // } else { - // BarButton(.accent("Done", action: { - // selection = selectedAlerts - // dismiss() - // })) - // } - // } - } - - func set2() { - let content = UNMutableNotificationContent() - content.title = "task.name" - content.body = "Gentle reminder for your task!" - - // 3 - var trigger: UNNotificationTrigger? - - trigger = UNTimeIntervalNotificationTrigger( - timeInterval: 4, repeats: false - ) - - // 4 - if let trigger { - let request = UNNotificationRequest( - identifier: UUID().uuidString, - content: content, - trigger: trigger - ) - // 5 - UNUserNotificationCenter.current().add(request) { error in - if let error { - print(error) - } - } - } - // - } - - func setAlert() { - UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in - print(success ? "Authorization success" : "Authorization failed") - print(error?.localizedDescription ?? "") - } - - let content = UNMutableNotificationContent() - content.title = "Hey DevTechie!" - content.subtitle = "Check out DevTechie.com" - content.body = "We have video courses!!!" - content.sound = UNNotificationSound.default - let imageName = "DT" - if let imageURL = Bundle.main.url(forResource: imageName, withExtension: "png") { - let attachment = try! UNNotificationAttachment(identifier: imageName, url: imageURL, options: .none) - - content.attachments = [attachment] - } - - let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false) - let request = UNNotificationRequest(identifier: "com.devtechie.notification", content: content, trigger: trigger) - - UNUserNotificationCenter.current().add(request) { error in - if let error { - print(error) - } - } - } -} +/* + import OversizeUI + import UserNotifications + import OversizeNotificationService + import SwiftUI + + public struct LocalNotificationSetScreen: View { + + @Environment(\.dismiss) var dismiss + @StateObject var viewModel: LocalNotificationSetScreenViewModel + @Binding private var selection: [LocalNotificationAlertsTimes] + @State private var selectedAlerts: [LocalNotificationAlertsTimes] = [] + private let notification: LocalNotification + + public init(selection: Binding<[LocalNotificationAlertsTimes]>, notification: LocalNotification) { + _selection = selection + _selectedAlerts = State(wrappedValue: selection.wrappedValue) + _viewModel = StateObject(wrappedValue: LocalNotificationSetScreenViewModel()) + self.notification = notification + } + + public var body: some View { + PageView("Alarm") { + SectionView { + VStack(spacing: .zero) { + ForEach(LocalNotificationAlertsTimes.allCases) { alert in + Checkbox(alert.title, isOn: .constant((selectedAlerts.first { $0.id == alert.id } != nil) ? true : false)) { + if !selectedAlerts.isEmpty, let index = selectedAlerts.firstIndex(where: { $0.id == alert.id }) { + selectedAlerts.remove(at: index) + } else { + selectedAlerts.append(alert) + } + } + } + } + } + .surfaceContentRowInsets() + } + .backgroundSecondary() + .leadingBar { + BarButton(.close) + } + .trailingBar { + if selectedAlerts.isEmpty { + BarButton(.disabled("Done")) + } else { + BarButton(.accent("Done", action: { + selection = selectedAlerts + dismiss() + })) + } + } + } + } + */ From 3ee8953ffb1392ff185cbcd447c2ec56e83f135f Mon Sep 17 00:00:00 2001 From: Alexander Romanov Date: Thu, 30 Mar 2023 19:47:24 +0300 Subject: [PATCH 2/6] Update MapView --- .../CreateEventScreen/CreateEventView.swift | 2 +- .../StoreScreen/StoreInstuctinsView.swift | 3 - .../SystemKit/SystemServices.swift | 15 +- .../MapCoordinateView/MapCoordinateView.swift | 157 ++++++++++++++++++ .../MapCoordinateViewModel.swift | 65 ++++++++ .../OversizePhotoKit/PhotoViewerView.swift | 48 ++++++ .../OversizePhotoKit/PhotosGalleryView.swift | 4 +- 7 files changed, 279 insertions(+), 15 deletions(-) create mode 100644 Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateView.swift create mode 100644 Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateViewModel.swift create mode 100644 Sources/OversizePhotoKit/PhotoViewerView.swift diff --git a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift index 14583d9..157b01f 100644 --- a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift +++ b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift @@ -294,7 +294,7 @@ public struct CreateEventView: View { if let location = viewModel.location { let region = MKCoordinateRegion(center: location, latitudinalMeters: 10000, longitudinalMeters: 10000) - let annotations = [MapPoint(name: "\(viewModel.locationName ?? "")", coordinate: location)] + let annotations = [MapPreviewPoint(name: "\(viewModel.locationName ?? "")", coordinate: location)] Map(coordinateRegion: .constant(region), annotationItems: annotations) { MapMarker(coordinate: $0.coordinate) } diff --git a/Sources/OversizeKit/StoreKit/StoreScreen/StoreInstuctinsView.swift b/Sources/OversizeKit/StoreKit/StoreScreen/StoreInstuctinsView.swift index 1b95429..9e6c41b 100644 --- a/Sources/OversizeKit/StoreKit/StoreScreen/StoreInstuctinsView.swift +++ b/Sources/OversizeKit/StoreKit/StoreScreen/StoreInstuctinsView.swift @@ -180,16 +180,13 @@ public struct StoreInstuctinsView: View { SubscriptionPrivacyView(products: data) } .padding(.bottom, 220) - .onAppear { Task { - // When this view appears, get the latest subscription status. await viewModel.updateSubscriptionStatus(products: data) } } .onChange(of: data.purchasedAutoRenewable) { _ in Task { - // When `purchasedSubscriptions` changes, get the latest subscription status. await viewModel.updateSubscriptionStatus(products: data) } } diff --git a/Sources/OversizeKit/SystemKit/SystemServices.swift b/Sources/OversizeKit/SystemKit/SystemServices.swift index a2eca4d..9121210 100644 --- a/Sources/OversizeKit/SystemKit/SystemServices.swift +++ b/Sources/OversizeKit/SystemKit/SystemServices.swift @@ -5,20 +5,18 @@ import OversizeCore import OversizeLocalizable - import OversizeServices - +import OversizeStoreService import OversizeUI import SwiftUI public struct SystemServicesModifier: ViewModifier { - @Environment(\.scenePhase) var scenePhase - @Environment(\.theme) var theme - - @Injected(Container.appStateService) var appState - @Injected(Container.settingsService) var settingsService - @Injected(Container.appStoreReviewService) var appStoreReviewService + @Injected(Container.appStateService) var appState: AppStateService + @Injected(Container.settingsService) var settingsService: SettingsServiceProtocol + @Injected(Container.appStoreReviewService) var appStoreReviewService: AppStoreReviewServiceProtocol + @Environment(\.scenePhase) var scenePhase: ScenePhase + @Environment(\.theme) var theme: ThemeSettings @AppStorage("AppState.PremiumState") var isPremium: Bool = false @StateObject var hudState = HUD() @@ -71,7 +69,6 @@ public struct SystemServicesModifier: ViewModifier { .premiumStatus(isPremium) .theme(ThemeSettings()) .screenSize(geometry) - // overlays .hud(isPresented: $hudState.isPresented, type: $hudState.type) { HUDContent(title: hudState.title, image: hudState.image, type: hudState.type) } diff --git a/Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateView.swift b/Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateView.swift new file mode 100644 index 0000000..1368841 --- /dev/null +++ b/Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateView.swift @@ -0,0 +1,157 @@ +// +// Copyright © 2023 Alexander Romanov +// MapCoordinateView.swift +// + +import MapKit +import OversizeResources +import OversizeUI +import SwiftUI + +public struct MapCoordinateView: View { + @Environment(\.screenSize) var screenSize + @Environment(\.openURL) var openURL + @StateObject var viewModel: MapCoordinateViewModel + + public init(_ location: CLLocationCoordinate2D, annotation: String? = nil) { + _viewModel = StateObject(wrappedValue: MapCoordinateViewModel(location: location, annotation: annotation)) + } + + public var body: some View { + VStack(spacing: 0) { + if #available(iOS 16.0, *) { + mapView + .ignoresSafeArea() + .safeAreaInset(edge: .top) { + ModalNavigationBar(title: viewModel.annotation ?? "", largeTitle: false, leadingBar: { + BarButton(.back) + }, trailingBar: { + BarButton(.icon(.map, action: { + viewModel.isShowRoutePickerSheet.toggle() + })) + }) + .background(.thickMaterial, ignoresSafeAreaEdges: .top) + } + .toolbar(.hidden, for: .tabBar) + } else { + mapView + .safeAreaInset(edge: .top) { + ModalNavigationBar(title: viewModel.annotation ?? "", largeTitle: false, leadingBar: { + BarButton(.back) + }, trailingBar: { + BarButton(.icon(.map, action: { + viewModel.isShowRoutePickerSheet.toggle() + })) + }) + } + } + } + .sheet(isPresented: $viewModel.isShowRoutePickerSheet) { + routeSheetView + .presentationDetents([.height(260)]) + } + } + + var mapView: some View { + ZStack(alignment: .trailing) { + Map(coordinateRegion: region, showsUserLocation: true, userTrackingMode: $viewModel.userTrackingMode, annotationItems: viewModel.annotations) { + MapMarker(coordinate: $0.coordinate) + } + controlButtons + } + } + + private var region: Binding { + Binding { + viewModel.region + } set: { region in + DispatchQueue.main.async { + viewModel.region = region + } + } + } + + var controlButtons: some View { + VStack { + Spacer() + VStack(spacing: .zero) { + Button { + viewModel.zoomIn() + } label: { + Icon(.plus) + .onSurfaceMediumEmphasisForegroundColor() + .padding(.xxSmall) + } + + Button { + viewModel.zoomOut() + } label: { + Icon(.minus) + .onSurfaceMediumEmphasisForegroundColor() + .padding(.xxSmall) + } + } + .background { + Capsule() + .fillSurfacePrimary() + .shadowElevaton(.z1) + } + Spacer() + } + .overlay(alignment: .bottomTrailing, content: { + Button { + viewModel.positionInLocation() + + } label: { + Icon(.navigation) + .onSurfaceMediumEmphasisForegroundColor() + .padding(.xxSmall) + } + .background { + Capsule() + .fillSurfacePrimary() + .shadowElevaton(.z1) + } + }) + .padding(.trailing, 16) + .padding(.bottom, screenSize.safeAreaBottom) + } + + var routeSheetView: some View { + PageView("Route") { + SectionView { + Row("Apple Maps") { + onTapAppleMaps() + } + Row("Google Maps") { + onTapGoogleMaps() + } + } + } + .leadingBar(leadingBar: { + BarButton(.close) + }) + .backgroundSecondary() + .disableScrollShadow(true) + .surfaceContentRowInsets() + } + + func onTapAppleMaps() { + let placemark = MKPlacemark(coordinate: viewModel.location, addressDictionary: nil) + let mapItem = MKMapItem(placemark: placemark) + mapItem.name = viewModel.annotation + mapItem.openInMaps() + viewModel.isShowRoutePickerSheet.toggle() + } + + func onTapGoogleMaps() { + guard let url = URL(string: "comgooglemaps://?saddr=\(viewModel.location.latitude),\(viewModel.location.longitude)") else { return } + openURL(url) + } +} + +struct MapCoordinateView_Previews: PreviewProvider { + static var previews: some View { + MapCoordinateView(.init(latitude: 100, longitude: 100)) + } +} diff --git a/Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateViewModel.swift b/Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateViewModel.swift new file mode 100644 index 0000000..2b4a6a0 --- /dev/null +++ b/Sources/OversizeLocationKit/MapCoordinateView/MapCoordinateViewModel.swift @@ -0,0 +1,65 @@ +// +// Copyright © 2023 Alexander Romanov +// MapCoordinateViewModel.swift +// + +import MapKit +import OversizeLocationService +import SwiftUI + +@MainActor +public final class MapCoordinateViewModel: ObservableObject { + @Published public var region: MKCoordinateRegion + @Published public var userTrackingMode: MapUserTrackingMode = .follow + @Published public var isShowRoutePickerSheet: Bool = false + + public let location: CLLocationCoordinate2D + public let annotation: String? + public let annotations: [MapPoint] + + public init(location: CLLocationCoordinate2D, annotation: String?) { + self.location = location + self.annotation = annotation + annotations = [MapPoint(name: annotation.valueOrEmpty, coordinate: location)] + region = MKCoordinateRegion( + center: location, + span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01) + ) + } + + public func zoomIn() { + if region.span.longitudeDelta / 2.5 > 0, region.span.latitudeDelta / 2.5 > 0 { + withAnimation { + region.span.latitudeDelta /= 2.5 + region.span.longitudeDelta /= 2.5 + } + } else { + withAnimation { + region.span.latitudeDelta = 0.00033266201122472694 + region.span.longitudeDelta = 0.00059856596270435602 + } + } + } + + public func zoomOut() { + if region.span.longitudeDelta * 2.5 < 134, region.span.latitudeDelta * 2.5 < 130 { + withAnimation { + region.span.latitudeDelta *= 2.5 + region.span.longitudeDelta *= 2.5 + } + } else { + withAnimation { + region.span.latitudeDelta = 130 + region.span.longitudeDelta = 130 + } + } + } + + public func positionInLocation() { + withAnimation { + region.center = location + region.span.latitudeDelta = 0.1 + region.span.longitudeDelta = 0.1 + } + } +} diff --git a/Sources/OversizePhotoKit/PhotoViewerView.swift b/Sources/OversizePhotoKit/PhotoViewerView.swift new file mode 100644 index 0000000..1c1f223 --- /dev/null +++ b/Sources/OversizePhotoKit/PhotoViewerView.swift @@ -0,0 +1,48 @@ +// +// Copyright © 2023 Alexander Romanov +// PhotoViewerView.swift +// + +import SwiftUI + +import OversizePhotoComponents +import OversizeUI +import SwiftUI + +public struct PhotoViewerView: View { + private let title: String + private let images: [Image] + @State private var isShowPhoto: Bool = false + @Binding private var selection: Int + + public init(_ title: String = "Photos", selection: Binding, images: [Image]) { + self.title = title + self.images = images + _selection = selection + } + + public var body: some View { +// PageView(title) { + VStack(spacing: 0) { +// ModalNavigationBar(title: title) { +// BarButton(.back) +// } + if images.isEmpty { + Text("Not photos") + .title3() + .onSurfaceHighEmphasisForegroundColor() + } else { + PhotoSliderView(selection: $selection, photos: images) + } + } +// .leadingBar { +// BarButton(.back) +// } + } +} + +// struct SwiftUIView_Previews: PreviewProvider { +// static var previews: some View { +// SwiftUIView() +// } +// } diff --git a/Sources/OversizePhotoKit/PhotosGalleryView.swift b/Sources/OversizePhotoKit/PhotosGalleryView.swift index a00ebc6..47a1dd2 100644 --- a/Sources/OversizePhotoKit/PhotosGalleryView.swift +++ b/Sources/OversizePhotoKit/PhotosGalleryView.swift @@ -39,8 +39,8 @@ public struct PhotosGalleryView: View { } } - struct PhotosGalleryView_Previews: PreviewProvider { +struct PhotosGalleryView_Previews: PreviewProvider { static var previews: some View { PhotosGalleryView(images: []) } - } +} From 6629f9353914ccb00dd2cb9a506955cb3a63ba09 Mon Sep 17 00:00:00 2001 From: Alexander Romanov Date: Thu, 30 Mar 2023 19:48:18 +0300 Subject: [PATCH 3/6] Update Notoifications access error --- .../OversizeKit/SystemKit/ErrorView/ErrorView.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift b/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift index 583024d..10f4616 100644 --- a/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift +++ b/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift @@ -98,6 +98,16 @@ public struct ErrorView: View { } else { return nil } + case let .notifications(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 + } } } } From 278487a39c638e0017bb0107bef32e830b296f50 Mon Sep 17 00:00:00 2001 From: Alexander Romanov Date: Sun, 9 Apr 2023 17:12:01 +0300 Subject: [PATCH 4/6] Add calendar components --- Package.swift | 2 +- .../CreateEventScreen/CreateEventView.swift | 4 ++-- .../ContactsLists/ContactsListsView.swift | 3 ++- .../ContactsPicker/EmailPickerView.swift | 6 ++++-- Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift | 2 +- Sources/OversizeKit/SystemKit/SystemServices.swift | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Package.swift b/Package.swift index 83cb9d1..e50173d 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.7 +// swift-tools-version: 5.8 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription diff --git a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift index 157b01f..f68aa44 100644 --- a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift +++ b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift @@ -240,10 +240,10 @@ public struct CreateEventView: View { @ViewBuilder var alarmView: some View { Group { - if let alarms = viewModel.alarms, !alarms.isEmpty { + if !viewModel.alarms.isEmpty { Surface { VStack(spacing: .zero) { - ForEach(alarms) { alarm in + ForEach(viewModel.alarms) { alarm in Row(alarm.title) { viewModel.present(.alarm) } leading: { diff --git a/Sources/OversizeContactsKit/ContactsLists/ContactsListsView.swift b/Sources/OversizeContactsKit/ContactsLists/ContactsListsView.swift index fc81abe..051dd99 100644 --- a/Sources/OversizeContactsKit/ContactsLists/ContactsListsView.swift +++ b/Sources/OversizeContactsKit/ContactsLists/ContactsListsView.swift @@ -49,7 +49,8 @@ public struct ContactsListsView: View { private func content(data: [CNContact]) -> some View { ForEach(emails, id: \.self) { email in if let contact = viewModel.getContactFromEmail(email: email, contacts: data) { - if let emails = contact.emailAddresses, !emails.isEmpty { + let emails = contact.emailAddresses + if !emails.isEmpty { ForEach(emails, id: \.identifier) { email in emailRow(email: email, contact: contact) } diff --git a/Sources/OversizeContactsKit/ContactsPicker/EmailPickerView.swift b/Sources/OversizeContactsKit/ContactsPicker/EmailPickerView.swift index e78c6b1..59e4d9b 100644 --- a/Sources/OversizeContactsKit/ContactsPicker/EmailPickerView.swift +++ b/Sources/OversizeContactsKit/ContactsPicker/EmailPickerView.swift @@ -98,7 +98,8 @@ public struct EmailPickerView: View { ForEach(viewModel.lastSelectedEmails, id: \.self) { email in if let contact = viewModel.getContactFromEmail(email: email, contacts: data) { - if let emails = contact.emailAddresses, !emails.isEmpty { + let emails = contact.emailAddresses + if !emails.isEmpty { ForEach(emails, id: \.identifier) { email in emailRow(email: email, contact: contact) } @@ -129,7 +130,8 @@ public struct EmailPickerView: View { .padding(.top, viewModel.lastSelectedEmails.isEmpty ? .zero : .small) ForEach(data, id: \.identifier) { contact in - if let emails = contact.emailAddresses, !emails.isEmpty { + let emails = contact.emailAddresses + if !emails.isEmpty { ForEach(emails, id: \.identifier) { email in emailRow(email: email, contact: contact) } diff --git a/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift b/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift index 10f4616..96dd8e0 100644 --- a/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift +++ b/Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift @@ -1,5 +1,5 @@ // -// Copyright © 2022 Alexander Romanov +// Copyright © 2023 Alexander Romanov // ErrorView.swift // diff --git a/Sources/OversizeKit/SystemKit/SystemServices.swift b/Sources/OversizeKit/SystemKit/SystemServices.swift index 9121210..d884e91 100644 --- a/Sources/OversizeKit/SystemKit/SystemServices.swift +++ b/Sources/OversizeKit/SystemKit/SystemServices.swift @@ -1,5 +1,5 @@ // -// Copyright © 2022 Alexander Romanov +// Copyright © 2023 Alexander Romanov // SystemServices.swift // From e62d4a83942708b6eb940bad06736e736c592e34 Mon Sep 17 00:00:00 2001 From: Alexander Romanov Date: Mon, 10 Apr 2023 18:29:01 +0300 Subject: [PATCH 5/6] Clean code --- Package.swift | 8 +++ .../CreateEventViewModel.swift | 5 +- .../AttendeesList/AttendeesViewModel.swift | 3 +- .../ContactsListsViewModel.swift | 3 +- .../ContactsPicker/EmailPickerViewModel.swift | 3 +- .../LauncherKit/LauncherViewModel.swift | 11 ++-- .../LauncherKit/RateAppScreen.swift | 4 +- .../PINCode/SetPINCodeViewModel.swift | 2 - .../Views/Security/SecuritySettingsView.swift | 4 +- .../SettingsKit/Views/SettingsView.swift | 1 - .../SoundsAndVibrationsSettingsView.swift | 1 - .../ViewModel/StoreViewModel.swift | 3 +- .../StoreKit/Views/StoreProductView.swift | 3 +- .../Views/SubscriptionPrivacyView.swift | 2 - .../SystemKit/SystemServices.swift | 7 ++- .../AddressPickerViewModel.swift | 3 +- .../OversizeNoticeKit/NoticeListView.swift | 3 +- .../LocalNotificationSetScreenViewModel.swift | 3 +- .../NotificationSetScreen.swift | 60 ------------------- 19 files changed, 41 insertions(+), 88 deletions(-) delete mode 100644 Sources/OversizeNotificationKit/NotificationSetScreen.swift diff --git a/Package.swift b/Package.swift index e50173d..7708eff 100644 --- a/Package.swift +++ b/Package.swift @@ -10,6 +10,7 @@ let productionDependencies: [PackageDescription.Package.Dependency] = { [ .package(url: "https://github.com/oversizedev/OversizeCore.git", branch: "main"), .package(url: "https://github.com/oversizedev/OversizeComponents.git", branch: "main"), .package(url: "https://github.com/oversizedev/OversizeResources.git", branch: "main"), + .package(url: "https://github.com/hmlongco/Factory.git", .upToNextMajor(from: "2.1.3")) ] }() let developmentDependencies: [PackageDescription.Package.Dependency] = { [ @@ -19,6 +20,7 @@ let developmentDependencies: [PackageDescription.Package.Dependency] = { [ .package(name: "OversizeCore", path: "../OversizeCore"), .package(name: "OversizeComponents", path: "../OversizeComponents"), .package(name: "OversizeResources", path: "../OversizeResources"), + .package(url: "https://github.com/hmlongco/Factory.git", .upToNextMajor(from: "2.1.3")) ] }() let package = Package( @@ -52,6 +54,7 @@ let package = Package( .product(name: "OversizeComponents", package: "OversizeComponents"), .product(name: "OversizeLocalizable", package: "OversizeLocalizable"), .product(name: "OversizeResources", package: "OversizeResources"), + .product(name: "Factory", package: "Factory") ] ), .target( @@ -71,6 +74,7 @@ let package = Package( .product(name: "OversizeServices", package: "OversizeServices"), .product(name: "OversizeCalendarService", package: "OversizeServices"), .product(name: "OversizeLocationService", package: "OversizeServices"), + .product(name: "Factory", package: "Factory") ] ), .target( @@ -81,6 +85,7 @@ let package = Package( .product(name: "OversizeServices", package: "OversizeServices"), .product(name: "OversizeContactsService", package: "OversizeServices"), .product(name: "OversizeCalendarService", package: "OversizeServices"), + .product(name: "Factory", package: "Factory") ] ), .target( @@ -89,6 +94,7 @@ let package = Package( .product(name: "OversizeUI", package: "OversizeUI"), .product(name: "OversizeServices", package: "OversizeServices"), .product(name: "OversizeLocationService", package: "OversizeServices"), + .product(name: "Factory", package: "Factory") ] ), .target( @@ -99,6 +105,7 @@ let package = Package( .product(name: "OversizeUI", package: "OversizeUI"), .product(name: "OversizeServices", package: "OversizeServices"), .product(name: "OversizeStoreService", package: "OversizeServices"), + .product(name: "Factory", package: "Factory") ] ), .target( @@ -114,6 +121,7 @@ let package = Package( .product(name: "OversizeUI", package: "OversizeUI"), .product(name: "OversizeServices", package: "OversizeServices"), .product(name: "OversizeNotificationService", package: "OversizeServices"), + .product(name: "Factory", package: "Factory") ] ), .target( diff --git a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift index 5947764..27774fd 100644 --- a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift +++ b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift @@ -9,6 +9,7 @@ import OversizeCore import OversizeLocationService import OversizeServices import SwiftUI +import Factory public enum CreateEventType: Equatable { case new(Date?, calendar: EKCalendar?) @@ -17,8 +18,8 @@ public enum CreateEventType: Equatable { @MainActor public class CreateEventViewModel: ObservableObject { - @Injected(Container.calendarService) private var calendarService: CalendarService - @Injected(Container.locationService) private var locationService: LocationServiceProtocol + @Injected(\.calendarService) private var calendarService: CalendarService + @Injected(\.locationService) private var locationService: LocationServiceProtocol @Published var state = CreateEventViewModelState.initial @Published var sheet: CreateEventViewModel.Sheet? = nil diff --git a/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift b/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift index 555070c..c39641e 100644 --- a/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift +++ b/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift @@ -9,10 +9,11 @@ import OversizeContactsService import OversizeCore import OversizeServices import SwiftUI +import Factory @MainActor class AttendeesViewModel: ObservableObject { - @Injected(Container.contactsService) private var contactsService: ContactsService + @Injected(\.contactsService) private var contactsService: ContactsService @Published var state = AttendeesViewModelState.initial @Published var searchText: String = .init() diff --git a/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift b/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift index efb0a02..6d62691 100644 --- a/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift +++ b/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift @@ -8,10 +8,11 @@ import OversizeContactsService import OversizeCore import OversizeServices import SwiftUI +import Factory @MainActor public class ContactsListsViewModel: ObservableObject { - @Injected(Container.contactsService) private var contactsService: ContactsService + @Injected(\.contactsService) private var contactsService: ContactsService @Published var state = ContactsPickerViewModelState.initial @Published var searchText: String = .init() diff --git a/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift b/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift index ff61a92..31892c1 100644 --- a/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift +++ b/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift @@ -8,10 +8,11 @@ import OversizeContactsService import OversizeCore import OversizeServices import SwiftUI +import Factory @MainActor class EmailPickerViewModel: ObservableObject { - @Injected(Container.contactsService) private var contactsService: ContactsService + @Injected(\.contactsService) private var contactsService: ContactsService @Published var state = ContactsPickerViewModelState.initial @Published var searchText: String = .init() diff --git a/Sources/OversizeKit/LauncherKit/LauncherViewModel.swift b/Sources/OversizeKit/LauncherKit/LauncherViewModel.swift index 0df2434..5a1f715 100644 --- a/Sources/OversizeKit/LauncherKit/LauncherViewModel.swift +++ b/Sources/OversizeKit/LauncherKit/LauncherViewModel.swift @@ -11,14 +11,15 @@ import SwiftUI #if canImport(LocalAuthentication) import LocalAuthentication #endif +import Factory @MainActor public final class LauncherViewModel: ObservableObject { - @Injected(Container.biometricService) var biometricService - @Injected(Container.appStateService) var appStateService: AppStateService - @Injected(Container.settingsService) var settingsService - @Injected(Container.appStoreReviewService) var reviewService: AppStoreReviewServiceProtocol - @Injected(Container.storeKitService) private var storeKitService: StoreKitService + @Injected(\.biometricService) var biometricService + @Injected(\.appStateService) var appStateService: AppStateService + @Injected(\.settingsService) var settingsService + @Injected(\.appStoreReviewService) var reviewService: AppStoreReviewServiceProtocol + @Injected(\.storeKitService) private var storeKitService: StoreKitService @AppStorage("AppState.PremiumState") var isPremium: Bool = false @AppStorage("AppState.SubscriptionsState") var subscriptionsState: RenewalState = .expired diff --git a/Sources/OversizeKit/LauncherKit/RateAppScreen.swift b/Sources/OversizeKit/LauncherKit/RateAppScreen.swift index 8370d57..3c0b699 100644 --- a/Sources/OversizeKit/LauncherKit/RateAppScreen.swift +++ b/Sources/OversizeKit/LauncherKit/RateAppScreen.swift @@ -5,12 +5,12 @@ import OversizeResources import OversizeServices - +import Factory import OversizeUI import SwiftUI struct RateAppScreen: View { - @Injected(Container.appStoreReviewService) var reviewService + @Injected(\.appStoreReviewService) var reviewService @Environment(\.dismiss) var dismiss var body: some View { diff --git a/Sources/OversizeKit/SettingsKit/Views/Security/PINCode/SetPINCodeViewModel.swift b/Sources/OversizeKit/SettingsKit/Views/Security/PINCode/SetPINCodeViewModel.swift index 739bc17..a75ebd3 100644 --- a/Sources/OversizeKit/SettingsKit/Views/Security/PINCode/SetPINCodeViewModel.swift +++ b/Sources/OversizeKit/SettingsKit/Views/Security/PINCode/SetPINCodeViewModel.swift @@ -5,9 +5,7 @@ import OversizeCore import OversizeLocalizable - import OversizeServices - import OversizeUI import SwiftUI diff --git a/Sources/OversizeKit/SettingsKit/Views/Security/SecuritySettingsView.swift b/Sources/OversizeKit/SettingsKit/Views/Security/SecuritySettingsView.swift index b7039fc..3d5c1e6 100644 --- a/Sources/OversizeKit/SettingsKit/Views/Security/SecuritySettingsView.swift +++ b/Sources/OversizeKit/SettingsKit/Views/Security/SecuritySettingsView.swift @@ -5,14 +5,14 @@ import OversizeLocalizable import OversizeServices - import OversizeUI import SwiftUI +import Factory // swiftlint:disable line_length #if os(iOS) public struct SecuritySettingsView: View { - @Injected(Container.biometricService) var biometricService + @Injected(\.biometricService) var biometricService @Environment(\.verticalSizeClass) private var verticalSizeClass @Environment(\.isPortrait) var isPortrait @Environment(\.presentationMode) var presentationMode diff --git a/Sources/OversizeKit/SettingsKit/Views/SettingsView.swift b/Sources/OversizeKit/SettingsKit/Views/SettingsView.swift index 700a660..e913598 100644 --- a/Sources/OversizeKit/SettingsKit/Views/SettingsView.swift +++ b/Sources/OversizeKit/SettingsKit/Views/SettingsView.swift @@ -6,7 +6,6 @@ import OversizeLocalizable import OversizeResources import OversizeServices - import OversizeUI import SwiftUI diff --git a/Sources/OversizeKit/SettingsKit/Views/SoundAndVibration/SoundsAndVibrationsSettingsView.swift b/Sources/OversizeKit/SettingsKit/Views/SoundAndVibration/SoundsAndVibrationsSettingsView.swift index 166a704..eb841c7 100644 --- a/Sources/OversizeKit/SettingsKit/Views/SoundAndVibration/SoundsAndVibrationsSettingsView.swift +++ b/Sources/OversizeKit/SettingsKit/Views/SoundAndVibration/SoundsAndVibrationsSettingsView.swift @@ -6,7 +6,6 @@ import OversizeCore import OversizeLocalizable import OversizeServices - import OversizeUI import SwiftUI diff --git a/Sources/OversizeKit/StoreKit/StoreScreen/ViewModel/StoreViewModel.swift b/Sources/OversizeKit/StoreKit/StoreScreen/ViewModel/StoreViewModel.swift index 848480d..a31aef5 100644 --- a/Sources/OversizeKit/StoreKit/StoreScreen/ViewModel/StoreViewModel.swift +++ b/Sources/OversizeKit/StoreKit/StoreScreen/ViewModel/StoreViewModel.swift @@ -9,6 +9,7 @@ import OversizeServices import OversizeStoreService import StoreKit import SwiftUI +import Factory @MainActor class StoreViewModel: ObservableObject { @@ -19,7 +20,7 @@ class StoreViewModel: ObservableObject { case error(AppError) } - @Injected(Container.storeKitService) var storeKitService: StoreKitService + @Injected(\.storeKitService) var storeKitService: StoreKitService @Published var state = State.initial public var updateListenerTask: Task? diff --git a/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift b/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift index fac9083..88b7c9f 100644 --- a/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift +++ b/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift @@ -8,13 +8,14 @@ import OversizeStoreService import OversizeUI import StoreKit import SwiftUI +import Factory public struct StoreProductView: View { public enum StoreProductViewType { case row, collumn } - @Injected(Container.storeKitService) private var store: StoreKitService + @Injected(\.storeKitService) private var store: StoreKitService @State var isPurchased: Bool = false @Binding var isSelected: Bool diff --git a/Sources/OversizeKit/StoreKit/Views/SubscriptionPrivacyView.swift b/Sources/OversizeKit/StoreKit/Views/SubscriptionPrivacyView.swift index 7380ae6..692e91e 100644 --- a/Sources/OversizeKit/StoreKit/Views/SubscriptionPrivacyView.swift +++ b/Sources/OversizeKit/StoreKit/Views/SubscriptionPrivacyView.swift @@ -31,8 +31,6 @@ struct SubscriptionPrivacyView: View { HStack(spacing: .xxSmall) { Button("Restore") { Task { - // This call displays a system prompt that asks users to authenticate with their App Store credentials. - // Call this function only in response to an explicit user action, such as tapping a button. try? await AppStore.sync() } } diff --git a/Sources/OversizeKit/SystemKit/SystemServices.swift b/Sources/OversizeKit/SystemKit/SystemServices.swift index d884e91..781bd93 100644 --- a/Sources/OversizeKit/SystemKit/SystemServices.swift +++ b/Sources/OversizeKit/SystemKit/SystemServices.swift @@ -9,11 +9,12 @@ import OversizeServices import OversizeStoreService import OversizeUI import SwiftUI +import Factory public struct SystemServicesModifier: ViewModifier { - @Injected(Container.appStateService) var appState: AppStateService - @Injected(Container.settingsService) var settingsService: SettingsServiceProtocol - @Injected(Container.appStoreReviewService) var appStoreReviewService: AppStoreReviewServiceProtocol + @Injected(\.appStateService) var appState: AppStateService + @Injected(\.settingsService) var settingsService: SettingsServiceProtocol + @Injected(\.appStoreReviewService) var appStoreReviewService: AppStoreReviewServiceProtocol @Environment(\.scenePhase) var scenePhase: ScenePhase @Environment(\.theme) var theme: ThemeSettings diff --git a/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift b/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift index 1c29a2a..dff7788 100644 --- a/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift +++ b/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift @@ -9,10 +9,11 @@ import MapKit import OversizeLocationService import OversizeServices import SwiftUI +import Factory @MainActor class AddressPickerViewModel: NSObject, ObservableObject { - @Injected(Container.locationService) var locationService: LocationServiceProtocol + @Injected(\.locationService) var locationService: LocationServiceProtocol @Published var locationResults: [MKLocalSearchCompletion] = .init() @Published var searchTerm: String = .init() diff --git a/Sources/OversizeNoticeKit/NoticeListView.swift b/Sources/OversizeNoticeKit/NoticeListView.swift index 4eec60b..527eb98 100644 --- a/Sources/OversizeNoticeKit/NoticeListView.swift +++ b/Sources/OversizeNoticeKit/NoticeListView.swift @@ -9,9 +9,10 @@ import OversizeStoreService import OversizeUI import StoreKit import SwiftUI +import Factory public struct NoticeListView: View { - @Injected(Container.appStoreReviewService) var reviewService + @Injected(\.appStoreReviewService) var reviewService @Environment(\.isPremium) var isPremium: Bool @State private var isBannerClosed = false diff --git a/Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift b/Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift index 9440ea3..00017a9 100644 --- a/Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift +++ b/Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift @@ -7,10 +7,11 @@ import OversizeCore import OversizeNotificationService import OversizeServices import SwiftUI +import Factory @MainActor class LocalNotificationSetScreenViewModel: ObservableObject { - @Injected(Container.localNotificationService) var localNotificationService: LocalNotificationServiceProtocol + @Injected(\.localNotificationService) var localNotificationService: LocalNotificationServiceProtocol @Published var state = State.initial public let id: UUID diff --git a/Sources/OversizeNotificationKit/NotificationSetScreen.swift b/Sources/OversizeNotificationKit/NotificationSetScreen.swift deleted file mode 100644 index afa386e..0000000 --- a/Sources/OversizeNotificationKit/NotificationSetScreen.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// Copyright © 2023 Alexander Romanov -// NotificationSetScreen.swift -// - -/* - import OversizeUI - import UserNotifications - import OversizeNotificationService - import SwiftUI - - public struct LocalNotificationSetScreen: View { - - @Environment(\.dismiss) var dismiss - @StateObject var viewModel: LocalNotificationSetScreenViewModel - @Binding private var selection: [LocalNotificationAlertsTimes] - @State private var selectedAlerts: [LocalNotificationAlertsTimes] = [] - private let notification: LocalNotification - - public init(selection: Binding<[LocalNotificationAlertsTimes]>, notification: LocalNotification) { - _selection = selection - _selectedAlerts = State(wrappedValue: selection.wrappedValue) - _viewModel = StateObject(wrappedValue: LocalNotificationSetScreenViewModel()) - self.notification = notification - } - - public var body: some View { - PageView("Alarm") { - SectionView { - VStack(spacing: .zero) { - ForEach(LocalNotificationAlertsTimes.allCases) { alert in - Checkbox(alert.title, isOn: .constant((selectedAlerts.first { $0.id == alert.id } != nil) ? true : false)) { - if !selectedAlerts.isEmpty, let index = selectedAlerts.firstIndex(where: { $0.id == alert.id }) { - selectedAlerts.remove(at: index) - } else { - selectedAlerts.append(alert) - } - } - } - } - } - .surfaceContentRowInsets() - } - .backgroundSecondary() - .leadingBar { - BarButton(.close) - } - .trailingBar { - if selectedAlerts.isEmpty { - BarButton(.disabled("Done")) - } else { - BarButton(.accent("Done", action: { - selection = selectedAlerts - dismiss() - })) - } - } - } - } - */ From 2c95bf6445a8fd35cf1b61dc794965d656fcd936 Mon Sep 17 00:00:00 2001 From: Alexander Romanov Date: Fri, 14 Apr 2023 00:25:44 +0300 Subject: [PATCH 6/6] Add dependency versions --- Package.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Package.swift b/Package.swift index 7708eff..d257cb5 100644 --- a/Package.swift +++ b/Package.swift @@ -4,12 +4,12 @@ import PackageDescription let productionDependencies: [PackageDescription.Package.Dependency] = { [ - .package(url: "https://github.com/oversizedev/OversizeUI.git", branch: "main"), - .package(url: "https://github.com/oversizedev/OversizeServices.git", branch: "main"), - .package(url: "https://github.com/oversizedev/OversizeLocalizable.git", branch: "main"), - .package(url: "https://github.com/oversizedev/OversizeCore.git", branch: "main"), - .package(url: "https://github.com/oversizedev/OversizeComponents.git", branch: "main"), - .package(url: "https://github.com/oversizedev/OversizeResources.git", branch: "main"), + .package(url: "https://github.com/oversizedev/OversizeUI.git", .upToNextMajor(from: "3.0.2")), + .package(url: "https://github.com/oversizedev/OversizeCore.git", .upToNextMajor(from: "1.3.0")), + .package(url: "https://github.com/oversizedev/OversizeServices.git", .upToNextMajor(from: "1.4.0")), + .package(url: "https://github.com/oversizedev/OversizeLocalizable.git", .upToNextMajor(from: "1.4.0")), + .package(url: "https://github.com/oversizedev/OversizeComponents.git", .upToNextMajor(from: "1.2.0")), + .package(url: "https://github.com/oversizedev/OversizeResources.git", .upToNextMajor(from: "1.3.0")), .package(url: "https://github.com/hmlongco/Factory.git", .upToNextMajor(from: "2.1.3")) ] }()