-
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.
- Loading branch information
Showing
324 changed files
with
12,021 additions
and
342 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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.
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.
Binary file not shown.
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
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
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 was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
Projects/Core/Sources/Utility/Function/CasetIterable + Bidirection.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,37 @@ | ||
// | ||
// BidirectionalCasetIterable.swift | ||
// Core | ||
// | ||
// Created by ์ด์๋น on 2023/08/11. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension CaseIterable where Self: Equatable, AllCases: BidirectionalCollection { | ||
/// ์ด์ `case`๋ฅผ ๋ฐํํด์ | ||
func previous() -> Self { | ||
let all = Self.allCases | ||
let idx = all.firstIndex(of: self)! | ||
let previous = all.index(before: idx) | ||
|
||
if idx == all.startIndex { | ||
return self | ||
} else { | ||
return all[previous] | ||
} | ||
} | ||
|
||
/// ๋ค์ `case`๋ฅผ ๋ฐํํด์ | ||
func next() -> Self { | ||
let all = Self.allCases | ||
let idx = all.firstIndex(of: self)! | ||
let next = all.index(after: idx) | ||
|
||
if next == all.endIndex { | ||
return self | ||
} else { | ||
return all[next] | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Projects/Core/Sources/Utility/Function/Comparable + Between.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,16 @@ | ||
// | ||
// Between.swift | ||
// Core | ||
// | ||
// Created by ์ด์๋น on 2023/08/11. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension Comparable { | ||
/// `min` ๊ณผ `max` ์ฌ์ด์ ๊ฐ๋ง ๋ฐํํด์ค์. | ||
func between(min minValue: Self, max maxValue: Self) -> Self { | ||
min(maxValue, max(minValue, self)) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Projects/Core/Sources/Utility/Function/Float + String.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,15 @@ | ||
// | ||
// Float + String.swift | ||
// Core | ||
// | ||
// Created by Young Bin on 2023/08/15. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension Float { | ||
func toString(floatingPoint: Int = 1) -> String { | ||
String(format: "%.\(floatingPoint)f", self) | ||
} | ||
} |
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,15 @@ | ||
// | ||
// Padding.swift | ||
// Core | ||
// | ||
// Created by ๊น์์ธ on 2023/08/17. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public enum Padding { | ||
public static func insets(top: CGFloat=0, leading: CGFloat=0, bottom: CGFloat=0, trailing: CGFloat=0) -> EdgeInsets { | ||
return EdgeInsets(top: top, leading: leading, bottom: bottom, trailing: trailing) | ||
} | ||
} |
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,46 @@ | ||
// | ||
// TCA+.swift | ||
// Core | ||
// | ||
// Created by Young Bin on 2023/09/03. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import ComposableArchitecture | ||
|
||
private final class Ref<T: Equatable>: Equatable { | ||
var val: T | ||
init(_ v: T) { | ||
self.val = v | ||
} | ||
|
||
static func == (lhs: Ref<T>, rhs: Ref<T>) -> Bool { | ||
lhs.val == rhs.val | ||
} | ||
} | ||
|
||
/// ์คํ ์ค๋ฒํ๋ก์ฐ ๋ฐฉ์ง์ฉ ๋ํผ | ||
/// ์ฐธ๊ณ : https://github.com/pointfreeco/swift-composable-architecture/discussions/488 | ||
@propertyWrapper | ||
public struct Box<T: Equatable>: Equatable { | ||
private var ref: Ref<T> | ||
|
||
public init(_ x: T) { | ||
self.ref = Ref(x) | ||
} | ||
|
||
public var wrappedValue: T { | ||
get { ref.val } | ||
set { | ||
if !isKnownUniquelyReferenced(&ref) { | ||
ref = Ref(newValue) | ||
return | ||
} | ||
ref.val = newValue | ||
} | ||
} | ||
|
||
public var projectedValue: Box<T> { | ||
self | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
Projects/Core/Sources/Utility/Interact/Haptic/HapticManager.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,108 @@ | ||
// | ||
// HapticManager.swift | ||
// Keyme | ||
// | ||
// Created by ์ด์๋น on 2023/08/11. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Foundation | ||
import CoreHaptics | ||
|
||
public class HapticManager { | ||
public static let shared = HapticManager() | ||
|
||
private var hapticEngine: CHHapticEngine? | ||
|
||
init() { | ||
self.hapticEngine = createEngine() | ||
} | ||
|
||
/// ๋ฒํผ ๋๋ฅด๋ ๋๋์ ํ ํฑ | ||
public func homeButtonTouchDown() { | ||
let generator = UIImpactFeedbackGenerator(style: .heavy) | ||
generator.prepare() | ||
generator.impactOccurred() | ||
} | ||
|
||
/// ๋ฒํผ ๋ผ๋ ๋๋์ ํ ํฑ | ||
public func homeButtonTouchUp() { | ||
let generator = UIImpactFeedbackGenerator(style: .medium) | ||
generator.prepare() | ||
generator.impactOccurred() | ||
} | ||
|
||
/// ๋๋ฅด๋ฅด... | ||
public func unexpectedDelight() { | ||
let generator = UINotificationFeedbackGenerator() | ||
generator.prepare() | ||
generator.notificationOccurred(.error) | ||
} | ||
|
||
/// ํตํต | ||
public func tongtong() { | ||
let generator = UINotificationFeedbackGenerator() | ||
generator.prepare() | ||
generator.notificationOccurred(.success) | ||
} | ||
|
||
/// ํก | ||
public func tok() { | ||
let generator = UIImpactFeedbackGenerator(style: .rigid) | ||
generator.prepare() | ||
generator.impactOccurred() | ||
} | ||
|
||
/// ๋ถ | ||
public func boong() { | ||
let generator = UIImpactFeedbackGenerator(style: .soft) | ||
generator.prepare() | ||
generator.impactOccurred() | ||
} | ||
|
||
/// ๋๋ฅด๋ฅต | ||
public func selectionChanged() { | ||
let generator = UISelectionFeedbackGenerator() | ||
generator.prepare() | ||
generator.selectionChanged() | ||
} | ||
|
||
/// ํจํด ์ฌ์(ํจํด์ ์ถํ ํ์ ํ ๊ฐ๋ฐํด์ ์ถ๊ฐ) | ||
public func playHapticPattern() { | ||
do { | ||
try hapticEngine?.start() | ||
|
||
let pattern = try createHapticPattern() | ||
let player = try hapticEngine?.makePlayer(with: pattern) | ||
|
||
try player?.start(atTime: 0) | ||
} catch let error { | ||
print("Error playing haptic pattern: \(error)") | ||
} | ||
} | ||
} | ||
|
||
private extension HapticManager { | ||
func createEngine() -> CHHapticEngine? { | ||
guard CHHapticEngine.capabilitiesForHardware().supportsHaptics else { | ||
return nil | ||
} | ||
|
||
do { | ||
return try CHHapticEngine() | ||
} catch let error { | ||
print("Error creating haptic engine: \(error)") | ||
return nil | ||
} | ||
} | ||
|
||
func createHapticPattern() throws -> CHHapticPattern { | ||
let intensity = CHHapticEventParameter(parameterID: .hapticIntensity, value: 0.5) | ||
let sharpness = CHHapticEventParameter(parameterID: .hapticSharpness, value: 1) | ||
|
||
let events = [CHHapticEvent(eventType: .hapticTransient, parameters: [sharpness, intensity], relativeTime: 0)] | ||
|
||
return try CHHapticPattern(events: events, parameters: []) | ||
} | ||
} |
Oops, something went wrong.