Skip to content

Commit

Permalink
Merge pull request #19 from Student-Center/feature/WEAV-46
Browse files Browse the repository at this point in the history
[WEAV-46] Design Component 구현
  • Loading branch information
jisu15-kim authored Sep 22, 2024
2 parents 812bbe9 + 375641f commit e4fa962
Show file tree
Hide file tree
Showing 63 changed files with 1,369 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "logo.png",
"filename" : "appicon.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
2 changes: 1 addition & 1 deletion Projects/App/Sources/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public struct ContentView: View {
MainView()

SampleComponent()
.foregroundStyle(DesignCore.red300)
.foregroundStyle(DesignCore.Colors.red300)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Projects/App/Sources/ThreeDaysApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct ThreeDaysApp: App {
}
.buttonStyle(BorderedProminentButtonStyle())
.typography(.semibold_14)
.tint(DesignCore.grey300)
.tint(DesignCore.Colors.grey300)
}
#endif
}
37 changes: 37 additions & 0 deletions Projects/Core/CoreKit/Sources/String+Ext.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// String+Ext.swift
// CoreKit
//
// Created by 김지수 on 9/21/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import Foundation

extension String {
/// 한국 휴대폰 번호 형식에 맞는지 체크(8자리)
public func isValidPhoneNumber() -> Bool {
let number = self.replacingOccurrences(of: "-", with: "")
let pattern = "^010\\d{8}$"
let regex = try? NSRegularExpression(pattern: pattern)
let range = NSRange(location: 0, length: number.utf16.count)
return regex?.firstMatch(in: number, options: [], range: range) != nil

}

public func formattedPhoneNumber() -> String {
let onlyNumbers = self.filter { $0.isNumber }

let firstPart = String(onlyNumbers.prefix(3))
let secondPart = String(onlyNumbers.dropFirst(3).prefix(4))
let thirdPart = String(onlyNumbers.dropFirst(7).prefix(4))

if onlyNumbers.count <= 3 {
return firstPart
} else if onlyNumbers.count <= 7 {
return "\(firstPart)-\(secondPart)"
} else {
return "\(firstPart)-\(secondPart)-\(thirdPart)"
}
}
}
25 changes: 25 additions & 0 deletions Projects/Core/CoreKit/Sources/UIApplication+Ext.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// UIApplication+Ext.swift
// CoreKit
//
// Created by 김지수 on 9/21/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import UIKit

extension UIApplication {
public func hideKeyboard() {
guard let window = windows.first else { return }
let tapRecognizer = UITapGestureRecognizer(target: window, action: #selector(UIView.endEditing))
tapRecognizer.cancelsTouchesInView = false
tapRecognizer.delegate = self
window.addGestureRecognizer(tapRecognizer)
}
}

extension UIApplication: UIGestureRecognizerDelegate {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return false
}
}
27 changes: 0 additions & 27 deletions Projects/Core/CoreKit/UnitTest/CoreKitTest.swift

This file was deleted.

157 changes: 157 additions & 0 deletions Projects/Core/CoreKit/UnitTest/StringExtensionText.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
//
// StringExtensionText.swift
// CoreKit-UnitTest
//
// Created by 김지수 on 9/21/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import XCTest
@testable import CoreKit

final class PhoneNumberTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

// 전화번호 검증 성공
func testValidPhoneNumber() {
// 유효한 번호 (하이픈 없는 11자리 번호)
XCTAssertTrue(
"01012345678".isValidPhoneNumber(),
"유효한 번호 형식임에도 불구하고 false가 반환됨"
)
}

// 전화번호 검증 실패
func testInvalidPhoneNumber() {
// 유효하지 않은 번호 (형식이 잘못된 경우)
XCTAssertFalse(
"01112345678".isValidPhoneNumber(),
"유효하지 않은 번호 형식임에도 불구하고 true가 반환됨"
)
XCTAssertFalse(
"0101234567".isValidPhoneNumber(),
"유효하지 않은 번호 형식임에도 불구하고 true가 반환됨"
)
XCTAssertFalse(
"010123456789".isValidPhoneNumber(),
"유효하지 않은 번호 형식임에도 불구하고 true가 반환됨"
)
XCTAssertFalse(
"010-1234-5678".isValidPhoneNumber(),
"하이픈이 포함된 경우 유효하지 않은 번호 형식임에도 불구하고 true가 반환됨"
)

// 텍스트가 포함된 경우
XCTAssertFalse(
"010a2345678".isValidPhoneNumber(),
"문자가 포함된 경우에도 유효한 번호로 처리되고 있음"
)
XCTAssertFalse(
"010123456a8".isValidPhoneNumber(),
"끝에 문자가 포함된 경우에도 유효한 번호로 처리되고 있음"
)
XCTAssertFalse(
"a1012345678".isValidPhoneNumber(),
"번호 앞에 문자가 포함된 경우에도 유효한 번호로 처리되고 있음"
)
}

// 전화번호 "-" 붙이기 케이스
func testFormattedPhoneNumberAddHyphen() {
XCTAssertEqual(
"01012345678".formattedPhoneNumber(),
"010-1234-5678",
"포맷된 번호가 예상과 다릅니다."
)

XCTAssertEqual(
"010123456".formattedPhoneNumber(),
"010-1234-56",
"포맷된 번호가 예상과 다릅니다."
)

XCTAssertEqual(
"0104444".formattedPhoneNumber(),
"010-4444",
"포맷된 번호가 예상과 다릅니다."
)

XCTAssertEqual(
"010".formattedPhoneNumber(),
"010",
"포맷된 번호가 예상과 다릅니다."
)

XCTAssertEqual(
"01042".formattedPhoneNumber(),
"010-42",
"포맷된 번호가 예상과 다릅니다."
)

XCTAssertEqual(
"01".formattedPhoneNumber(),
"01",
"포맷된 번호가 예상과 다릅니다."
)
// 10자리 입력
XCTAssertEqual(
"0101234567".formattedPhoneNumber(),
"010-1234-567",
"포맷된 번호가 예상과 다릅니다."
)

// 7자리 입력
XCTAssertEqual(
"0101234".formattedPhoneNumber(),
"010-1234",
"포맷된 번호가 예상과 다릅니다."
)

// 6자리 입력
XCTAssertEqual(
"010123".formattedPhoneNumber(),
"010-123",
"포맷된 번호가 예상과 다릅니다."
)

// 5자리 입력
XCTAssertEqual(
"01012".formattedPhoneNumber(),
"010-12",
"포맷된 번호가 예상과 다릅니다."
)

// 4자리 입력
XCTAssertEqual(
"0101".formattedPhoneNumber(),
"010-1",
"포맷된 번호가 예상과 다릅니다."
)

// 3자리 입력
XCTAssertEqual(
"010".formattedPhoneNumber(),
"010",
"포맷된 번호가 예상과 다릅니다."
)

// 2자리 이하 입력
XCTAssertEqual(
"01".formattedPhoneNumber(),
"01",
"포맷된 번호가 예상과 다릅니다."
)
XCTAssertEqual(
"0".formattedPhoneNumber(),
"0",
"포맷된 번호가 예상과 다릅니다."
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "255",
"green" : "140",
"red" : "64"
"blue" : "247",
"green" : "155",
"red" : "94"
}
},
"idiom" : "universal"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "165",
"green" : "219",
"red" : "223"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "241",
"green" : "242",
"red" : "242"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "196",
"green" : "177",
"red" : "230"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "165",
"green" : "219",
"red" : "223"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit e4fa962

Please sign in to comment.