Skip to content

Commit

Permalink
Merge pull request #140 from boostcampwm-2024/fix/handleObject
Browse files Browse the repository at this point in the history
[Fix] 오브젝트 수정 기능 QA 반영
  • Loading branch information
taipaise authored Dec 3, 2024
2 parents 13a4908 + 85e4cd7 commit 371a773
Show file tree
Hide file tree
Showing 17 changed files with 379 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ extension WhiteboardRepository: NearbyNetworkConnectionDelegate {
do {
guard
isHost,
let context = context,
let prevInfo = self.participantsInfo["participants"]
let context = context
else { return }

let decodedContext = try JSONDecoder().decode(RequestedContext.self, from: context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public protocol PhotoRepositoryInterface {
/// id: 사진의 id
/// imageData: 사진 이미지 데이터
/// - Returns: 저장한 위치 URL
@discardableResult
func savePhoto(id: UUID, imageData: Data) -> URL?

/// 저장된 사진을 가져옵니다
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@ public protocol ManageWhiteboardObjectUseCaseInterface {
whiteboardObjectID: UUID,
scale: CGFloat,
angle: CGFloat) async -> Bool

/// 화이트보드 오브젝트들을 모두 삭제합니다.
func removeAllWhiteboardObjects()
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public protocol WhiteboardObjectSetInterface {
/// - Parameter object: 삭제할 오브젝트
func remove(object: WhiteboardObject) async

/// 모든 화이트보드 오브젝트들을 삭제합니다.
func removeAll() async

/// 집합에 있는 오브젝트를 업데이트 합니다.
/// - Parameter object: 업데이트할 오브젝트
func update(object: WhiteboardObject) async
Expand Down
4 changes: 4 additions & 0 deletions Domain/Domain/Sources/Model/WhiteboardObjectSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public actor WhiteboardObjectSet: WhiteboardObjectSetInterface {
whiteboardObjects.remove(object)
}

public func removeAll() async {
whiteboardObjects.removeAll()
}

public func update(object: WhiteboardObject) {
remove(object: object)
insert(object: object)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ public final class ManageWhiteboardObjectUseCase: ManageWhiteboardObjectUseCaseI
}
}
}

public func removeAllWhiteboardObjects() {
Task {
await whiteboardObjectSet.removeAll()
}
}
}

extension ManageWhiteboardObjectUseCase: WhiteboardObjectRepositoryDelegate {
Expand Down
2 changes: 2 additions & 0 deletions Domain/Domain/Sources/UseCase/PhotoUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public final class PhotoUseCase: PhotoUseCaseInterface {
) -> PhotoObject? {
let id = UUID()

photoRepository.savePhoto(id: id, imageData: imageData)

var size = size
let scaleFactor = size.width >= size.height ? 200 / size.width : 200 / size.height
size.width *= scaleFactor
Expand Down
2 changes: 1 addition & 1 deletion Domain/Domain/Sources/UseCase/TextObjectUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class TextObjectUseCase: TextObjectUseCaseInterface {
id: UUID(),
centerPosition: point,
size: textFieldDefaultSize,
text: "Hello, AirplaIN!")
text: "")
}

public func editText(id: UUID, text: String) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ extension NearbyNetworkService: MCSessionDelegate {
didReceive data: Data,
fromPeer peerID: MCPeerID
) {
guard let connection = connectedPeers[peerID] else {
guard connectedPeers[peerID] != nil else {
logger.log(level: .error, "\(peerID.displayName)와 연결되어 있지 않음")
return
}
Expand Down
132 changes: 72 additions & 60 deletions Presentation/Presentation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
0080E8CA2CE2FF750095B958 /* WhiteboardObjectViewFactoryable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0080E8C92CE2FF6E0095B958 /* WhiteboardObjectViewFactoryable.swift */; };
0080E8D12CE4A00F0095B958 /* WhiteboardViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0080E8D02CE4A0060095B958 /* WhiteboardViewModel.swift */; };
0080E8D32CE4A0840095B958 /* ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0080E8D22CE4A0820095B958 /* ViewModel.swift */; };
00C2950B2CFDF14700BD6768 /* AirplainTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00C2950A2CFDF14700BD6768 /* AirplainTextField.swift */; };
00CCC2672CE60BCD005FA747 /* AirplainFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8525DC72CE201D50089DA5E /* AirplainFont.swift */; };
00D2DD982CE8CD300089F0BA /* DrawingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00D2DD972CE8CD300089F0BA /* DrawingView.swift */; };
00D2DD9A2CE8DCEA0089F0BA /* DrawingObjectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00D2DD992CE8DCEA0089F0BA /* DrawingObjectView.swift */; };
Expand All @@ -25,6 +26,13 @@
6F199EF32CE3203A005DC40F /* WhiteboardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F199EF22CE3203A005DC40F /* WhiteboardViewController.swift */; };
6F1EB9A72CF83538000EECB7 /* HapticManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F1EB9A62CF83538000EECB7 /* HapticManager.swift */; };
6F21477D2CE4EFCF00B55E2C /* TextObjectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F21477C2CE4EFCF00B55E2C /* TextObjectView.swift */; };
6F25BE442CF5BC44005BCAA2 /* PeerMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F25BE432CF5BC44005BCAA2 /* PeerMessageCell.swift */; };
6F25BE472CF5BF79005BCAA2 /* ChatMessageCellModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F25BE462CF5BF6F005BCAA2 /* ChatMessageCellModel.swift */; };
6FA7DBE92CF4B4E1007333C6 /* ChatTextFieldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FA7DBE82CF4B4E1007333C6 /* ChatTextFieldView.swift */; };
6FA7DBEC2CF56103007333C6 /* ChatViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FA7DBEB2CF56103007333C6 /* ChatViewModel.swift */; };
6FA7DBEE2CF56457007333C6 /* MessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FA7DBED2CF56457007333C6 /* MessageCell.swift */; };
6FA7DBF02CF5665B007333C6 /* MyMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FA7DBEF2CF5665B007333C6 /* MyMessageCell.swift */; };
6FA7DBF22CF56A3F007333C6 /* ChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FA7DBF12CF56A3F007333C6 /* ChatViewController.swift */; };
A81E7ABB2CF5C771007E8414 /* Wordle.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81E7ABA2CF5C771007E8414 /* Wordle.swift */; };
A81E7ABD2CF5C7A7007E8414 /* WordleState.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81E7ABC2CF5C7A7007E8414 /* WordleState.swift */; };
A81E7ABF2CF5C7FE007E8414 /* KeyboardState.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81E7ABE2CF5C7FE007E8414 /* KeyboardState.swift */; };
Expand All @@ -35,13 +43,6 @@
A81E7BD62CF6E797007E8414 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A81E7BD52CF6E797007E8414 /* Images.xcassets */; };
A81E7BD82CF6E94F007E8414 /* WordleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81E7BD72CF6E94F007E8414 /* WordleView.swift */; };
A81E7BDB2CF6E973007E8414 /* WordleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81E7BDA2CF6E973007E8414 /* WordleViewModel.swift */; };
6F25BE442CF5BC44005BCAA2 /* PeerMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F25BE432CF5BC44005BCAA2 /* PeerMessageCell.swift */; };
6F25BE472CF5BF79005BCAA2 /* ChatMessageCellModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F25BE462CF5BF6F005BCAA2 /* ChatMessageCellModel.swift */; };
6FA7DBE92CF4B4E1007333C6 /* ChatTextFieldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FA7DBE82CF4B4E1007333C6 /* ChatTextFieldView.swift */; };
6FA7DBEC2CF56103007333C6 /* ChatViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FA7DBEB2CF56103007333C6 /* ChatViewModel.swift */; };
6FA7DBEE2CF56457007333C6 /* MessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FA7DBED2CF56457007333C6 /* MessageCell.swift */; };
6FA7DBF02CF5665B007333C6 /* MyMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FA7DBEF2CF5665B007333C6 /* MyMessageCell.swift */; };
6FA7DBF22CF56A3F007333C6 /* ChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FA7DBF12CF56A3F007333C6 /* ChatViewController.swift */; };
A81E7BF52CF710EC007E8414 /* GameObjectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81E7BF42CF710EC007E8414 /* GameObjectView.swift */; };
A8525DC32CE200230089DA5E /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A8525DC22CE200230089DA5E /* Colors.xcassets */; };
A8525DCB2CE203D50089DA5E /* UIView+.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8525DCA2CE203D50089DA5E /* UIView+.swift */; };
Expand Down Expand Up @@ -78,6 +79,7 @@
0080E8C92CE2FF6E0095B958 /* WhiteboardObjectViewFactoryable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiteboardObjectViewFactoryable.swift; sourceTree = "<group>"; };
0080E8D02CE4A0060095B958 /* WhiteboardViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiteboardViewModel.swift; sourceTree = "<group>"; };
0080E8D22CE4A0820095B958 /* ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModel.swift; sourceTree = "<group>"; };
00C2950A2CFDF14700BD6768 /* AirplainTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AirplainTextField.swift; sourceTree = "<group>"; };
00D2DD972CE8CD300089F0BA /* DrawingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawingView.swift; sourceTree = "<group>"; };
00D2DD992CE8DCEA0089F0BA /* DrawingObjectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawingObjectView.swift; sourceTree = "<group>"; };
5B2BC78A2CE4F66F00893B9E /* WhiteboardListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiteboardListViewController.swift; sourceTree = "<group>"; };
Expand All @@ -89,6 +91,13 @@
6F199EF22CE3203A005DC40F /* WhiteboardViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiteboardViewController.swift; sourceTree = "<group>"; };
6F1EB9A62CF83538000EECB7 /* HapticManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticManager.swift; sourceTree = "<group>"; };
6F21477C2CE4EFCF00B55E2C /* TextObjectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextObjectView.swift; sourceTree = "<group>"; };
6F25BE432CF5BC44005BCAA2 /* PeerMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeerMessageCell.swift; sourceTree = "<group>"; };
6F25BE462CF5BF6F005BCAA2 /* ChatMessageCellModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessageCellModel.swift; sourceTree = "<group>"; };
6FA7DBE82CF4B4E1007333C6 /* ChatTextFieldView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatTextFieldView.swift; sourceTree = "<group>"; };
6FA7DBEB2CF56103007333C6 /* ChatViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatViewModel.swift; sourceTree = "<group>"; };
6FA7DBED2CF56457007333C6 /* MessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageCell.swift; sourceTree = "<group>"; };
6FA7DBEF2CF5665B007333C6 /* MyMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyMessageCell.swift; sourceTree = "<group>"; };
6FA7DBF12CF56A3F007333C6 /* ChatViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatViewController.swift; sourceTree = "<group>"; };
A81E7ABA2CF5C771007E8414 /* Wordle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Wordle.swift; sourceTree = "<group>"; };
A81E7ABC2CF5C7A7007E8414 /* WordleState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordleState.swift; sourceTree = "<group>"; };
A81E7ABE2CF5C7FE007E8414 /* KeyboardState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardState.swift; sourceTree = "<group>"; };
Expand All @@ -99,13 +108,6 @@
A81E7BD52CF6E797007E8414 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
A81E7BD72CF6E94F007E8414 /* WordleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordleView.swift; sourceTree = "<group>"; };
A81E7BDA2CF6E973007E8414 /* WordleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordleViewModel.swift; sourceTree = "<group>"; };
6F25BE432CF5BC44005BCAA2 /* PeerMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeerMessageCell.swift; sourceTree = "<group>"; };
6F25BE462CF5BF6F005BCAA2 /* ChatMessageCellModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessageCellModel.swift; sourceTree = "<group>"; };
6FA7DBE82CF4B4E1007333C6 /* ChatTextFieldView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatTextFieldView.swift; sourceTree = "<group>"; };
6FA7DBEB2CF56103007333C6 /* ChatViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatViewModel.swift; sourceTree = "<group>"; };
6FA7DBED2CF56457007333C6 /* MessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageCell.swift; sourceTree = "<group>"; };
6FA7DBEF2CF5665B007333C6 /* MyMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyMessageCell.swift; sourceTree = "<group>"; };
6FA7DBF12CF56A3F007333C6 /* ChatViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatViewController.swift; sourceTree = "<group>"; };
A81E7BF42CF710EC007E8414 /* GameObjectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameObjectView.swift; sourceTree = "<group>"; };
A8525DC22CE200230089DA5E /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = "<group>"; };
A8525DC72CE201D50089DA5E /* AirplainFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AirplainFont.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -213,6 +215,14 @@
path = ViewModel;
sourceTree = "<group>";
};
00C295092CFDF13700BD6768 /* View */ = {
isa = PBXGroup;
children = (
00C2950A2CFDF14700BD6768 /* AirplainTextField.swift */,
);
path = View;
sourceTree = "<group>";
};
5B2BC78B2CE4F66F00893B9E /* View */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -273,6 +283,52 @@
path = Manager;
sourceTree = "<group>";
};
6F25BE452CF5BF63005BCAA2 /* Model */ = {
isa = PBXGroup;
children = (
6F25BE462CF5BF6F005BCAA2 /* ChatMessageCellModel.swift */,
);
path = Model;
sourceTree = "<group>";
};
6FA7DBE52CF4682F007333C6 /* Chat */ = {
isa = PBXGroup;
children = (
6F25BE452CF5BF63005BCAA2 /* Model */,
6FA7DBE72CF4B4DA007333C6 /* View */,
6FA7DBE62CF4685A007333C6 /* ViewModel */,
);
path = Chat;
sourceTree = "<group>";
};
6FA7DBE62CF4685A007333C6 /* ViewModel */ = {
isa = PBXGroup;
children = (
6FA7DBEB2CF56103007333C6 /* ChatViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
};
6FA7DBE72CF4B4DA007333C6 /* View */ = {
isa = PBXGroup;
children = (
6FA7DBF12CF56A3F007333C6 /* ChatViewController.swift */,
6FA7DBE82CF4B4E1007333C6 /* ChatTextFieldView.swift */,
6FA7DBEA2CF560D5007333C6 /* Cell */,
);
path = View;
sourceTree = "<group>";
};
6FA7DBEA2CF560D5007333C6 /* Cell */ = {
isa = PBXGroup;
children = (
6FA7DBED2CF56457007333C6 /* MessageCell.swift */,
6FA7DBEF2CF5665B007333C6 /* MyMessageCell.swift */,
6F25BE432CF5BC44005BCAA2 /* PeerMessageCell.swift */,
);
path = Cell;
sourceTree = "<group>";
};
A81E7AB42CF5C6D4007E8414 /* Wordle */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -313,52 +369,6 @@
path = ViewModel;
sourceTree = "<group>";
};
6FA7DBE52CF4682F007333C6 /* Chat */ = {
isa = PBXGroup;
children = (
6F25BE452CF5BF63005BCAA2 /* Model */,
6FA7DBE72CF4B4DA007333C6 /* View */,
6FA7DBE62CF4685A007333C6 /* ViewModel */,
);
path = Chat;
sourceTree = "<group>";
};
6FA7DBE62CF4685A007333C6 /* ViewModel */ = {
isa = PBXGroup;
children = (
6FA7DBEB2CF56103007333C6 /* ChatViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
};
6FA7DBE72CF4B4DA007333C6 /* View */ = {
isa = PBXGroup;
children = (
6FA7DBF12CF56A3F007333C6 /* ChatViewController.swift */,
6FA7DBE82CF4B4E1007333C6 /* ChatTextFieldView.swift */,
6FA7DBEA2CF560D5007333C6 /* Cell */,
);
path = View;
sourceTree = "<group>";
};
6FA7DBEA2CF560D5007333C6 /* Cell */ = {
isa = PBXGroup;
children = (
6FA7DBED2CF56457007333C6 /* MessageCell.swift */,
6FA7DBEF2CF5665B007333C6 /* MyMessageCell.swift */,
6F25BE432CF5BC44005BCAA2 /* PeerMessageCell.swift */,
);
path = Cell;
sourceTree = "<group>";
};
6F25BE452CF5BF63005BCAA2 /* Model */ = {
isa = PBXGroup;
children = (
6F25BE462CF5BF6F005BCAA2 /* ChatMessageCellModel.swift */,
);
path = Model;
sourceTree = "<group>";
};
A8525DC12CE200110089DA5E /* Resources */ = {
isa = PBXGroup;
children = (
Expand All @@ -371,6 +381,7 @@
A8525DC52CE201C00089DA5E /* Common */ = {
isa = PBXGroup;
children = (
00C295092CFDF13700BD6768 /* View */,
6F1EB9A52CF8352F000EECB7 /* Manager */,
A8525DC92CE202D30089DA5E /* Extension */,
A8525DC62CE201CB0089DA5E /* DesignSystem */,
Expand Down Expand Up @@ -568,6 +579,7 @@
0080E8D32CE4A0840095B958 /* ViewModel.swift in Sources */,
5B2BC78E2CE4F66F00893B9E /* WhiteboardListViewController.swift in Sources */,
5B2BC78F2CE4F66F00893B9E /* WhiteboardListViewModel.swift in Sources */,
00C2950B2CFDF14700BD6768 /* AirplainTextField.swift in Sources */,
0080E8CA2CE2FF750095B958 /* WhiteboardObjectViewFactoryable.swift in Sources */,
A81E7BD42CF6E76D007E8414 /* WordleGuideView.swift in Sources */,
00683D762CE4B828000D28E4 /* DrawingRenderer.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// AirplainTextField.swift
// Presentation
//
// Created by 이동현 on 12/2/24.
//

import UIKit

public protocol AirplaINTextFieldDelegate: AnyObject, UITextFieldDelegate {
func airplainTextFieldDidChange(_ textField: AirplainTextField)
}

public final class AirplainTextField: UITextField {
weak var airplainTextFieldDelegate: AirplaINTextFieldDelegate? {
didSet {
delegate = airplainTextFieldDelegate
}
}

override init(frame: CGRect) {
super.init(frame: frame)
configureAttribute()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
configureAttribute()
}

private func configureAttribute() {
configurePlaceHolder()

self.addAction(
UIAction { [weak self] _ in
guard let self else { return }
self.airplainTextFieldDelegate?.airplainTextFieldDidChange(self)
},
for: .editingChanged)

self.addAction(
UIAction { [weak self] _ in
self?.attributedPlaceholder = nil
},
for: .editingDidBegin)

self.addAction(
UIAction { [weak self] _ in
self?.configurePlaceHolder()
},
for: .editingDidEnd)
}

private func configurePlaceHolder() {
let placeholderText = "Hello, AirplaIN"
let placeholderAttributes: [NSAttributedString.Key: Any] = [.foregroundColor: UIColor.airplainBlack]
self.attributedPlaceholder = NSAttributedString(string: placeholderText, attributes: placeholderAttributes)
}
}
Loading

0 comments on commit 371a773

Please sign in to comment.