Skip to content

Commit

Permalink
Merge pull request #11 from oversizedev/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
aromanov91 authored Apr 13, 2023
2 parents eba5e7e + 2c95bf6 commit 8a78d51
Show file tree
Hide file tree
Showing 30 changed files with 535 additions and 159 deletions.
23 changes: 16 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// 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

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"))
] }()

let developmentDependencies: [PackageDescription.Package.Dependency] = { [
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -113,6 +120,8 @@ let package = Package(
"OversizeKit",
.product(name: "OversizeUI", package: "OversizeUI"),
.product(name: "OversizeServices", package: "OversizeServices"),
.product(name: "OversizeNotificationService", package: "OversizeServices"),
.product(name: "Factory", package: "Factory")
]
),
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import OversizeCore
import OversizeLocationService
import OversizeServices
import SwiftUI
import Factory

public enum CreateEventType: Equatable {
case new(Date?, calendar: EKCalendar?)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
11 changes: 6 additions & 5 deletions Sources/OversizeKit/LauncherKit/LauncherViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Sources/OversizeKit/LauncherKit/RateAppScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

import OversizeCore
import OversizeLocalizable

import OversizeServices

import OversizeUI
import SwiftUI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Sources/OversizeKit/SettingsKit/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import OversizeLocalizable
import OversizeResources
import OversizeServices

import OversizeUI
import SwiftUI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import OversizeCore
import OversizeLocalizable
import OversizeServices

import OversizeUI
import SwiftUI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import OversizeServices
import OversizeStoreService
import StoreKit
import SwiftUI
import Factory

@MainActor
class StoreViewModel: ObservableObject {
Expand All @@ -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<Void, Error>?
Expand Down
3 changes: 2 additions & 1 deletion Sources/OversizeKit/StoreKit/Views/StoreProductView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
12 changes: 11 additions & 1 deletion Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright © 2022 Alexander Romanov
// Copyright © 2023 Alexander Romanov
// ErrorView.swift
//

Expand Down Expand Up @@ -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
}
}
}
}
Expand Down
18 changes: 8 additions & 10 deletions Sources/OversizeKit/SystemKit/SystemServices.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
//
// Copyright © 2022 Alexander Romanov
// Copyright © 2023 Alexander Romanov
// SystemServices.swift
//

import OversizeCore
import OversizeLocalizable

import OversizeServices

import OversizeStoreService
import OversizeUI
import SwiftUI
import Factory

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(\.appStateService) var appState: AppStateService
@Injected(\.settingsService) var settingsService: SettingsServiceProtocol
@Injected(\.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()
Expand Down Expand Up @@ -71,7 +70,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)
}
Expand Down
Loading

0 comments on commit 8a78d51

Please sign in to comment.