Skip to content

Onboarding View 리팩토링 #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions PyeonHaeng-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
BA73DDC42BC17912009EE718 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = BA73DDC32BC17912009EE718 /* GoogleService-Info.plist */; };
BA73DDC72BC179F6009EE718 /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = BA73DDC62BC179F6009EE718 /* FirebaseAnalytics */; };
BA73DDCB2BC179F6009EE718 /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = BA73DDCA2BC179F6009EE718 /* FirebaseCrashlytics */; };
BA7C1A5E2C241CC200869EB3 /* PageSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA7C1A5D2C241CC200869EB3 /* PageSlider.swift */; };
BA7C1A612C24317A00869EB3 /* Array+subscript.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA7C1A602C24317A00869EB3 /* Array+subscript.swift */; };
BA7C1A632C24392F00869EB3 /* OnboardingPageControlOffsetKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA7C1A622C24392F00869EB3 /* OnboardingPageControlOffsetKey.swift */; };
BA849A342B8F4F36004495BF /* ProductConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA8E83232B8EF83B00FE968C /* ProductConfiguration.swift */; };
BA849A372B8F4FC0004495BF /* MockPaginatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA849A362B8F4FC0004495BF /* MockPaginatable.swift */; };
BA8E83242B8EF83B00FE968C /* ProductConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA8E83232B8EF83B00FE968C /* ProductConfiguration.swift */; };
Expand All @@ -57,6 +60,8 @@
BAAF1D302BAFF1920001EA36 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BAAF1D2F2BAFF1920001EA36 /* Preview Assets.xcassets */; };
BAAF1D3A2BB01D910001EA36 /* NoticeDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAAF1D392BB01D910001EA36 /* NoticeDetailView.swift */; };
BAAF1D3C2BB01D980001EA36 /* NoticeDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAAF1D3B2BB01D980001EA36 /* NoticeDetailViewModel.swift */; };
BAAF367B2C2559B600C5BF44 /* View+accessibilityIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAAF367A2C2559B600C5BF44 /* View+accessibilityIdentifier.swift */; };
BAAF367E2C255CC400C5BF44 /* Subscript+AccessibilityIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAAF367D2C255CC400C5BF44 /* Subscript+AccessibilityIdentifier.swift */; };
BAB254A02C2315F900E74438 /* BottomSheetHeightKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAB2549F2C2315F900E74438 /* BottomSheetHeightKey.swift */; };
BAB569612B639F3000D1E0F9 /* DesignSystem in Frameworks */ = {isa = PBXBuildFile; productRef = BAB569602B639F3000D1E0F9 /* DesignSystem */; };
BAB5CF252B6B7C5A008B24BF /* Services.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAB5CF242B6B7C5A008B24BF /* Services.swift */; };
Expand Down Expand Up @@ -144,6 +149,9 @@
BA4C95EC2BEA263E00E80D08 /* PyeonHaeng_iOSUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PyeonHaeng_iOSUITestsLaunchTests.swift; sourceTree = "<group>"; };
BA4EA35A2B6A00F70003DCE7 /* Entity */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Entity; sourceTree = "<group>"; };
BA73DDC32BC17912009EE718 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
BA7C1A5D2C241CC200869EB3 /* PageSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageSlider.swift; sourceTree = "<group>"; };
BA7C1A602C24317A00869EB3 /* Array+subscript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+subscript.swift"; sourceTree = "<group>"; };
BA7C1A622C24392F00869EB3 /* OnboardingPageControlOffsetKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingPageControlOffsetKey.swift; sourceTree = "<group>"; };
BA849A362B8F4FC0004495BF /* MockPaginatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPaginatable.swift; sourceTree = "<group>"; };
BA8E83232B8EF83B00FE968C /* ProductConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductConfiguration.swift; sourceTree = "<group>"; };
BA9903552BBBD9F500DC3ED3 /* InfoPlist.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = InfoPlist.xcstrings; sourceTree = "<group>"; };
Expand All @@ -160,6 +168,8 @@
BAAF1D2F2BAFF1920001EA36 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
BAAF1D392BB01D910001EA36 /* NoticeDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeDetailView.swift; sourceTree = "<group>"; };
BAAF1D3B2BB01D980001EA36 /* NoticeDetailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeDetailViewModel.swift; sourceTree = "<group>"; };
BAAF367A2C2559B600C5BF44 /* View+accessibilityIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+accessibilityIdentifier.swift"; sourceTree = "<group>"; };
BAAF367D2C255CC400C5BF44 /* Subscript+AccessibilityIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Subscript+AccessibilityIdentifier.swift"; sourceTree = "<group>"; };
BAB2549F2C2315F900E74438 /* BottomSheetHeightKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomSheetHeightKey.swift; sourceTree = "<group>"; };
BAB5CF242B6B7C5A008B24BF /* Services.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Services.swift; sourceTree = "<group>"; };
BAB5CF262B6B7CF3008B24BF /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -298,6 +308,7 @@
BA28F1712B6152EE0052855E /* Sources */ = {
isa = PBXGroup;
children = (
BA7C1A5F2C24317000869EB3 /* Extensions */,
BAB2549E2C2315E600E74438 /* PreferenceKeys */,
BA9D943B2BF20EBA00E7C9F7 /* AccessibilityIdentifier.swift */,
E5462C652B65677B00E9FDF2 /* PromotionTag.swift */,
Expand All @@ -313,8 +324,8 @@
BA28F1722B61532C0052855E /* Scenes */ = {
isa = PBXGroup;
children = (
BA28F1862B61558C0052855E /* HomeScene */,
BA28F1832B6155710052855E /* OnboardingScene */,
BA28F1862B61558C0052855E /* HomeScene */,
BA28F1892B6155940052855E /* ProductInfoScene */,
BA28F18F2B61565F0052855E /* ProductSearchScene */,
BA28F18C2B6155EC0052855E /* SettingsScene */,
Expand Down Expand Up @@ -344,9 +355,10 @@
BA28F1832B6155710052855E /* OnboardingScene */ = {
isa = PBXGroup;
children = (
BA28F1842B6155810052855E /* OnboardingView.swift */,
9CE4B4742B6F78E8002DC446 /* OnboardingPageControl.swift */,
E5DB08EA2BA7EC7000E83910 /* OnboardingPage.swift */,
9CE4B4742B6F78E8002DC446 /* OnboardingPageControl.swift */,
BA28F1842B6155810052855E /* OnboardingView.swift */,
BA7C1A5D2C241CC200869EB3 /* PageSlider.swift */,
);
path = OnboardingScene;
sourceTree = "<group>";
Expand Down Expand Up @@ -422,6 +434,7 @@
BA4C95E92BEA263E00E80D08 /* PyeonHaeng-iOSUITests */ = {
isa = PBXGroup;
children = (
BAAF367C2C255CB500C5BF44 /* Utils */,
BA4C95EA2BEA263E00E80D08 /* PyeonHaengUITests.swift */,
BA4C95EC2BEA263E00E80D08 /* PyeonHaeng_iOSUITestsLaunchTests.swift */,
);
Expand All @@ -435,6 +448,15 @@
name = Frameworks;
sourceTree = "<group>";
};
BA7C1A5F2C24317000869EB3 /* Extensions */ = {
isa = PBXGroup;
children = (
BA7C1A602C24317A00869EB3 /* Array+subscript.swift */,
BAAF367A2C2559B600C5BF44 /* View+accessibilityIdentifier.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
BA849A352B8F4FB0004495BF /* Mocks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -529,10 +551,19 @@
path = "Preview Content";
sourceTree = "<group>";
};
BAAF367C2C255CB500C5BF44 /* Utils */ = {
isa = PBXGroup;
children = (
BAAF367D2C255CC400C5BF44 /* Subscript+AccessibilityIdentifier.swift */,
);
path = Utils;
sourceTree = "<group>";
};
BAB2549E2C2315E600E74438 /* PreferenceKeys */ = {
isa = PBXGroup;
children = (
BAB2549F2C2315F900E74438 /* BottomSheetHeightKey.swift */,
BA7C1A622C24392F00869EB3 /* OnboardingPageControlOffsetKey.swift */,
);
path = PreferenceKeys;
sourceTree = "<group>";
Expand Down Expand Up @@ -822,6 +853,7 @@
BA4C95ED2BEA263E00E80D08 /* PyeonHaeng_iOSUITestsLaunchTests.swift in Sources */,
BA9D943D2BF20ECB00E7C9F7 /* AccessibilityIdentifier.swift in Sources */,
BA4C95EB2BEA263E00E80D08 /* PyeonHaengUITests.swift in Sources */,
BAAF367E2C255CC400C5BF44 /* Subscript+AccessibilityIdentifier.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -835,8 +867,10 @@
E5028D5C2B96BA9400B36C16 /* SearchView.swift in Sources */,
BAE159DA2B65FC35002DCF94 /* HomeProductListView.swift in Sources */,
BA402F7E2B85E31800E86AAD /* ConvenienceSelectBottomSheetView.swift in Sources */,
BAAF367B2C2559B600C5BF44 /* View+accessibilityIdentifier.swift in Sources */,
BA19897C2BA95E8C0083B4BE /* DIContainer.swift in Sources */,
BA28F1852B6155810052855E /* OnboardingView.swift in Sources */,
BA7C1A612C24317A00869EB3 /* Array+subscript.swift in Sources */,
BAB5CF272B6B7CF3008B24BF /* HomeViewModel.swift in Sources */,
BA28F1882B6155910052855E /* HomeView.swift in Sources */,
E5F2EC452B64926100EE0838 /* PromotionTagView.swift in Sources */,
Expand All @@ -848,9 +882,11 @@
BA19897A2BA95C040083B4BE /* NoticeConfiguration.swift in Sources */,
E5DB08EB2BA7EC7000E83910 /* OnboardingPage.swift in Sources */,
9CE4B4752B6F78E8002DC446 /* OnboardingPageControl.swift in Sources */,
BA7C1A5E2C241CC200869EB3 /* PageSlider.swift in Sources */,
BA28F18E2B6156420052855E /* SettingsView.swift in Sources */,
E55DD5122B91DE9500AA63C0 /* SearchListCardView.swift in Sources */,
BA097F0E2B9CA82A002D3E1E /* MailSheetView.swift in Sources */,
BA7C1A632C24392F00869EB3 /* OnboardingPageControlOffsetKey.swift in Sources */,
E52F371B2B947DC8000EBAD5 /* SearchViewModel.swift in Sources */,
BAE159DE2B663A9A002DCF94 /* HomeProductSorterView.swift in Sources */,
BA1688E02B99B85500A8F462 /* NoticeView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Staging"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down
4 changes: 2 additions & 2 deletions PyeonHaeng-iOS/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@
}
}
},
"Numerous benefits in one place" : {
"Numerous benefits" : {
"localizations" : {
"ja" : {
"stringUnit" : {
Expand Down Expand Up @@ -953,4 +953,4 @@
}
},
"version" : "1.0"
}
}
32 changes: 26 additions & 6 deletions PyeonHaeng-iOS/Sources/AccessibilityIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,33 @@
import Foundation

public enum AccessibilityIdentifier {
public enum Splash {
static let screen = "splash.screen"
case splash(Splash)
case onboarding(Onboarding)
case home(Home)

var stringValue: String {
switch self {
case let .splash(splash):
splash.rawValue
case let .onboarding(onboarding):
onboarding.rawValue
case let .home(home):
home.rawValue
}
}

public enum Splash: String {
case screen = "splash.screen"
}

public enum Onboarding: String {
case navigationBar = "onboarding.navigationBar"
case skip = "onboarding.skip"
}

public enum Home {
static let screen = "home.screen"
static let productCountLabel = "product.count.label"
static let sortButton = "product.sort.button"
public enum Home: String {
case screen = "home.screen"
case productCountLabel = "product.count.label"
case sortButton = "product.sort.button"
}
}
14 changes: 14 additions & 0 deletions PyeonHaeng-iOS/Sources/Extensions/Array+subscript.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Array+subscript.swift
// PyeonHaeng-iOS
//
// Created by 홍승현 on 6/20/24.
//

import Foundation

extension Array {
subscript(safe index: Index) -> Element? {
indices ~= index ? self[index] : nil
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// View+accessibilityIdentifier.swift
// PyeonHaeng-iOS
//
// Created by 홍승현 on 6/21/24.
//

import SwiftUI

public extension View {
/// Uses the AccessibilityIdentifier you specify to identify the view.
///
/// Use this value for testing. It isn't visible to the user.
func accessibilityIdentifier(_ identifier: AccessibilityIdentifier) -> ModifiedContent<Self, AccessibilityAttachmentModifier> {
accessibilityIdentifier(identifier.stringValue)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// OnboardingPageControlOffsetKey.swift
// PyeonHaeng-iOS
//
// Created by 홍승현 on 6/20/24.
//

import SwiftUI

struct OnboardingPageControlOffsetKey: PreferenceKey {
static var defaultValue: CGRect = .zero

static func reduce(value: inout CGRect, nextValue: () -> CGRect) {
value = nextValue()
}
}
8 changes: 7 additions & 1 deletion PyeonHaeng-iOS/Sources/PyeonHaengApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@ import SwiftUI
@main
struct PyeonHaengApp: App {
@State private var networkMonitor: NetworkMonitor = .init()
#if !RELEASE
@AppStorage("isFirstLaunch") private var isFirstLaunch = true
#endif
private let services = Services()

init() {
FontRegistrar.registerFonts() // 앱을 실행하기 전에 폰트를 로드합니다.
setupNavigationBarAppearance()
FirebaseApp.configure()
#if !RELEASE
isFirstLaunch = true
#endif
}

var body: some Scene {
WindowGroup {
RootView {
SplashView()
.accessibilityIdentifier(AccessibilityIdentifier.Splash.screen)
.accessibilityIdentifier(.splash(.screen))
.environment(\.injected, DIContainer(services: services))
// 네트워크 연결 모니터링
.onChange(of: networkMonitor.isSatisfied) { oldValue, newValue in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct HomeProductSorterView<ViewModel>: View where ViewModel: HomeViewModelRepr
var body: some View {
HStack {
Text(productCountString)
.accessibilityIdentifier(AccessibilityIdentifier.Home.productCountLabel)
.accessibilityIdentifier(.home(.productCountLabel))
.font(.title2)
Spacer()
Button {
Expand All @@ -35,7 +35,7 @@ struct HomeProductSorterView<ViewModel>: View where ViewModel: HomeViewModelRepr
}
.accessibilityLabel(accessibilityLabel(for: viewModel.state.productConfiguration.order))
.accessibilityHint("더블 탭하여 정렬 기준을 바꿔보세요")
.accessibilityIdentifier(AccessibilityIdentifier.Home.sortButton)
.accessibilityIdentifier(.home(.sortButton))
}
.padding(.all, 8)
}
Expand Down
5 changes: 2 additions & 3 deletions PyeonHaeng-iOS/Sources/Scenes/HomeScene/View/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import SwiftUI
struct HomeView<ViewModel>: View where ViewModel: HomeViewModelRepresentable {
@StateObject private var viewModel: ViewModel
@State private var isOnboardingSheetOpen = false
@AppStorage("isFirstLaunch") private var isFirstLaunch = false
@AppStorage("isFirstLaunch") private var isFirstLaunch = true
@Environment(\.injected) private var container

init(viewModel: @autoclosure @escaping () -> ViewModel) {
Expand Down Expand Up @@ -83,9 +83,8 @@ struct HomeView<ViewModel>: View where ViewModel: HomeViewModelRepresentable {
OnboardingView()
}
.onAppear {
if !isFirstLaunch {
if isFirstLaunch {
isOnboardingSheetOpen = true
isFirstLaunch = true
}
viewModel.trigger(.fetchProducts)
}
Expand Down
30 changes: 9 additions & 21 deletions PyeonHaeng-iOS/Sources/Scenes/OnboardingScene/OnboardingPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,18 @@
// Created by 김응철 on 3/18/24.
//

import DesignSystem
import SwiftUI

/// Onboarding Paging Slider Data Model
struct OnboardingPage: Identifiable {
let id = UUID()
let id: UUID = .init()

/// 온보딩 제목
let title: LocalizedStringKey
let body: LocalizedStringKey
let image: Image
let tag: Int

static let pages: [OnboardingPage] = [
OnboardingPage(
title: "Buy one, get one free",
body: "Discover 1+1, 2+1 promotional product information from various convenience stores to consume smartly and economically.",
image: .onboarding1,
tag: 0
),
OnboardingPage(
title: "Numerous benefits in one place",
body: """
Find the myriad of promotional information from 7-Eleven, CU, emart24, GS25 all in one place with ’`Pyeonhaeng`’.
""",
image: .onboarding2,
tag: 1
),
]
/// 온보딩 부연설명
let subtitle: LocalizedStringKey

/// 이미지
let image: Image
}
Loading
Loading