Skip to content

Commit

Permalink
feat : 참여자 없는 화면 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
미니 committed Sep 21, 2023
1 parent 9e27f0f commit 1613c28
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 53 deletions.
20 changes: 20 additions & 0 deletions igoMoney/igoMoney.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
18599A4B2ABC321E0075DE76 /* MyChallengeSectionCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18599A4A2ABC321E0075DE76 /* MyChallengeSectionCore.swift */; };
18599A4E2ABC32790075DE76 /* EmptyChallengeListSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18599A4D2ABC32790075DE76 /* EmptyChallengeListSection.swift */; };
18599A502ABC329C0075DE76 /* EmptyChallengeListSectionCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18599A4F2ABC329C0075DE76 /* EmptyChallengeListSectionCore.swift */; };
18599A532ABC34640075DE76 /* ChallengeInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18599A522ABC34640075DE76 /* ChallengeInformation.swift */; };
18599A572ABC35C70075DE76 /* EmptyChallengeDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18599A562ABC35C70075DE76 /* EmptyChallengeDetail.swift */; };
18599A592ABC43D80075DE76 /* EmptyChallengeDetailCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18599A582ABC43D80075DE76 /* EmptyChallengeDetailCore.swift */; };
18606F492AB9D20A00025C37 /* ProfileSettingCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18606F482AB9D20A00025C37 /* ProfileSettingCore.swift */; };
187252C72ABC07AE00DCF08C /* MainTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 187252C62ABC07AE00DCF08C /* MainTab.swift */; };
187252C92ABC07C700DCF08C /* MainCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 187252C82ABC07C700DCF08C /* MainCore.swift */; };
Expand Down Expand Up @@ -76,6 +79,9 @@
18599A4A2ABC321E0075DE76 /* MyChallengeSectionCore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyChallengeSectionCore.swift; sourceTree = "<group>"; };
18599A4D2ABC32790075DE76 /* EmptyChallengeListSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyChallengeListSection.swift; sourceTree = "<group>"; };
18599A4F2ABC329C0075DE76 /* EmptyChallengeListSectionCore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyChallengeListSectionCore.swift; sourceTree = "<group>"; };
18599A522ABC34640075DE76 /* ChallengeInformation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeInformation.swift; sourceTree = "<group>"; };
18599A562ABC35C70075DE76 /* EmptyChallengeDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyChallengeDetail.swift; sourceTree = "<group>"; };
18599A582ABC43D80075DE76 /* EmptyChallengeDetailCore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyChallengeDetailCore.swift; sourceTree = "<group>"; };
18606F482AB9D20A00025C37 /* ProfileSettingCore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileSettingCore.swift; sourceTree = "<group>"; };
187252C62ABC07AE00DCF08C /* MainTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTab.swift; sourceTree = "<group>"; };
187252C82ABC07C700DCF08C /* MainCore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainCore.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -228,12 +234,22 @@
18599A4C2ABC325E0075DE76 /* EmptyChallengeListSection */ = {
isa = PBXGroup;
children = (
18599A552ABC35B40075DE76 /* EmptyChallengeDetail */,
18599A4D2ABC32790075DE76 /* EmptyChallengeListSection.swift */,
18599A4F2ABC329C0075DE76 /* EmptyChallengeListSectionCore.swift */,
);
path = EmptyChallengeListSection;
sourceTree = "<group>";
};
18599A552ABC35B40075DE76 /* EmptyChallengeDetail */ = {
isa = PBXGroup;
children = (
18599A562ABC35C70075DE76 /* EmptyChallengeDetail.swift */,
18599A582ABC43D80075DE76 /* EmptyChallengeDetailCore.swift */,
);
path = EmptyChallengeDetail;
sourceTree = "<group>";
};
187252CC2ABC0B6200DCF08C /* ChallengeScene */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -266,6 +282,7 @@
isa = PBXGroup;
children = (
18CD8F2F2AB9A1EF006FEA6F /* Provier.swift */,
18599A522ABC34640075DE76 /* ChallengeInformation.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -395,7 +412,9 @@
180FC6A42ABB4BC500DD8477 /* APIClient.swift in Sources */,
18606F492AB9D20A00025C37 /* ProfileSettingCore.swift in Sources */,
180FC6A22ABB48DC00DD8477 /* Networking.swift in Sources */,
18599A572ABC35C70075DE76 /* EmptyChallengeDetail.swift in Sources */,
18CD8F2D2AB995F5006FEA6F /* SignUpCore.swift in Sources */,
18599A532ABC34640075DE76 /* ChallengeInformation.swift in Sources */,
18599A452ABC2A950075DE76 /* ChallengeCore.swift in Sources */,
187252CB2ABC081F00DCF08C /* MainRoundTabBar.swift in Sources */,
180FC6912ABB157200DD8477 /* Bundle+Extensions.swift in Sources */,
Expand All @@ -419,6 +438,7 @@
18599A4E2ABC32790075DE76 /* EmptyChallengeListSection.swift in Sources */,
187252D12ABC0BA800DCF08C /* MyPageScene.swift in Sources */,
187252C92ABC07C700DCF08C /* MainCore.swift in Sources */,
18599A592ABC43D80075DE76 /* EmptyChallengeDetailCore.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//
// EmptyChallengeDetail.swift
// igoMoney
//
// Copyright (c) 2023 Minii All rights reserved.

import SwiftUI

import ComposableArchitecture

struct EmptyChallengeDetail: View {
let store: StoreOf<ChallengeDetailCore>

var body: some View {
VStack(alignment: .leading, spacing: 8) {
// 챌린지 타이틀
WithViewStore(store, observe: { $0.title }) { viewStore in
Text("같이 절약 챌린지 성공해봐요!")
.multilineTextAlignment(.leading)
.minimumScaleFactor(0.5)
.lineLimit(2)
.font(.system(size: 16, weight: .bold))
}

// 챌린지 생성자 닉네임
WithViewStore(store, observe: { $0.user }) { viewStore in
Text(viewStore.nickName)
.font(.system(size: 12, weight: .medium))
}

VStack(alignment: .leading, spacing: 2) {
// 챌린지 머니
WithViewStore(store, observe: { $0.targetMoneyDescription }) { viewStore in
Text(viewStore.state)
.padding(.horizontal, 2)
.background(ColorConstants.primary7)
.cornerRadius(4)
}

Text("내일부터 시작")
.padding(.horizontal, 2)
.background(ColorConstants.primary7)
.cornerRadius(4)
}
.font(.system(size: 12, weight: .medium))

HStack {
Spacer()

// 사용자 이미지
WithViewStore(store, observe: { $0.user.profileImagePath }) { viewStore in
if let path = viewStore.state {
// 사용자 프로필 이미지로 변경하기
Image("default_profile")
.resizable()
.scaledToFit()
.frame(width: 60)
} else {
Image("default_profile")
.resizable()
.scaledToFit()
.frame(width: 60)
}
}
}
}
.padding(16)
.background(
RoundedRectangle(cornerRadius: 10)
.fill(.white)
.shadow(
color: ColorConstants.gray2.opacity(0.3),
radius: 8,
y: 2
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// EmptyChallengeDetailCore.swift
// igoMoney
//
// Copyright (c) 2023 Minii All rights reserved.

import Foundation

import ComposableArchitecture

struct ChallengeDetailCore: Reducer {
struct State: Equatable, Identifiable {
let id: UUID

var title: String
var content: String
var targetAmount: Int
var user: User

var targetMoneyDescription: String {
return "💸 \(targetAmount)"
}
}

enum Action: Equatable, Sendable {

}

func reduce(into state: inout State, action: Action) -> Effect<Action> {
return .none
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,22 @@ struct EmptyChallengeListSection: View {
}

var body: some View {
ChallengeSectionTitleView(sectionType: .emptyChallenge) {
print("Move Empty List")
}

LazyVGrid(columns: generateGridItem(count: 2, spacing: 16), spacing: 12) {
ForEach(1..<10, id: \.self) { _ in
// TODO: - 각 뷰마다 Reducer 가질 수 있도록 변경
VStack(alignment: .leading, spacing: 8) {
Text("같이 절약 챌린지 성공해봐요!")
.multilineTextAlignment(.leading)
.minimumScaleFactor(0.5)
.lineLimit(2)
.font(.system(size: 16, weight: .bold))

Text("아이고머니님")
.font(.system(size: 12, weight: .medium))

VStack(alignment: .leading, spacing: 2) {
Text("50000원")
.padding(.horizontal, 2)
.background(ColorConstants.primary7)
.cornerRadius(4)

Text("내일부터 시작")
.padding(.horizontal, 2)
.background(ColorConstants.primary7)
.cornerRadius(4)
}
.font(.system(size: 12, weight: .medium))

HStack {
Spacer()

Image("default_profile")
.resizable()
.scaledToFit()
.frame(width: 60)
}
VStack {
ChallengeSectionTitleView(sectionType: .emptyChallenge) {
print("Move Empty List")
}

LazyVGrid(columns: generateGridItem(count: 2, spacing: 16), spacing: 12) {
ForEachStore(store.scope(
state: \.challenges,
action: EmptyChallengeListSectionCore.Action.challengeDetail)
) { store in
EmptyChallengeDetail(store: store)
}
.padding(16)
.background(
RoundedRectangle(cornerRadius: 10)
.fill(.white)
.shadow(
color: ColorConstants.gray2.opacity(0.3),
radius: 8,
y: 2
)
)
}
}
.onAppear {
store.send(._onAppear)
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,50 @@
//
// Copyright (c) 2023 Minii All rights reserved.

import Foundation

import ComposableArchitecture

struct EmptyChallengeListSectionCore: Reducer {
struct State: Equatable {

var challenges: IdentifiedArrayOf<ChallengeDetailCore.State> = []
}

enum Action: Equatable {
enum Action: Equatable, Sendable {
// User Action
// Inner Action
case _onAppear

// Child Action
case challengeDetail(id: ChallengeDetailCore.State.ID, action: ChallengeDetailCore.Action)
}

func reduce(into state: inout State, action: Action) -> Effect<Action> {
return .none
var body: some Reducer<State, Action> {
Reduce { state, action in
switch action {
// Inner Action
case ._onAppear:
let informations = ChallengeInformation.default
informations.forEach {
let detailState = ChallengeDetailCore.State(
id: UUID(),
title: $0.title,
content: $0.content,
targetAmount: $0.targetAmount,
user: $0.user
)
state.challenges.append(detailState)
}

return .none

// Child Action
case .challengeDetail:
return .none
}
}
.forEach(\.challenges, action: /Action.challengeDetail) {
ChallengeDetailCore()
}
}
}
43 changes: 43 additions & 0 deletions igoMoney/igoMoney/Source/Models/ChallengeInformation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// ChallengeInformation.swift
// igoMoney
//
// Copyright (c) 2023 Minii All rights reserved.

import Foundation

struct ChallengeInformation: Decodable, Equatable {
let title: String
let content: String
let targetAmount: Int
let user: User

static let `default`: [Self] = Array(
repeating: ChallengeInformation(
title: "일주일에 3만원으로 살아남기 👊🏻",
content: "",
targetAmount: 30000,
user: .default
),
count: 16
)


static func == (lhs: ChallengeInformation, rhs: ChallengeInformation) -> Bool {
return lhs.title == rhs.title && lhs.user.id == rhs.user.id
}
}

struct User: Decodable, Equatable {
let id: String
let nickName: String
let profileImagePath: String?
let email: String

static let `default` = User(
id: UUID().uuidString,
nickName: "아이고머니",
profileImagePath: nil,
email: "[email protected]"
)
}

0 comments on commit 1613c28

Please sign in to comment.