Skip to content

Commit

Permalink
feat(ios): Halloween icons announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
autoreleasefool committed Sep 29, 2024
1 parent 92d31e8 commit 93f42b5
Show file tree
Hide file tree
Showing 16 changed files with 221 additions and 313 deletions.
7 changes: 0 additions & 7 deletions ios/Approach.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
CAA668BE2A8F29A800DF3E75 /* EmailService in Frameworks */ = {isa = PBXBuildFile; productRef = CAA668BD2A8F29A800DF3E75 /* EmailService */; };
CABA39BF2C38AD7100F74E0C /* AvatarEditorPreviewApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABA39BE2C38AD7100F74E0C /* AvatarEditorPreviewApp.swift */; };
CABA39C32C38AD7200F74E0C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CABA39C22C38AD7200F74E0C /* Assets.xcassets */; };
CABD35C22B85EC98001FB3C2 /* AnnouncementsService in Frameworks */ = {isa = PBXBuildFile; productRef = CABD35C12B85EC98001FB3C2 /* AnnouncementsService */; };
CABEC0CF29CBF9CD003CF669 /* AddressLookupService in Frameworks */ = {isa = PBXBuildFile; productRef = CABEC0CE29CBF9CD003CF669 /* AddressLookupService */; };
CAC458A32AB838C500898C16 /* ImportExportService in Frameworks */ = {isa = PBXBuildFile; productRef = CAC458A22AB838C500898C16 /* ImportExportService */; };
CAC51C1A2A4FDF9D00A99164 /* DatabaseMockingService in Frameworks */ = {isa = PBXBuildFile; productRef = CAC51C192A4FDF9D00A99164 /* DatabaseMockingService */; };
Expand Down Expand Up @@ -130,7 +129,6 @@
CA2890DE28F87FF2003C1EE9 /* AppFeature in Frameworks */,
CA2B78212AABC9EC0044487E /* ScoresRepository in Frameworks */,
CA439E5229E32A9900B09020 /* LeaguesRepository in Frameworks */,
CABD35C22B85EC98001FB3C2 /* AnnouncementsService in Frameworks */,
CAA668BE2A8F29A800DF3E75 /* EmailService in Frameworks */,
CA30F8E22B2670A100A80543 /* LaunchService in Frameworks */,
CAC51C1A2A4FDF9D00A99164 /* DatabaseMockingService in Frameworks */,
Expand Down Expand Up @@ -356,7 +354,6 @@
CAC458A22AB838C500898C16 /* ImportExportService */,
CA4A66172B09F37E00DCD52B /* QuickLaunchRepository */,
CA30F8E12B2670A100A80543 /* LaunchService */,
CABD35C12B85EC98001FB3C2 /* AnnouncementsService */,
CAC7A9F72BFA61FE00F35921 /* ZIPService */,
);
productName = Approach;
Expand Down Expand Up @@ -744,10 +741,6 @@
isa = XCSwiftPackageProductDependency;
productName = EmailService;
};
CABD35C12B85EC98001FB3C2 /* AnnouncementsService */ = {
isa = XCSwiftPackageProductDependency;
productName = AnnouncementsService;
};
CABEC0CE29CBF9CD003CF669 /* AddressLookupService */ = {
isa = XCSwiftPackageProductDependency;
productName = AddressLookupService;
Expand Down
41 changes: 3 additions & 38 deletions ios/Approach/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ let package = Package(
.library(name: "AddressLookupServiceInterface", targets: ["AddressLookupServiceInterface"]),
.library(name: "AnalyticsService", targets: ["AnalyticsService"]),
.library(name: "AnalyticsServiceInterface", targets: ["AnalyticsServiceInterface"]),
.library(name: "AnnouncementsService", targets: ["AnnouncementsService"]),
.library(name: "AnnouncementsServiceInterface", targets: ["AnnouncementsServiceInterface"]),
.library(name: "AppIconService", targets: ["AppIconService"]),
.library(name: "AppIconServiceInterface", targets: ["AppIconServiceInterface"]),
.library(name: "AvatarService", targets: ["AvatarService"]),
Expand Down Expand Up @@ -114,7 +112,6 @@ let package = Package(
.library(name: "ZIPServiceInterface", targets: ["ZIPServiceInterface"]),

// MARK: - Libraries
.library(name: "AnnouncementsLibrary", targets: ["AnnouncementsLibrary"]),
.library(name: "AssetsLibrary", targets: ["AssetsLibrary"]),
.library(name: "ComposableExtensionsLibrary", targets: ["ComposableExtensionsLibrary"]),
.library(name: "ConstantsLibrary", targets: ["ConstantsLibrary"]),
Expand Down Expand Up @@ -238,10 +235,11 @@ let package = Package(
.target(
name: "AnnouncementsFeature",
dependencies: [
.product(name: "UserDefaultsPackageServiceInterface", package: "swift-utilities"),
"AnalyticsServiceInterface",
"AnnouncementsServiceInterface",
"FeatureActionLibrary",
"LoggingServiceInterface",
"ViewsLibrary",
]
),
.testTarget(
Expand Down Expand Up @@ -305,6 +303,7 @@ let package = Package(
.product(name: "ExtensionsPackageLibrary", package: "swift-utilities"),
"AnalyticsServiceInterface",
"AvatarServiceInterface",
"ComposableExtensionsLibrary",
"FeatureActionLibrary",
"FeatureFlagsLibrary",
"LoggingServiceInterface",
Expand Down Expand Up @@ -1179,26 +1178,6 @@ let package = Package(
"AnalyticsService",
]
),
.target(
name: "AnnouncementsService",
dependencies: [
.product(name: "UserDefaultsPackageServiceInterface", package: "swift-utilities"),
"AnnouncementsServiceInterface",
]
),
.target(
name: "AnnouncementsServiceInterface",
dependencies: [
"AnnouncementsLibrary",
]
),
.testTarget(
name: "AnnouncementsServiceTests",
dependencies: [
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
"AnnouncementsService",
]
),
.target(
name: "AppIconService",
dependencies: [
Expand Down Expand Up @@ -1489,20 +1468,6 @@ let package = Package(
),

// MARK: - Libraries
.target(
name: "AnnouncementsLibrary",
dependencies: [
.product(name: "Dependencies", package: "swift-dependencies"),
"ViewsLibrary",
]
),
.testTarget(
name: "AnnouncementsLibraryTests",
dependencies: [
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
"AnnouncementsLibrary",
]
),
.target(
name: "AssetsLibrary",
dependencies: [
Expand Down
14 changes: 3 additions & 11 deletions ios/Approach/Package.swift.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ libraries = [ "FeatureFlags", "ResourceList" ]
dependencies = [ "ExtensionsPackageLibrary" ]

[features.Announcements]
services = [ "Announcements" ]
libraries = [ "Views" ]
dependencies = [ "UserDefaultsPackageServiceInterface" ]

[features.ArchiveList]
features = [ "Errors" ]
Expand All @@ -44,7 +45,7 @@ libraries = [ "DateTime", "ModelsViews" ]

[features.AvatarEditor]
services = [ "Avatar" ]
libraries = [ "FeatureFlags", "Views" ]
libraries = [ "ComposableExtensions", "FeatureFlags", "Views" ]
dependencies = [ "EquatablePackageLibrary", "ExtensionsPackageLibrary" ]

[features.BowlerDetails]
Expand Down Expand Up @@ -237,11 +238,6 @@ dependencies = [ "Sentry" ]
[services.Analytics.interface]
dependencies = [ "AnalyticsPackageServiceInterface", "ComposableArchitecture", "DependenciesMacros", "ErrorReportingClientPackageLibrary" ]

[services.Announcements]
dependencies = [ "UserDefaultsPackageServiceInterface" ]
[services.Announcements.interface]
libraries = [ "Announcements" ]

[services.AppIcon]
skip_tests = true
[services.AppIcon.interface]
Expand Down Expand Up @@ -311,10 +307,6 @@ dependencies = [ "DependenciesMacros" ]

# Libraries

[libraries.Announcements]
libraries = [ "Views" ]
dependencies = [ "Dependencies" ]

[libraries.Assets]
skip_tests = true
dependencies = [ "SFSafeSymbols" ]
Expand Down
96 changes: 59 additions & 37 deletions ios/Approach/Sources/AnnouncementsFeature/Announcements.swift
Original file line number Diff line number Diff line change
@@ -1,80 +1,102 @@
import AnnouncementsLibrary
import AnnouncementsServiceInterface
import ComposableArchitecture
import FeatureActionLibrary
import SwiftUI
import SwiftUIExtensionsPackageLibrary
import ViewsLibrary

@Reducer
public struct Announcements: Reducer, Sendable {
@ObservableState
public struct State: Equatable {
public let announcement: Announcement
@Presents public var destination: Destination.State?

public init(announcement: Announcement) {
self.announcement = announcement
}
public init() {}
}

public enum Action: FeatureAction, ViewAction {
@CasePathable public enum View {
case didDoAction(AnnouncementView.Action)
case didDismiss
case didFirstAppear
}
@CasePathable public enum Delegate {
case openAppIconSettings
@CasePathable public enum Delegate { case doNothing }
@CasePathable public enum Internal {
case showHalloweenAnnouncement

case destination(PresentationAction<Destination.Action>)
}
@CasePathable public enum Internal { case doNothing }

case view(View)
case delegate(Delegate)
case `internal`(Internal)
}

public init() {}
@Reducer(state: .equatable)
public enum Destination {
case halloween2024(Halloween2024Announcement)
}

@Dependency(\.dismiss) var dismiss
public init() {}

public var body: some ReducerOf<Self> {
Reduce<State, Action> { _, action in
Reduce<State, Action> { state, action in
switch action {
case let .view(viewAction):
switch viewAction {
case let .didDoAction(action):
switch action {
case .openAppIconSettings:
return .concatenate(
.send(.delegate(.openAppIconSettings)),
.run { _ in await dismiss() }
)
case .didFirstAppear:
return .run { send in
// Check for announcements
if await Halloween2024Announcement.shouldShow() {
await send(.internal(.showHalloweenAnnouncement))
}
}

case .didDismiss:
return .run { _ in await dismiss() }
}

case .internal(.doNothing):
return .none
case let .internal(internalAction):
switch internalAction {
case .showHalloweenAnnouncement:
state.destination = .halloween2024(Halloween2024Announcement.State())
return .none

case .destination(.dismiss):
switch state.destination {
case .halloween2024:
return .run { _ in await Halloween2024Announcement.didDismiss() }

case .none:
return .none
}

case .destination(.presented(.halloween2024(.delegate(.doNothing)))),
.destination(.presented(.halloween2024(.internal))),
.destination(.presented(.halloween2024(.view))):
return .none
}

case .delegate:
return .none
}
}
.ifLet(\.$destination, action: \.internal.destination)
}
}

@ViewAction(for: Announcements.self)
public struct AnnouncementsView: View {
public let store: StoreOf<Announcements>
// MARK: - View

public init(store: StoreOf<Announcements>) {
self.store = store
public struct AnnouncementsViewModifier: ViewModifier {
@SwiftUI.State var store: StoreOf<Announcements>

public func body(content: Content) -> some View {
content
.onFirstAppear { store.send(.view(.didFirstAppear)) }
.sheet(
item: $store.scope(state: \.destination?.halloween2024, action: \.internal.destination.halloween2024)
) {
Halloween2024AnnouncementView(store: $0)
}
}
}

public var body: some View {
AnnouncementsLibrary.AnnouncementView(
announcement: store.announcement,
onAction: { send(.didDoAction($0)) },
onDismiss: { send(.didDismiss) }
)
extension View {
public func announcements(store: StoreOf<Announcements>) -> some View {
self.modifier(AnnouncementsViewModifier(store: store))
}
}
Loading

0 comments on commit 93f42b5

Please sign in to comment.