Skip to content
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

merge :: 잔류 신청 api 연동 #177

Merged
merged 28 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5812819
feat :: 잔류 신청 공지 사항 api 연동
HongSJae Feb 27, 2023
9dc2f45
fix :: 에러 메세지 수정
HongSJae Feb 27, 2023
2b9b148
feat :: WeekType 한국어로 바꾸는 함수
HongSJae Feb 27, 2023
b434f07
feat :: Date 포매팅
baekteun Feb 27, 2023
87c0680
fix :: conflicts
HongSJae Feb 27, 2023
103e933
feat :: 잔류 신청 공지 api 연동 완성
HongSJae Feb 27, 2023
6d3310d
feat :: Select 기능 및 list api 연동
HongSJae Feb 27, 2023
d14bee4
fix :: 명세서 변경에 따른 수정
HongSJae Feb 27, 2023
9487ac5
feat :: 클릭 변수 변경
HongSJae Feb 27, 2023
488c36f
feat :: 잔류 신청 api 연동
HongSJae Feb 28, 2023
0ea6b40
feat :: 잔류 신청 api 연동
HongSJae Feb 28, 2023
c0bc12e
fix :: ~ != nil -> if let 으로 변경
HongSJae Feb 28, 2023
00b8af5
fix :: 오타 수정
HongSJae Feb 28, 2023
e7b8fdb
fix :: switch 스타일 가이드
HongSJae Feb 28, 2023
5746753
fix :: 줄바꿈
HongSJae Feb 28, 2023
3cad4e4
fix :: 줄바꿈
HongSJae Feb 28, 2023
c4f3a63
fix :: 타입 명시 제거
HongSJae Feb 28, 2023
75cfc9a
fix :: retain cycle
HongSJae Feb 28, 2023
5de8570
fix :: retain cycle
HongSJae Feb 28, 2023
723fdc1
fix :: 줄바꿈
HongSJae Feb 28, 2023
5bd239d
fix :: 코드 줄이기
HongSJae Feb 28, 2023
bae276a
fix :: comment 대로 코드 개선
HongSJae Feb 28, 2023
04ff7ea
fix :: 함수 수정
HongSJae Feb 28, 2023
c9ae9e2
fix :: 들여쓰기
HongSJae Feb 28, 2023
669b959
fix :: LazyStack으로 변경
HongSJae Feb 28, 2023
97d37f7
fix :: error 추가
HongSJae Feb 28, 2023
55e4127
fix :: viewmodel 에서 함수 처리
HongSJae Feb 28, 2023
4c44126
feat :: toast 설정
HongSJae Feb 28, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ public extension AppComponent {

var remainingApplicationsChangesUseCase: any RemainingApplicationsChangesUseCase {
shared {
RemainingApplicationsChangesUseCaselmpl(remainsRepository: remainsRepository)
RemainingApplicationsChangesUseCaseImpl(remainsRepository: remainsRepository)
}
}

var fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase {
shared {
FetchMyRemainApplicationItemsUseCaselmpl(remainsRepository: remainsRepository)
FetchMyRemainApplicationItemsUseCaseImpl(remainsRepository: remainsRepository)
}
}

var fetchRemainApplicationListUseCase: any FetchRemainApplicationListUseCase {
shared {
FetchRemainAppListUseCaselmpl(remainsRepository: remainsRepository)
FetchRemainAppListUseCaseImpl(remainsRepository: remainsRepository)
}
}

var fetchRemainsAvailableTimeUseCase: any FetchRemainsAvailableTimeUseCase {
shared {
FetchRemainsAvailableTimeUseCaselmpl(remainsRepository: remainsRepository)
FetchRemainsAvailableTimeUseCaseImpl(remainsRepository: remainsRepository)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ public extension AppComponent {
var cancelStudyRoomSeatUseCase: any CancelStudyRoomSeatUseCase {
CancelStudyRoomSeatUseCaseImpl(studyRoomsRepository: studyRoomsRepository)
}

var fehtchMyStudyRoomAppItemsUseCase: any FetchMyStudyRoomAppItemsUseCase {
FetchMyStudyRoomAppItemsUseCaseImpl(studyRoomsRepository: studyRoomsRepository)
}
}
1 change: 1 addition & 0 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ extension AppComponent: Registration {
localTable["fetchDetailStudyRoomUseCase-any FetchDetailStudyRoomUseCase"] = { [unowned self] in self.fetchDetailStudyRoomUseCase as Any }
localTable["applyStudyRoomSeatUseCase-any ApplyStudyRoomSeatUseCase"] = { [unowned self] in self.applyStudyRoomSeatUseCase as Any }
localTable["cancelStudyRoomSeatUseCase-any CancelStudyRoomSeatUseCase"] = { [unowned self] in self.cancelStudyRoomSeatUseCase as Any }
localTable["fehtchMyStudyRoomAppItemsUseCase-any FetchMyStudyRoomAppItemsUseCase"] = { [unowned self] in self.fehtchMyStudyRoomAppItemsUseCase as Any }
localTable["localAuthDataSource-any LocalAuthDataSource"] = { [unowned self] in self.localAuthDataSource as Any }
localTable["remoteAuthDataSource-any RemoteAuthDataSource"] = { [unowned self] in self.remoteAuthDataSource as Any }
localTable["authRepository-any AuthRepository"] = { [unowned self] in self.authRepository as Any }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import RemainApplyFeature
import SwiftUI

struct ApplyPageView: View {
@AppStorage("StudyRoomState") var studyRoomState: String?
@AppStorage("RemainState") var remainState: String?
@StateObject var viewModel: ApplyPageViewModel
@Environment(\.tabbarHidden) var tabbarHidden

Expand Down Expand Up @@ -32,25 +30,25 @@ struct ApplyPageView: View {
Spacer()
.frame(height: 5)

applyListCellView(
ApplyListCellView(
name: "자습실",
content: """
자습실 사용이 필요한 경우, 자습실 신청을 통해서 원하는 자리를 신청해 보세요.
""",
buttonTitle: "자습실 신청하기",
applyState: studyRoomState,
applyState: viewModel.studyRoomState,
onTapped: {
viewModel.isNavigateToStudy.toggle()
}
)

applyListCellView(
ApplyListCellView(
name: "잔류",
content: """
주말 기숙사 잔류 여부를 확인하고, 잔류 신청을 통해서 잔류 또는 귀가를 신청해 보세요.
""",
buttonTitle: "잔류 신청하기",
applyState: remainState,
applyState: viewModel.remainState,
onTapped: {
viewModel.isNavigateToRemain.toggle()
}
Expand All @@ -62,6 +60,10 @@ struct ApplyPageView: View {
.navigationTitle("신청")
.navigationBarTitleDisplayMode(.inline)
.dmsBackground()
.onAppear {
// viewModel.fehtchMyStudyRoomApplicationItems()
// viewModel.fetchMyRemainApplicationItems()
}
.onChange(of: viewModel.isNavigateToStudy) { newValue in
withAnimation {
tabbarHidden.wrappedValue = newValue
Expand All @@ -83,21 +85,4 @@ struct ApplyPageView: View {
.navigationViewStyle(.stack)
}
}

@ViewBuilder
func applyListCellView(
name: String,
content: String,
buttonTitle: String,
applyState: String?,
onTapped: @escaping () -> Void
) -> some View {
ApplyListCellView(
name: name,
content: content,
buttonTitle: buttonTitle,
applyState: applyState,
onTapped: onTapped
)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,56 @@
import BaseFeature
import DomainModule
import DataMappingModule
import Combine
import SwiftUI

final class ApplyPageViewModel: BaseViewModel {
@Published var isNavigateToStudy: Bool = false
@Published var isNavigateToRemain: Bool = false

@Published var myRemainApplicationItem: MyRemainApplicationItemsEntity?
@Published var myStudyRoomApplicationItems: MyStudyRoomAppItemsEntity?

// private let fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase
// private let fehtchMyStudyRoomAppItemsUserCase: any FetchMyStudyRoomAppItemsUserCase

var remainState: String? {
if let item = myRemainApplicationItem {
return item.title
} else {
return nil
}
}

var studyRoomState: String? {
if let item = myStudyRoomApplicationItems {
return item.floor + "층 " + item.name
} else {
return nil
}
}
//
// public init(
// fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase,
// fehtchMyStudyRoomAppItemsUserCase: any FetchMyStudyRoomAppItemsUserCase
// ) {
// self.fetchMyRemainApplicationItemsUseCase = fetchMyRemainApplicationItemsUseCase
// self.fehtchMyStudyRoomAppItemsUserCase = fehtchMyStudyRoomAppItemsUserCase
// }

// func fetchMyRemainApplicationItems() {
// addCancellable(
// fetchMyRemainApplicationItemsUseCase.execute()
// ) { [weak self] myRemainApplicationItem in
// self?.myRemainApplicationItem = myRemainApplicationItem
// }
// }
//
// func fehtchMyStudyRoomApplicationItems() {
// addCancellable(
// fehtchMyStudyRoomAppItemsUserCase.execute()
// ) { [weak self] myStudyRoomApplicationItems in
// self?.myStudyRoomApplicationItems = myStudyRoomApplicationItems
// }
// }
HongSJae marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import RemainApplyFeature
import DesignSystem

struct ApplyListCellView: View {
@AppStorage("StudyRoomState") var studyRoomState: String?
@AppStorage("RemainState") var remainState: String?
var name: String
var content: String
var buttonTitle: String
Expand Down Expand Up @@ -37,15 +35,17 @@ struct ApplyListCellView: View {

Spacer()

Text(applyState ?? "")
.dmsFont(.etc(.button), color: .PrimaryVariant.primary)
.frame(height: 22)
.padding(.vertical, 6)
.padding(.horizontal, 14)
.background(Color.PrimaryVariant.lighten2)
.cornerRadius(24)
.padding(.trailing, 16)
.padding(.top, -2)
if let applyState {
Text(applyState)
.dmsFont(.etc(.button), color: .PrimaryVariant.primary)
.frame(height: 22)
.padding(.vertical, 6)
.padding(.horizontal, 14)
.background(Color.PrimaryVariant.lighten2)
.cornerRadius(24)
.padding(.trailing, 16)
.padding(.top, -2)
}
}

Text(content)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,78 +1,38 @@
import DesignSystem
import DomainModule
import SwiftUI
import DomainModule
import DesignSystem

struct RemainApplyListCellView: View {
@StateObject var viewModel: RemainApplyViewModel

let dummy1 = RemainOptionEntity(
id: "0",
title: "금요 귀가",
description: """
금요일 일과가 모두 끝나고
8시 30분 이후부터9시 30분까지 귀가하고
일요일 6시 30분 부터 9시 30분까지 귀사해야 합니다.

혹시나 개인 일정으로 부득이하기 금요일이 아닌, 토요일
또는 일요일에 귀가해야 하는 학생들은 사감 선생님께
말씀부탁드립니다.
"""
)
let dummy2 = RemainOptionEntity(
id: "1",
title: "토요 귀가",
description: """
금요일 일과가 모두 끝나고
8시 30분 이후부터9시 30분까지 귀가하고
일요일 6시 30분 부터 9시 30분까지 귀사해야 합니다.

혹시나 개인 일정으로 부득이하기 금요일이 아닌, 토요일
또는 일요일에 귀가해야 하는 학생들은 사감 선생님께
말씀부탁드립니다.
"""
)
let dummy3 = RemainOptionEntity(
id: "2",
title: "잔류",
description: """
금요일 일과가 모두 끝나고
8시 30분 이후부터9시 30분까지 귀가하고
일요일 6시 30분 부터 9시 30분까지 귀사해야 합니다.

혹시나 개인 일정으로 부득이하기 금요일이 아닌, 토요일
또는 일요일에 귀가해야 하는 학생들은 사감 선생님께
말씀부탁드립니다.
"""
)

var body: some View {
VStack(spacing: 12) {
remainApplyListCellView(list: dummy1, applyType: .friday)

remainApplyListCellView(list: dummy2, applyType: .saturday)

remainApplyListCellView(list: dummy3, applyType: .stay)
}
@State private var isShowingDetail = false
var list: RemainOptionEntity
let isSelected: Bool
let action: () -> Void
public init(
list: RemainOptionEntity,
isSelected: Bool,
action: @escaping () -> Void
) {
self.list = list
self.isSelected = isSelected
self.action = action
}

@ViewBuilder
// swiftlint:disable function_body_length
func remainApplyListCellView(list: RemainOptionEntity, applyType: ApplyType) -> some View {
VStack {
var body: some View {
VStack(alignment: .leading) {
HStack(alignment: .center) {
Button(action: {
viewModel.selectedType = list.title
viewModel.selectedNum = Int(list.id) ?? 10
if !isSelected {
action()
}
}, label: {
HStack {
Text(list.title)
.dmsFont(.title(.title2), color: viewModel.selectedNum == applyType.rawValue
.dmsFont(.title(.title2), color: isSelected
? .System.primary : .GrayScale.gray7)
.frame(height: 32)
.padding(.vertical, 14)
.padding(.horizontal, 20)

if viewModel.isAlreadyApplied == true && viewModel.appliedNum == applyType.rawValue {
if list.isApplied {
Text("신청 완료")
.dmsFont(.etc(.button), color: .PrimaryVariant.primary)
.frame(height: 22)
Expand All @@ -85,19 +45,23 @@ struct RemainApplyListCellView: View {

Spacer()

Image(systemName: viewModel.isDetailTapped == true && viewModel.selectedNum == applyType.rawValue
? "chevron.up" : "chevron.down")
.foregroundColor(viewModel.selectedNum == applyType.rawValue
Image(systemName: "chevron.down")
.foregroundColor(isSelected
? .System.primary : .GrayScale.gray7)
.padding(.trailing, 25)
.rotationEffect(
isShowingDetail
HongSJae marked this conversation as resolved.
Show resolved Hide resolved
? Angle.degrees(180)
: .degrees(0)
)
.padding(25)
.onTapGesture {
viewModel.selectedNum = applyType.rawValue
viewModel.selectedType = list.title
viewModel.isDetailTapped.toggle()
withAnimation {
isShowingDetail.toggle()
}
}
})
}
if viewModel.isDetailTapped == true && viewModel.selectedNum == applyType.rawValue {
if isShowingDetail {
Text(list.description)
.multilineTextAlignment(.leading)
.dmsFont(.body(.body3), color: .GrayScale.gray9)
Expand All @@ -109,17 +73,11 @@ struct RemainApplyListCellView: View {
.overlay(
RoundedRectangle(cornerRadius: 10)
.inset(by: 1)
.stroke(viewModel.selectedNum == applyType.rawValue ?
Color.System.primary : .clear, lineWidth: 1.5)
.stroke(isSelected ?
Color.System.primary : .clear,
lineWidth: 1.5)
)
.padding(.bottom, 12)
.dmsShadow(style: .surface)
}
// swiftlint:enable function_body_length
}

enum ApplyType: Int {
case friday = 0
case saturday
case stay
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import DesignSystem
import DomainModule
import SwiftUI

struct RemainApplyListView: View {
@StateObject var viewModel: RemainApplyViewModel

var body: some View {
LazyVStack(spacing: 12) {
ForEach(viewModel.remainApplicationList.remainOptions, id: \.self) { remainApplication in
RemainApplyListCellView(
list: remainApplication,
isSelected: remainApplication.id == viewModel.selectedEntity?.id,
action: {
viewModel.selectedEntity = remainApplication
}
)
}
}
.onAppear {
viewModel.fetchRemainApplicationList()
}
}
}
Loading