Skip to content

Commit

Permalink
Merge pull request #41 from Student-Center/working/WEAV-122
Browse files Browse the repository at this point in the history
[WEAV-122] �프로필 위젯 입력 기능 구현
  • Loading branch information
jisu15-kim authored Nov 15, 2024
2 parents 9b5aa81 + 59e6b7f commit 305c519
Show file tree
Hide file tree
Showing 39 changed files with 2,940 additions and 79 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ on:

jobs:
build:

runs-on: macos-latest
runs-on: macos-15
environment: develop
env:
# app archive 및 export 에 쓰일 환경 변수 설정
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unitTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
run-unitTest:

runs-on: macos-latest
runs-on: macos-15

steps:
- uses: actions/checkout@v4
Expand All @@ -27,7 +27,7 @@ jobs:
run: |
set -o pipefail && xcodebuild test \
-scheme three-days-UnitTest \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' \
-destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' \
| tee result.log
if grep -q "** TEST FAILED **" result.log; then
exit 1
Expand Down
434 changes: 424 additions & 10 deletions OpenApiGenerator/Sources/OpenapiGenerated/Client.swift

Large diffs are not rendered by default.

781 changes: 776 additions & 5 deletions OpenApiGenerator/Sources/OpenapiGenerated/Types.swift

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion OpenApiGenerator/Sources/openapi-generator-cli/3days-oas
Submodule 3days-oas updated 1 files
+173 −1 openapi.yaml
22 changes: 22 additions & 0 deletions Projects/Core/CommonKit/Sources/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public final class AppCoordinator: ObservableObject {
}
}
}
startRefreshMyUserInfo()
}

@MainActor
Expand Down Expand Up @@ -100,4 +101,25 @@ public final class AppCoordinator: ObservableObject {
}
}
}

public func refreshMyUserInfo() async throws {
if TokenManager.accessToken == nil || TokenManager.accessToken == "" {
return
}
let userInfo = try await authService.requestMyUserInfo()
await MainActor.run {
self.userInfo = userInfo
AuthState.change(.login)
}
}

// 20초마다 한번씩 refreshMyUserInfo() 를 호출
private func startRefreshMyUserInfo() {
Task {
while true {
try? await Task.sleep(for: .seconds(20))
try? await refreshMyUserInfo()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// Color+Ext.swift
// DesignCore
// CoreKit
//
// Created by 김지수 on 9/14/24.
// Copyright © 2024 com.studentcenter. All rights reserved.
// Created by 김지수 on 11/11/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import SwiftUI
Expand Down
9 changes: 9 additions & 0 deletions Projects/Core/CoreKit/Sources/String+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ extension String {
return "\(firstPart)-\(secondPart)-\(thirdPart)"
}
}

public func clipMaxCount(_ maxCount: Int) -> String {
if self.count > maxCount {
let index = self.index(self.startIndex, offsetBy: maxCount)
let formattedText = String(self[..<index])
return formattedText
}
return self
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public class AuthServiceMock: AuthServiceProtocol {
jobOccupations: [],
distanceType: .anywhere,
allowSameCompany: nil
)
),
profileWidgets: []
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// ProfileService.swift
// CommonKit
//
// Created by 김지수 on 11/14/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import Foundation
import CoreKit
import OpenapiGenerated
import Model

public protocol ProfileServiceProtocol {
func requestPutProfileWidget(
widgetType: Components.Schemas.ProfileWidgetType,
content: String
) async throws

func requestDeleteProfileWidget(
widgetType: Components.Schemas.ProfileWidgetType
) async throws
}

public final class ProfileService {
public static let shared = ProfileService()
private init() {}
}

extension ProfileService: ProfileServiceProtocol {
public func requestPutProfileWidget(
widgetType: Components.Schemas.ProfileWidgetType,
content: String
) async throws {
let result = try await client.putProfileWidget(
body: .json(
.init(
_type: widgetType,
content: content
)
)
)
let _ = try result.ok
}

public func requestDeleteProfileWidget(
widgetType: Components.Schemas.ProfileWidgetType
) async throws {
let response = try await client.deleteProfileWidget(
.init(
path: .init(_type: widgetType)
)
)
_ = try response.noContent
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// ProfileServiceMock.swift
// NetworkKit
//
// Created by 김지수 on 11/15/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import Foundation
import OpenapiGenerated
import CoreKit

public final class ProfileServiceMock: ProfileServiceProtocol {
public init() {}

public func requestPutProfileWidget(
widgetType: Components.Schemas.ProfileWidgetType,
content: String
) async throws {
print("✅ [ProfileServiceMock] requestPutProfileWidget 성공!")
return
}

public func requestDeleteProfileWidget(
widgetType: Components.Schemas.ProfileWidgetType
) async throws {
print("✅ [ProfileServiceMock] requestDeleteProfileWidget 성공!")
return
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "pencil.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "pencil@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "pencil@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "plus_circle_filled.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "plus_circle_filled@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "plus_circle_filled@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions Projects/DesignSystem/DesignCore/Sources/FlatTextFieldOption.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// FlatTextFieldOption.swift
// DesignCore
//
// Created by 김지수 on 11/14/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import SwiftUI

struct FlatTextFieldOptionModifier: ViewModifier {
let keyboardType: UIKeyboardType

func body(content: Content) -> some View {
content
.keyboardType(keyboardType)
.interactiveDismissDisabled()
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
.speechAnnouncementsQueued(false)
.speechSpellsOutCharacters(false)
}
}

extension View {
public func flatTextFieldOption(keyboardType: UIKeyboardType = .default) -> some View {
modifier(FlatTextFieldOptionModifier(keyboardType: keyboardType))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// ProfileWidgetView.swift
// DesignCore
//
// Created by 김지수 on 11/7/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import SwiftUI
import CoreKit

public enum ProfileWidgetIconType {
case add
case edit

var image: Image {
switch self {
case .add: DesignCore.Images.plusCircleFilled.image
case .edit: DesignCore.Images.pencil1.image
}
}
}

public struct ProfileWidgetView: View {

public let title: String
public let bodyText: String
public let titleColor: Color
public let bodyColor: Color
public let gradientColors: [Color]
public var iconType: ProfileWidgetIconType?

public init(
title: String,
bodyText: String,
titleColor: Color,
bodyColor: Color,
gradientColors: [Color],
iconType: ProfileWidgetIconType? = nil
) {
self.title = title
self.bodyText = bodyText
self.titleColor = titleColor
self.bodyColor = bodyColor
self.gradientColors = gradientColors
self.iconType = iconType
}

public var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 24)
.fill(
LinearGradient(
colors: gradientColors,
startPoint: .top,
endPoint: .bottom
)
)
VStack {
HStack {
Text(title)
.pretendard(weight: ._600, size: 22)
.foregroundStyle(titleColor)
Spacer()
if let iconType {
iconType.image
.resizable()
.frame(width: 22, height: 22)
}
}
Spacer()
ScrollView {
LeftAlignText(bodyText)
.typography(.regular_14)
.foregroundStyle(bodyColor)
}
}
.scrollIndicators(.hidden)
.padding(.all, 20)
}
}
}
Loading

0 comments on commit 305c519

Please sign in to comment.