Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

로그인 & 디자인 시스템 일부 적용 #1

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions yappu-world-ios/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import SwiftUI

struct ContentView: View {
var body: some View {
VStack {
HomeView()
}
.padding()
LoginView(viewModel: .init())
}
}

Expand Down
10 changes: 10 additions & 0 deletions yappu-world-ios/Source/Data/DTO/DTOExample.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// DTOExample.swift
// yappu-world-ios
//
// Created by Tabber on 1/7/25.
//

import Foundation

/// 위 파일은 예시파일입니다. 삭제 하고 사용하세용
152 changes: 152 additions & 0 deletions yappu-world-ios/Source/DesignSystem/Button/YPButtonStyle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
//
// YPButtonStyle.swift
// yappu-world-ios
//
// Created by Tabber on 1/7/25.
//

import SwiftUI

public enum ColorStyle {
case primary
case border
}

public struct YPButtonStyle: ButtonStyle {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ButtonStyle, TextFieldStyle 보면서 그동안 디자인시스템 헛으로 만들었다는 것을 깨달았습니다... 많이 배우겠슴다,,,

@Environment(\.isEnabled) private var isEnabled

private let font: Pretendard.Style
private let verticalPadding: CGFloat
private let horizontalPadding: CGFloat
private let cornerRadius: CGFloat
private let colorStyle: ColorStyle

public func makeBody(configuration: Configuration) -> some View {
configuration.label
.font(font)
.padding(.horizontal, horizontalPadding)
.padding(.vertical, verticalPadding)
.foregroundStyle(foregroundColor)
.background(backgroundColor)
.if(colorStyle == .border) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 신박한데,,,

$0.overlay(
RoundedRectangle(cornerRadius: cornerRadius)
.stroke(foregroundColor, lineWidth: 1)
)
}
.cornerRadius(radius: cornerRadius, corners: .allCorners)

}
}

public extension YPButtonStyle {
/// 출석앱에서 주로 사용하는 버튼의 Style
/// font: Pretendard 스타일 폰트 설정입니다. ex) .pretendard16(.bold)
/// horizontalPadding: 버튼을 horizontal 기준으로 몇 padding 시킬지에 대한 값입니다.
/// verticalPadding: 버튼을 vertical 기준으로 몇 padding 시킬지에 대한 값입니다.
/// radius: 버튼의 radius 값입니다.
/// colorStyle: 버튼이 노출되는 스타일을 설정합니다. ex) .primary or .border
init(
font: Pretendard.Style,
horizontalPadding: CGFloat,
verticalPadding: CGFloat,
radius: CGFloat,
colorStyle: ColorStyle
) {
self.font = font
self.horizontalPadding = horizontalPadding
self.verticalPadding = verticalPadding
self.cornerRadius = radius
self.colorStyle = colorStyle
}

private var foregroundColor: Color {
if colorStyle == .primary {
switch isEnabled {
case true: return .white
case false: return .gray30
}
} else {
return .yapp_primary
}
}

private var backgroundColor: Color {
if colorStyle == .primary {
switch isEnabled {
case true: return .yapp_primary
case false: return .disabledGray
}
} else {
return .white
}
}
}

#Preview {
VStack(spacing: 20) {
Button(action: {}, label: {
Text("다음")
.frame(maxWidth: .infinity)
})
.buttonStyle(.yapp(style: .primary))

Button(action: {}, label: {
Text("다음")
.frame(maxWidth: .infinity)
})
.buttonStyle(.yapp(style: .border))

Button(action: {}, label: {
Text("다음")
.frame(maxWidth: .infinity)
})
.buttonStyle(.yapp(style: .primary))
.disabled(true)

Button(action: {}, label: {
Text("인증메일 발송")
.frame(maxWidth: .infinity)
})
.buttonStyle(.yapp(style: .primary))
.disabled(true)

Button(action: {}, label: {
Text("요청거절")
})
.buttonStyle(.yapp(
horizontalPadding: 22,
style: .primary
))
.disabled(true)

Button(action: {}, label: {
Text("요청승인")
})
.buttonStyle(.yapp(
horizontalPadding: 70,
style: .primary
))

Button(action: {}, label: {
Text("검색")
})
.buttonStyle(.yapp(
font: .pretendard16(.bold),
horizontalPadding: 14,
verticalPadding: 15,
style: .border
))

Button(action: {}, label: {
Text("검색")
.frame(maxWidth: .infinity)
})
.buttonStyle(.yapp(
font: .pretendard16(.semibold),
horizontalPadding: 14,
verticalPadding: 15,
style: .border
))
}
}
108 changes: 108 additions & 0 deletions yappu-world-ios/Source/DesignSystem/Popup/DimmedPopupModifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
//
// DimmedPopupModifier.swift
// yappu-world-ios
//
// Created by Tabber on 1/7/25.
//

import SwiftUI

struct DimmedPopupModifier<Popup: View>: ViewModifier {
@Binding var isOpen: Bool
@ViewBuilder let popupView: Popup
var horizontalPadding: CGFloat
var verticalPadding: CGFloat
var alignment: Alignment = .bottom

func body(content: Content) -> some View {
ZStack {
content

if isOpen {
Color.black.opacity(0.3)
.ignoresSafeArea()
.onTapGesture {
isOpen = false // 팝업 닫기
}
}

VStack {
switch alignment {
case .bottom:
Spacer()
default:
EmptyView()
}

if isOpen {

ZStack(alignment: .leading) {
Color.white
.frame(maxWidth: .infinity)
.cornerRadius(radius: 16, corners: .allCorners)

popupView
.transition(.move(edge: .bottom)) // 팝업 애니메이션 추가
.zIndex(1) // 팝업을 최상단으로 설정
.padding(.horizontal, horizontalPadding)
.padding(.vertical, verticalPadding)
}
.fixedSize(horizontal: false, vertical: true)
.padding(.horizontal, 8)
}
}

}
}
}

extension View {
func yappBottomPopup<Popup: View>(
isOpen: Binding<Bool>,
horizontalPadding: CGFloat = 20,
verticalPadding: CGFloat = 20,
@ViewBuilder view: @escaping () -> Popup
) -> some View {
modifier(
DimmedPopupModifier<Popup>(
isOpen: isOpen,
popupView: view,
horizontalPadding: horizontalPadding,
verticalPadding: verticalPadding,
alignment: .bottom
)
)
}

func yappDefaultPopup<Popup: View>(
isOpen: Binding<Bool>,
horizontalPadding: CGFloat = 20,
verticalPadding: CGFloat = 20,
@ViewBuilder view: @escaping () -> Popup
) -> some View {
modifier(
DimmedPopupModifier<Popup>(
isOpen: isOpen,
popupView: view,
horizontalPadding: horizontalPadding,
verticalPadding: verticalPadding,
alignment: .center
)
)
}
}

#Preview {
VStack {
Text("Hello")
.font(.title)
.padding()
}
.yappBottomPopup(isOpen: .constant(true)) {
VStack(alignment: .leading) {
Text("서비스 이용약관")
.font(.pretendard18(.bold))
.foregroundStyle(Color.labelGray)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ import SwiftUI

// MARK: - Gray Scale
public extension Color {
static let gray22: Color = .init(uiColor: .init(hex: "#70737C")).opacity(0.22)
static let gray22: Color = .init(hex: "#70737C").opacity(0.22)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 그냥 헥스값으로 하신 이유가 있나여? 좀 힘들었을 것 같은데...

static let gray30: Color = .init(hex: "#37383C").opacity(0.28)
static let gray60: Color = .init(hex: "#37383C").opacity(0.61)
}

// MARK: - Main Color
public extension Color {
static let yapp_primary: Color = .init(uiColor: .init(hex: "#FA6027"))
static let yapp_primary: Color = .init(hex: "#FA6027")
}

// MARK: - System Color
public extension Color {
static let red100: Color = .init(uiColor: .init(hex: "#FF4242"))
static let labelGray: Color = .init(hex: "#171719")
static let disabledGray: Color = .init(hex: "#F4F4F5")
static let orGray: Color = .init(hex: "#E0E0E2")
static let red100: Color = .init(hex: "#FF4242")
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum Pretendard {
public enum Style {
case pretendard28(Weight)
case pretendard22(Weight)
case pretendard24(Weight)
case pretendard19(Weight)
case pretendard18(Weight)
case pretendard17(Weight)
Expand Down Expand Up @@ -44,6 +45,7 @@ extension Pretendard.Style {
switch self {
case .pretendard28: return 28
case .pretendard22: return 22
case .pretendard24: return 24
case .pretendard19: return 19
case .pretendard18: return 18
case .pretendard17: return 17
Expand All @@ -60,6 +62,7 @@ extension Pretendard.Style {
switch self {
case .pretendard28: return 28
case .pretendard22: return 34
case .pretendard24: return 34
case .pretendard19: return 20
case .pretendard18: return 24
case .pretendard17: return 20
Expand All @@ -79,6 +82,7 @@ extension Pretendard.Style {
switch weight {
case .bold: return 18
case .medium: return 18
case .regular: return 22
default: return self.size
}
case .pretendard14(let weight):
Expand Down Expand Up @@ -135,6 +139,7 @@ extension Pretendard.Style: FontLineHeightConfigurable {
switch self {
case .pretendard28(let weight),
.pretendard22(let weight),
.pretendard24(let weight),
.pretendard19(let weight),
.pretendard18(let weight),
.pretendard17(let weight),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,34 @@ public struct HeaderLabel: View {
private let value: String
private let isRequired: Bool
private let font: Pretendard.Style
private let headerColor: Color

public var body: some View {
HStack(spacing: 0) {
Text(value)
.font(font)

if isRequired {
Text(" *")
.font(font)
.foregroundStyle(Color.red100)
}
}
.foregroundStyle(headerColor)
}
}

public extension HeaderLabel {
init(
title: String,
isRequired: Bool = false,
font: Pretendard.Style = .pretendard16(.semibold)
font: Pretendard.Style = .pretendard16(.semibold),
headerColor: Color = .gray60
) {
self.value = title
self.isRequired = isRequired
self.font = font
self.headerColor = headerColor
}
}

Expand Down
Loading