Skip to content

Commit

Permalink
Merge branch 'develop' into feat/archiveCalendar/#210
Browse files Browse the repository at this point in the history
  • Loading branch information
FpRaArNkK authored Nov 13, 2024
2 parents 302547c + 5426e76 commit 5a3899c
Show file tree
Hide file tree
Showing 81 changed files with 1,404 additions and 1,638 deletions.
21 changes: 12 additions & 9 deletions Namo_SwiftUI/Projects/App/Sources/MainTab/MainTabCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@
//

import Foundation
import ComposableArchitecture
import TCACoordinators

import Feature
import Domain
import Shared

import ComposableArchitecture
import TCACoordinators

@Reducer
struct MainTabCoordinator {
enum Tab: Hashable {
case home
case moim
}

enum Action {

enum Action: BindableAction {
case binding(BindingAction<State>)
case home(HomeCoordinator.Action)
case moim(MoimCoordinator.Action)

Expand All @@ -31,17 +30,21 @@ struct MainTabCoordinator {

@ObservableState
struct State: Equatable {
static let intialState = State(home: .initialState, moim: .initialState)
static let intialState = State(currentTab: .home, home: .initialState, moim: .initialState)

var currentTab: Tab
var home: HomeCoordinator.State
var moim: MoimCoordinator.State


@Shared(.inMemory(SharedKeys.categories.rawValue)) var categories: [NamoCategory] = []
}

@Dependency(\.categoryUseCase) var categoryUseCase

var body: some ReducerOf<Self> {
// 탭은 Navigatin을 가지지 않고 각 Coordinator를 Scope로 설정
BindingReducer()

Scope(state: \.home, action: \.home) {
HomeCoordinator()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,29 @@
//

import SwiftUI

import Feature
import SharedDesignSystem

import ComposableArchitecture
import TCACoordinators
import Feature

struct MainTabCoordinatorView: View {
let store: StoreOf<MainTabCoordinator>

@Perception.Bindable var store: StoreOf<MainTabCoordinator>
var body: some View {
WithPerceptionTracking {
TabView {
TabView(selection: $store.currentTab) {
HomeCoordinatorView(store: store.scope(state: \.home, action: \.home))
.tabItem { Text("") }
.tag(Tab.home)
MoimCoordinatorView(store: store.scope(state: \.moim, action: \.moim))
.tabItem { Text("모임") }
.tag(Tab.group)
}
.overlay(alignment: .bottom) {
NamoTabView(currentTab: $store.currentTab)
}
.edgesIgnoringSafeArea(.bottom)
.onAppear {
store.send(.viewOnAppear)
}
Expand Down
6 changes: 4 additions & 2 deletions Namo_SwiftUI/Projects/App/Sources/Root/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
//

import Foundation

import SharedUtil

import ComposableArchitecture
import TCACoordinators
import SharedUtil

@Reducer(state: .equatable)
enum AppScreen {
Expand Down Expand Up @@ -51,7 +53,7 @@ struct AppCoordinator {

// mainTab 이동 - 로그인 체크 결과 goToMainScreen 시
case .router(.routeAction(_, action: .onboarding(.goToMainScreen))):
state.routes = [.root(.mainTab(.init(home: .initialState, moim: .initialState)), embedInNavigationView: true)]
state.routes = [.root(.mainTab(.init(currentTab: .home, home: .initialState, moim: .initialState)), embedInNavigationView: true)]
return .none

// Notification 에러 핸들링
Expand Down
40 changes: 21 additions & 19 deletions Namo_SwiftUI/Projects/App/Sources/Root/AppCoordinatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,31 @@ import SharedDesignSystem
import SharedUtil

struct AppCoordinatorView: View {
let store: StoreOf<AppCoordinator>
@Perception.Bindable var store: StoreOf<AppCoordinator>
@State private var cancellables = Set<AnyCancellable>()

var body: some View {
TCARouter(store.scope(state: \.routes, action: \.router)) { screen in
switch screen.case {
case let .mainTab(store):
MainTabCoordinatorView(store: store)
case let .onboarding(store):
OnboardingCoordinatorView(store: store)
WithPerceptionTracking {
TCARouter(store.scope(state: \.routes, action: \.router)) { screen in
switch screen.case {
case let .mainTab(store):
MainTabCoordinatorView(store: store)
case let .onboarding(store):
OnboardingCoordinatorView(store: store)
}
}
}
.namoAlertView(
isPresented: Binding(get: { store.showAlert }, set: { store.send(.changeShowAlert(show: $0)) }),
title: store.alertTitle,
content: store.alertContent,
confirmAction: {
store.send(.doAlertConfirmAction)
}
)
.onReceive(NotificationCenter.default.publisher(for: .networkError)) { notification in
if let error = notification.userInfo?["error"] as? NetworkErrorNotification {
store.send(.handleNotiError(error: error))
// .namoAlertView(
// isPresented: Binding(get: { store.showAlert }, set: { store.send(.changeShowAlert(show: $0)) }),
// title: store.alertTitle,
// content: store.alertContent,
// confirmAction: {
// store.send(.doAlertConfirmAction)
// }
// )
.onReceive(NotificationCenter.default.publisher(for: .networkError)) { notification in
if let error = notification.userInfo?["error"] as? NetworkErrorNotification {
store.send(.handleNotiError(error: error))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public extension AuthManager {
try KeyChainManager.addItem(key: "refreshToken", value: result.refreshToken)

// 3. userId 키체인 저장

try KeyChainManager.addItem(key: "userId", value: String(result.userId))

// 4. 약관 동의, 필요 정보 작성 여부 저장
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,5 @@ extension FriendCategoryDTO {
return FriendCategory(categoryName: categoryName, colorId: colorId)
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
//

import Foundation

import CoreNetwork
import DomainFriend
import SharedUtil

public extension MoimScheduleListResponseDTO {
Expand All @@ -23,14 +25,14 @@ public extension MoimScheduleListResponseDTO {
public extension MoimSchedule {
func toDto() -> MoimScheduleRequestDTO {
return .init(title: title,
imageUrl: nil,
imageUrl: imageUrl,
period: PeriodDto(startDate: startDate.dateToISO8601(),
endDate: endDate.dateToISO8601()),
location: LocationDto(longitude: 0.0,
latitude: 0.0,
location: LocationDto(longitude: longitude,
latitude: latitude,
locationName: locationName,
kakaoLocationId: kakaoLocationId),
participants: [11])
participants: participants.map { $0.userId })
}
}

Expand All @@ -40,8 +42,8 @@ public extension MoimSchedule {
imageUrl: imageUrl,
period: PeriodDto(startDate: startDate.dateToISO8601(),
endDate: startDate.dateToISO8601()),
location: LocationDto(longitude: 0.0,
latitude: 0.0,
location: LocationDto(longitude: longitude,
latitude: latitude,
locationName: locationName,
kakaoLocationId: kakaoLocationId),
participantsToAdd: [],
Expand Down Expand Up @@ -74,3 +76,14 @@ public extension ParticipantsDto {
isOwner: isOwner)
}
}

public extension Friend {
func toParticipant() -> Participant {
.init(participantId: 0,
userId: memberId,
isGuest: false,
nickname: nickname,
colorId: favoriteColorId,
isOwner: false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import Foundation
import CoreNetwork

public struct MoimSchedule: Decodable, Hashable {
import SharedUtil

public struct MoimSchedule: Decodable, Hashable, Equatable {
public init(scheduleId: Int,
title: String,
imageUrl: String,
Expand All @@ -30,16 +32,30 @@ public struct MoimSchedule: Decodable, Hashable {
self.kakaoLocationId = kakaoLocationId
self.participants = participants
}

public init() {
self.scheduleId = 0
self.title = ""
self.imageUrl = ""
self.startDate = .now
self.endDate = .now
self.longitude = 0.0
self.latitude = 0.0
self.locationName = ""
self.kakaoLocationId = ""
self.participants = []
}

public let scheduleId: Int
public let title: String
public let imageUrl: String
public let startDate: Date
public let endDate: Date
public let longitude: Double
public let latitude: Double
public let locationName: String
public let kakaoLocationId: String
public let participants: [Participant]
public var title: String
public var imageUrl: String
public var startDate: Date
public var endDate: Date
public var longitude: Double
public var latitude: Double
public var locationName: String
public var kakaoLocationId: String
public var participants: [Participant]
}

public struct Participant: Decodable, Hashable {
Expand All @@ -66,6 +82,14 @@ public struct Participant: Decodable, Hashable {

public extension MoimSchedule {
var isOwner: Bool {
participants.firstIndex(where: { $0.isOwner && $0.userId == UserDefaults.standard.integer(forKey: "userId")}) != nil
do {
guard let readUserId = try? KeyChainManager.readItem(key: "userId"),
let userId = Int(readUserId) else {
return false
}
return participants.firstIndex(where: { $0.isOwner && $0.userId == userId}) != nil
} catch {
return false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct MoimScheduleItem: Decodable, Hashable {
public struct MoimScheduleItem: Decodable, Hashable, Identifiable {
public init(meetingScheduleId: Int,
title: String,
startDate: String,
Expand All @@ -21,6 +21,7 @@ public struct MoimScheduleItem: Decodable, Hashable {
self.participantCount = participantCount
self.participantNicknames = participantNicknames
}
public var id: Int { meetingScheduleId }
public let meetingScheduleId: Int
public let title: String
public let startDate: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI

import ComposableArchitecture
import TCACoordinators
import SharedDesignSystem

public struct ScheduleEditCoordinatorView: View {
let store: StoreOf<ScheduleEditCoordinator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ComposableArchitecture
@main
struct FeautureMoimExampleApp: App {
var body: some Scene {
WindowGroup {
WindowGroup {
MoimCoordinatorView(store: .init(initialState: .initialState, reducer: {
MoimCoordinator()
}))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// FriendInviteStoreInterface.swift
// FeatureMoim
//
// Created by 권석기 on 11/3/24.
//

import Foundation

import DomainFriendInterface
import DomainFriend

import ComposableArchitecture

/**
Reducer for FriendInvite(친구초대) Feature
*/
@Reducer
public struct FriendInviteStore {
private let reducer: Reduce<State, Action>

public init(reducer: Reduce<State, Action>) {
self.reducer = reducer
}

@ObservableState
public struct State: Equatable {
public init() {}

/// 검색어
public var searchText = ""

/// 친구목록
public var friendList: [Friend] = []

/// 추가한 친구목록
public var addedFriend: [Friend] = []
}

public enum Action: BindableAction {

/// 바인딩액션
case binding(BindingAction<State>)

/// 검색결과탭
case searchButtonTapped

/// 검색결과 응답
case searchResponse(FriendResponse)

/// 친구 추가
case addFriend(Friend)

/// 초대친구 삭제
case removeFriend(memberId: Int)

/// 뒤로가기
case backButtonTapped
}

public var body: some ReducerOf<Self> {
BindingReducer()

reducer
}
}
Loading

0 comments on commit 5a3899c

Please sign in to comment.