Skip to content

Commit

Permalink
Merge pull request #522 from DeveloperAcademy-POSTECH/feat/521-AddNew…
Browse files Browse the repository at this point in the history
…Extensions

[Feat] 공통 Extension 제작 등
  • Loading branch information
HanGyeongjun authored Apr 5, 2024
2 parents fcc497c + 82ffe69 commit d2cc1c2
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 11 deletions.
24 changes: 15 additions & 9 deletions HappyAnding/HappyAnding.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
A0DD085729276608008177BB /* URL+DeepLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0DD085629276608008177BB /* URL+DeepLink.swift */; };
A0F822AC2910B8F100AF4448 /* ShortcutsZipViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0F822AB2910B8F100AF4448 /* ShortcutsZipViewModel.swift */; };
A0F822B729164D2300AF4448 /* ListCategoryShortcutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0F822B629164D2300AF4448 /* ListCategoryShortcutView.swift */; };
A309862B2BBFE5650004D993 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D5889E72AA36A52000C4849 /* AppDelegate.swift */; };
A309862D2BBFE5F50004D993 /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = A309862C2BBFE5F50004D993 /* FirebaseMessaging */; };
A309862F2BBFE6B90004D993 /* View+Shadow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A309862E2BBFE6B90004D993 /* View+Shadow.swift */; };
A31F1844292A637300AF4A82 /* Date+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9CAEF822914855900224B0A /* Date+String.swift */; };
A31F1846292A638700AF4A82 /* (null) in Sources */ = {isa = PBXBuildFile; };
A31F1848292A64D700AF4A82 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 87E99C7128F94EA8009B691F /* Assets.xcassets */; };
Expand Down Expand Up @@ -277,6 +280,7 @@
A0DD085629276608008177BB /* URL+DeepLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+DeepLink.swift"; sourceTree = "<group>"; };
A0F822AB2910B8F100AF4448 /* ShortcutsZipViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutsZipViewModel.swift; sourceTree = "<group>"; };
A0F822B629164D2300AF4448 /* ListCategoryShortcutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListCategoryShortcutView.swift; sourceTree = "<group>"; };
A309862E2BBFE6B90004D993 /* View+Shadow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Shadow.swift"; sourceTree = "<group>"; };
A323D3C92AEE870700DDA716 /* SuggestionForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuggestionForm.swift; sourceTree = "<group>"; };
A323D3CB2AEEA10F00DDA716 /* SuggestionFormViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuggestionFormViewModel.swift; sourceTree = "<group>"; };
A33F74AD2908D8C800B8D0D0 /* CheckBoxShortcutCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckBoxShortcutCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -361,6 +365,7 @@
files = (
A3FC474B292A61550058BF26 /* FirebaseDatabase in Frameworks */,
A3FC474D292A61550058BF26 /* FirebaseFirestoreCombine-Community in Frameworks */,
A309862D2BBFE5F50004D993 /* FirebaseMessaging in Frameworks */,
A3FC4747292A61550058BF26 /* FirebaseAnalytics in Frameworks */,
A3FC4749292A61550058BF26 /* FirebaseAuth in Frameworks */,
);
Expand All @@ -369,14 +374,6 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
4DB674822AF11B7900A83C0B /* Support */ = {
isa = PBXGroup;
children = (
4D5889E72AA36A52000C4849 /* AppDelegate.swift */,
);
path = Support;
sourceTree = "<group>";
};
8786B2DD29A7F8C8000B46A1 /* String */ = {
isa = PBXGroup;
children = (
Expand All @@ -393,6 +390,7 @@
8786B2E329A7F966000B46A1 /* View+NavigationBar.swift */,
8751B29829A32CC000C2B27E /* View+Navigation.swift */,
8786B33D29ABA5A9000B46A1 /* View+Shape.swift */,
A309862E2BBFE6B90004D993 /* View+Shadow.swift */,
8786B2E129A7F93B000B46A1 /* View+UIFont.swift */,
);
path = View;
Expand Down Expand Up @@ -493,7 +491,6 @@
3D41EE06290A458B008BE986 /* Info.plist */,
87E99CC22901454D009B691F /* Extensions */,
A39504852AD46ACB0019895E /* Support */,
4DB674822AF11B7900A83C0B /* Support */,
87E99C9828FFF1D2009B691F /* Views */,
87E99CD729042503009B691F /* Model */,
A0F822AA2910B8B900AF4448 /* ViewModel */,
Expand Down Expand Up @@ -726,6 +723,7 @@
isa = PBXGroup;
children = (
A39504862AD46B9B0019895E /* HapticManager.swift */,
4D5889E72AA36A52000C4849 /* AppDelegate.swift */,
);
path = Support;
sourceTree = "<group>";
Expand Down Expand Up @@ -857,6 +855,7 @@
A3FC4748292A61550058BF26 /* FirebaseAuth */,
A3FC474A292A61550058BF26 /* FirebaseDatabase */,
A3FC474C292A61550058BF26 /* FirebaseFirestoreCombine-Community */,
A309862C2BBFE5F50004D993 /* FirebaseMessaging */,
);
productName = ShareExtension;
productReference = A3A6AD14292763E2004C49DC /* ShareExtension.appex */;
Expand Down Expand Up @@ -1014,6 +1013,7 @@
87E99CA128FFF225009B691F /* MyPageView.swift in Sources */,
8792478D2918CE450040D5C3 /* UINavigationContoller+Gesture.swift in Sources */,
8786B33C29ABA588000B46A1 /* View+Gesture.swift in Sources */,
A309862F2BBFE6B90004D993 /* View+Shadow.swift in Sources */,
87E99CC7290145AD009B691F /* ShortcutCell.swift in Sources */,
87E99CBB28FFF298009B691F /* IconModalView.swift in Sources */,
87E99C7028F94EA6009B691F /* ShortcutTabView.swift in Sources */,
Expand Down Expand Up @@ -1088,6 +1088,7 @@
A3439AF529395A100043E273 /* UserAuth.swift in Sources */,
A31F1846292A638700AF4A82 /* (null) in Sources */,
F9DB8EB92939853D00516CE1 /* ShareExtensionValidationTextField.swift in Sources */,
A309862B2BBFE5650004D993 /* AppDelegate.swift in Sources */,
F92766562A61A0E5009C4EC2 /* WriteShortcutModalViewModel.swift in Sources */,
8786B2EA29A7F9E7000B46A1 /* View+NavigationBar.swift in Sources */,
A3C5576C292BE084003907DC /* ShareExtensionWriteShortcutView.swift in Sources */,
Expand Down Expand Up @@ -1558,6 +1559,11 @@
package = F94B435B2907B19A00987819 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseMessaging;
};
A309862C2BBFE5F50004D993 /* FirebaseMessaging */ = {
isa = XCSwiftPackageProductDependency;
package = F94B435B2907B19A00987819 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseMessaging;
};
A3FC4746292A61550058BF26 /* FirebaseAnalytics */ = {
isa = XCSwiftPackageProductDependency;
package = F94B435B2907B19A00987819 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x40",
"green" : "0x40",
"red" : "0x40"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x40",
"green" : "0x40",
"red" : "0x40"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions HappyAnding/HappyAnding/Extensions/View/View+Shadow.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// View+Shadow.swift
// HappyAnding
//
// Created by HanGyeongjun on 4/5/24.
//

import SwiftUI

extension View {

///View에 Drop Shadow를 적용합니다.
///모든 View에서 사용되는 값에 변화가 없어 매개변수는 없습니다.
func dropShadow() -> some View {
self.shadow(color: Color("CharcoalGray").opacity(0.04),
radius: 8,
x: 0,
y: 2)
}
}
20 changes: 18 additions & 2 deletions HappyAnding/HappyAnding/Extensions/View/View+Shape.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,37 @@ import SwiftUI
/// 뷰의 모서리를 설정하기 위한 확장입니다.
extension View {

//TODO: 디자인 업데이트 완료 후 해당 익스텐션 삭제 필요
func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View {
clipShape( RoundedCorner(radius: radius, corners: corners) )
}

///반투명 테두리가 있는 둥근 모서리를 설정하기 위한 확장입니다.
///테두리의 두께는 고정값입니다.
///
///cornerRadius: 둥근 모서리의 정도를 설정합니다. 기본값 16.
///color: 테두리의 색상을 설정합니다. 기본값 "CharcoalGray"
///isBlendMode: 블랜드모드 적용을 조정합니다. 기본값 false
///opacity: 테두리의 투명도를 설정합니다. 기본값 1.0
func roundedBorder(cornerRadius: CGFloat = 16, color: Color = Color("CharcoalGray"), isNormalBlend: Bool = true, opacity: Double = 1.0) -> some View {
self.overlay(
RoundedRectangle(cornerRadius: cornerRadius)
.strokeBorder(color.opacity(opacity), lineWidth: 2)
.blendMode(isNormalBlend ? .normal : .multiply)
)
.clipShape(RoundedRectangle(cornerRadius: cornerRadius))
}
}


//MARK: - 둥근 모서리

/// 해당 Shape을 이용하여 다른 뷰에 적용합니다.
struct RoundedCorner: Shape {

var radius: CGFloat = .infinity
var corners: UIRectCorner = .allCorners

func path(in rect: CGRect) -> Path {
let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
return Path(path.cgPath)
Expand Down

0 comments on commit d2cc1c2

Please sign in to comment.