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

๐Ÿ”€ :: ๋ฉ”์ธ ํŽ˜์ด์ง€ refresh ๊ธฐ๋Šฅ ์ถ”๊ฐ€ #214

Merged
merged 4 commits into from
Jun 19, 2023
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
2 changes: 1 addition & 1 deletion Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ private func registerProviderFactory(_ componentPath: String, _ factory: @escapi

#if !NEEDLE_DYNAMIC

@inline(never) private func register1() {
private func register1() {
registerProviderFactory("^->AppComponent->JwtStoreComponent", factoryb27d5aae1eb7e73575a6f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent", factoryEmptyDependencyProvider)
registerProviderFactory("^->AppComponent->KeychainComponent", factoryEmptyDependencyProvider)
Expand Down
12 changes: 12 additions & 0 deletions Projects/Feature/MainFeature/Sources/Intent/MainIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ final class MainIntent: MainIntentProtocol {
}
}

func refresh() {
model?.updateIsRefresh(isRefresh: true)
Task {
let studentList = try await fetchStudentListUseCase.execute(req: .init(page: 1, size: 20))
model?.updateContent(content: studentList.studentList)
model?.updatePage(page: 2)
model?.updateTotalSize(totalSize: studentList.totalSize)
model?.updateIsLast(isLast: false)
model?.updateIsRefresh(isRefresh: false)
}
}

func existActionSheetIsRequired() {
model?.updateIsPresentedExistActionSheet(isPresented: true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import StudentDomainInterface

protocol MainIntentProtocol {
func reachedBottom(page: Int, isLast: Bool)
func refresh()
func existActionSheetIsRequired()
func existActionSheetDismissed()
func logoutDialogIsRequired()
Expand Down
11 changes: 10 additions & 1 deletion Projects/Feature/MainFeature/Sources/Model/MainModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ final class MainModel: ObservableObject, MainStateProtocol {
@Published var totalSize: Int = 0
@Published var isLast: Bool = false
@Published var isError: Bool = false
@Published var isRefresh: Bool = false
@Published var isPresentedExistActionSheet: Bool = false
@Published var isPresentedLogoutDialog: Bool = false
@Published var isPresentedWithdrawalDialog: Bool = false
Expand Down Expand Up @@ -65,10 +66,18 @@ extension MainModel: MainActionProtocol {
self.content.append(contentsOf: content)
}

func updateContent(content: [SingleStudentEntity]) {
self.content = content
}

func updateSelectedUserID(userID: String?) {
self.selectedUserID = userID
}


func updateIsRefresh(isRefresh: Bool) {
self.isRefresh = isRefresh
}

func updateUserRole(role: UserRoleType) {
self.currentUserRole = role
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ protocol MainStateProtocol {
var totalSize: Int { get }
var isLast: Bool { get }
var isError: Bool { get }
var isRefresh: Bool { get }
var isPresentedExistActionSheet: Bool { get }
var isPresentedLogoutDialog: Bool { get }
var isPresentedWithdrawalDialog: Bool { get }
Expand All @@ -23,6 +24,8 @@ protocol MainActionProtocol: AnyObject {
func updateIsPresentedLogoutDialog(isPresented: Bool)
func updateIsPresentedWithdrawalDialog(isPresented: Bool)
func appendContent(content: [SingleStudentEntity])
func updateContent(content: [SingleStudentEntity])
func updateIsRefresh(isRefresh: Bool)
func updateSelectedUserID(userID: String?)
func updateUserRole(role: UserRoleType)
}
7 changes: 6 additions & 1 deletion Projects/Feature/MainFeature/Sources/Scene/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ struct MainView: View {

Color.clear
.onAppear {
guard !state.isRefresh else { return }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์–ด ์ด๊ฑฐ ์„ฑ๊ณตํ•œ๊ฑด๊ฐ€์š”

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ค ์ €๊ฑฐ ์•ˆ ํ•˜๋ฉด reachedBottom์ด๋ž‘ ๋™์‹œ์— ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค

intent.reachedBottom(page: state.page, isLast: state.isLast)
}
}
}
.refreshable {
intent.refresh()
}
.overlay(alignment: .bottomTrailing) {
floatingButton {
withAnimation(.default) {
Expand Down Expand Up @@ -160,7 +164,8 @@ struct MainView: View {
.init(text: "์ทจ์†Œ") {
intent.logoutDialogDismissed()
}
])
]
)
.smsAlert(
title: "ํšŒ์›ํƒˆํ‡ด",
description: "์ •๋ง๋กœ ํšŒ์›ํƒˆํ‡ด ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?",
Expand Down