Skip to content

Commit

Permalink
♻️ :: [#127] SwiftFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
uuuunseo committed Jan 21, 2024
1 parent 4f3dd26 commit 63019d9
Show file tree
Hide file tree
Showing 29 changed files with 207 additions and 125 deletions.
6 changes: 3 additions & 3 deletions App/Sources/Application/DI/User/AppComponent+User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ public extension AppComponent {
RemoteUserDataSourceImpl(keychain: keychain)
}
}

var userRepository: any UserRepository {
shared {
UserRepositoryImpl(remoteUserDataSource: remoteUserDataSource)
}
}

var changePasswordUseCase: any ChangePasswordUseCase {
shared {
ChangePasswordUseCaseImpl(userRepository: userRepository)
}
}

var queryMyInfoUseCase: any QueryMyInfoUseCase {
shared {
QueryMyInfoUseCaseImpl(userRepository: userRepository)
Expand Down
162 changes: 119 additions & 43 deletions App/Sources/Application/NeedleGenerated.swift

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ struct ActivityListView: View {
@Environment(\.dismiss) var dismiss
@StateObject var model: ActivityListModel
@StateObject var viewModel: ActivityListViewModel

private let inputActivityFactory: any InputActivityFactory

init(
inputActivityFactory: any InputActivityFactory,
model: ActivityListModel,
Expand All @@ -17,7 +17,7 @@ struct ActivityListView: View {
_model = StateObject(wrappedValue: model)
_viewModel = StateObject(wrappedValue: viewModel)
}

var body: some View {
NavigationView {
ScrollView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import SwiftUI

struct InputActivityView: View {
@StateObject var viewModel: InputActivityViewModel

init(viewModel: InputActivityViewModel) {
_viewModel = StateObject(wrappedValue: viewModel)
}

var body: some View {
ScrollView {
VStack(spacing: 0) {
Expand All @@ -33,9 +33,9 @@ struct InputActivityView: View {
}
.padding(.top, -40)
.frame(minHeight: 40, maxHeight: 120)

Divider()

VStack {
TextEditor(text: Binding(
get: { viewModel.activityText },
Expand All @@ -59,18 +59,18 @@ struct InputActivityView: View {
}
.padding(.top, 16)
.frame(height: 460)

Divider()

VStack(spacing: 8) {
Button {} label: {
Spacer()

BitgouelAsset.Icons.setting.swiftUIImage

Text("활동 세부 설정")
.bitgouelFont(.text3, color: .primary(.p5))

Spacer()
}
.padding(.vertical, 12)
Expand All @@ -79,7 +79,7 @@ struct InputActivityView: View {
RoundedRectangle(cornerRadius: 8)
.strokeBorder(Color.bitgouel(.primary(.p5)))
}

CTAButton(
text: "활동 추가",
style: .default
Expand Down
11 changes: 5 additions & 6 deletions App/Sources/Feature/StudentSignUpFeature/StudentSignUpView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SwiftUI
import Service
import SwiftUI

struct StudentSignUpView: View {
@StateObject var viewModel: StudentSignUpViewModel
Expand Down Expand Up @@ -226,7 +226,6 @@ struct StudentSignUpView: View {
AssociationSelectButton(text: viewModel.selectedAssociation?.associationValue() ?? "소속") {
viewModel.isPresentedAssociationSheet = true
}

}
}

Expand Down Expand Up @@ -324,13 +323,13 @@ struct StudentSignUpView: View {
.padding(.bottom, -20)
}
}

@ViewBuilder
func userRoleTypeView() -> some View {
ScrollView {
let data: [UserAuthorityType] = viewModel.selectedAssociation == .school
? [.student, .teacher]
: [.companyInstructor, .professor, .bbozzack, .government]
? [.student, .teacher]
: [.companyInstructor, .professor, .bbozzack, .government]
ForEach(data, id: \.self) { userRole in
HStack {
Text(userRole.display())
Expand All @@ -354,7 +353,7 @@ struct StudentSignUpView: View {
}
}
}

@ViewBuilder
func associationTypeView() -> some View {
ScrollView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class StudentSignUpViewModel: BaseViewModel {
@Published var isPresentedUserRoleSheet = false
@Published var isPresentedSchoolSheet = false
@Published var isPresentedClubSheet = false

// MARK: variable
@Published var schoolSearch = ""
@Published var clubSearch = ""
Expand All @@ -29,34 +29,39 @@ class StudentSignUpViewModel: BaseViewModel {
@Published var studentID: String = ""
@Published var selectedAssociation: AssociationType?
@Published var selectedUserRole: UserAuthorityType?

// MARK: computed property
var clubsForSelectedHighSchool: [String] {
selectedSchool?.getClubsForSelectedHighSchool() ?? []
}

// MARK: validation
var nameIsValid: Bool {
name.count >= 2
}

var yearOfAdmissionIsValid: Bool {
(yearOfAdmission ?? 0) >= 1000
}

var studentIDIsValid: Bool {
studentID.count == 4 && grade != nil && classRoom != nil && number != nil
}

var phoneNumberIsValid: Bool {
phoneNumber.count == 11
}

var emailIsValid: Bool {
let emailRegex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}"
return NSPredicate(format: "SELF MATCHES %@", emailRegex).evaluate(with: email)
}

var passwordIsValid: Bool {
let passwordRegex = "[A-Z0-9a-z@!#$%%^~&*()_+-=.]{8,24}"
return NSPredicate(format: "SELF MATCHES %@", passwordRegex).evaluate(with: password)
}

// MARK: usecase
private let studentSignupUseCase: StudentSignupUseCase
private let teacherSignupUseCase: TeacherSignupUseCase
Expand Down Expand Up @@ -229,7 +234,7 @@ class StudentSignUpViewModel: BaseViewModel {
return "비밀번호를 다시 입력해 주세요!"
}
}

func parseStudentID() {
if studentID.count == 4 {
grade = Int(studentID.prefix(1))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SwiftUI
import Service
import SwiftUI

struct SchoolListView: View {
let searchKeyword: Binding<String>
Expand All @@ -18,7 +18,11 @@ struct SchoolListView: View {
ScrollView {
LazyVStack {
ForEach(schoolList, id: \.self) { school in
SchoolListRowView(school: school, selectedSchool: selectedSchool, onHighSchoolSelect: onHighSchoolSelect)
SchoolListRowView(
school: school,
selectedSchool: selectedSchool,
onHighSchoolSelect: onHighSchoolSelect
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ public final class RemotePostDataSourceImpl: BaseRemoteDataSource<PostAPI>, Remo
public func writePost(req: InputPostRequestDTO) async throws {
try await request(.writePost(req: req))
}

public func queryPostList() async throws -> [PostEntity] {
try await request(.queryPostList, dto: PostListsResponseDTO.self).toDomain()
}

public func queryPostDetail(postID: String) async throws -> PostDetailEntity {
try await request(.queryPostDetail(postID: postID), dto: PostDetailResponseDTO.self).toDomain()
}

public func updatePost(postID: String, req: InputPostRequestDTO) async throws {
try await request(.updatePost(postID: postID, req: req))
}

public func deletePost(postID: String) async throws {
try await request(.deletePost(postID: postID))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Foundation

public final class RemoteUserDataSourceImpl: BaseRemoteDataSource<UserAPI>, RemoteUserDataSource {

public func changePassword(req: ChangePasswordRequestDTO) async throws {
try await request(.changePassword(req))
}

public func queryMyInfo() async throws -> MyInfoEntity {
try await request(.queryMyInfo, dto: QueryMyInfoResponseDTO.self).toDomain()
}
Expand Down
12 changes: 6 additions & 6 deletions Service/Sources/Data/Repository/Post/PostRepositoryImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ import Foundation

public struct PostRepositoryImpl: PostRepository {
private let remotePostDataSource: RemotePostDataSource

public init(remotePostDataSource: RemotePostDataSource) {
self.remotePostDataSource = remotePostDataSource
}

public func writePost(req: InputPostRequestDTO) async throws {
try await remotePostDataSource.writePost(req: req)
}

public func queryPostList() async throws -> [PostEntity] {
try await remotePostDataSource.queryPostList()
}

public func queryPostDetail(postID: String) async throws -> PostDetailEntity {
try await remotePostDataSource.queryPostDetail(postID: postID)
}

public func updatePost(postID: String, req: InputPostRequestDTO) async throws {
try await remotePostDataSource.updatePost(postID: postID, req: req)
}

public func deletePost(postID: String) async throws {
try await remotePostDataSource.deletePost(postID: postID)
}
Expand Down
6 changes: 3 additions & 3 deletions Service/Sources/Data/Repository/User/UserRepositoryImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import Foundation

public struct UserRepositoryImpl: UserRepository {
private let remoteUserDataSource: RemoteUserDataSource

public init(remoteUserDataSource: RemoteUserDataSource) {
self.remoteUserDataSource = remoteUserDataSource
}

public func changePassword(req: ChangePasswordRequestDTO) async throws {
try await remoteUserDataSource.changePassword(req: req)
}

public func queryMyInfo() async throws -> MyInfoEntity {
try await remoteUserDataSource.queryMyInfo()
}
Expand Down
4 changes: 2 additions & 2 deletions Service/Sources/Data/UseCase/Post/DeletePostUseCaseImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Foundation

public struct DeletePostUseCaseImpl: DeletePostUseCase {
private let postRepository: any PostRepository

public init(postRepository: any PostRepository) {
self.postRepository = postRepository
}

public func callAsFunction(postID: String) async throws {
try await postRepository.deletePost(postID: postID)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Foundation

public struct QueryPostDetailUseCaseImpl: QueryPostDetailUseCase {
private let postRepository: any PostRepository

public init(postRepository: any PostRepository) {
self.postRepository = postRepository
}

public func callAsFunction(postID: String) async throws -> PostDetailEntity {
try await postRepository.queryPostDetail(postID: postID)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Foundation

public struct QueryPostListUseCaseImpl: QueryPostListUseCase {
private let postRepository: any PostRepository

public init(postRepository: any PostRepository) {
self.postRepository = postRepository
}

public func callAsFunction() async throws -> [PostEntity] {
try await postRepository.queryPostList()
}
Expand Down
4 changes: 2 additions & 2 deletions Service/Sources/Data/UseCase/Post/UpdatePostUseCaseImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Foundation

public struct UpdatePostUseCaseImpl: UpdatePostUseCase {
private let postRepository: any PostRepository

public init(postRepository: any PostRepository) {
self.postRepository = postRepository
}

public func callAsFunction(postID: String, req: InputPostRequestDTO) async throws {
try await postRepository.updatePost(postID: postID, req: req)
}
Expand Down
4 changes: 2 additions & 2 deletions Service/Sources/Data/UseCase/Post/WritePostUseCaseImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Foundation

public struct WritePostUseCaseImpl: WritePostUseCase {
private let postRepository: any PostRepository

public init(postRepository: any PostRepository) {
self.postRepository = postRepository
}

public func callAsFunction(req: InputPostRequestDTO) async throws {
try await postRepository.writePost(req: req)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Foundation

public struct ChangePasswordUseCaseImpl: ChangePasswordUseCase {
private let userRepository: any UserRepository

public init(userRepository: any UserRepository) {
self.userRepository = userRepository
}

public func callAsFunction(req: ChangePasswordRequestDTO) async throws {
try await userRepository.changePassword(req: req)
}
Expand Down
Loading

0 comments on commit 63019d9

Please sign in to comment.