-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from Student-Center/feature/WEAV-46
[WEAV-46] Design Component 구현
- Loading branch information
Showing
63 changed files
with
1,369 additions
and
64 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
Projects/App/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
157 changes: 157 additions & 0 deletions
157
Projects/Core/CoreKit/UnitTest/StringExtensionText.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
"포맷된 번호가 예상과 다릅니다." | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
.../DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Green100.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
...ts/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey50.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...s/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Pink100.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
...DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Yellow100.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
Projects/DesignSystem/DesignCore/Resources/Images/Images.xcassets/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.