-
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
38 changed files
with
3,452 additions
and
13 deletions.
There are no files selected for viewing
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
4 changes: 2 additions & 2 deletions
4
...wiftpm/Utils/Extension/SwiftUI/File.swift → ...ls/Extension/SwiftUI/AnyTransition+.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// | ||
// File.swift | ||
// | ||
// AnyTransition+.swift | ||
// | ||
// | ||
// Created by 남유성 on 2/14/24. | ||
// | ||
|
43 changes: 43 additions & 0 deletions
43
myot-si-ya/myot-si-ya/View/Components/Button/ControlButton.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,43 @@ | ||
// | ||
// ControlButton.swift | ||
// | ||
// | ||
// Created by 남유성 on 2/5/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ControlButton: View { | ||
|
||
@State var isToggled: Bool = false | ||
|
||
let icon: String | ||
let toggleIcon: String? | ||
let tintColor: Color = .secondary | ||
let bgColor: Color = .quaternary | ||
let iconSize: CGFloat = 32 | ||
let btnSize: CGSize = CGSize(width: 60, height: 60) | ||
let action: () -> Void | ||
|
||
init(icon: String, toggleIcon: String? = nil, action: @escaping () -> Void) { | ||
self.icon = icon | ||
self.toggleIcon = toggleIcon | ||
self.action = action | ||
} | ||
|
||
var body: some View { | ||
Button { | ||
action() | ||
if toggleIcon != nil { | ||
isToggled.toggle() | ||
} | ||
} label: { | ||
Image(systemName: (toggleIcon == nil || !isToggled) ? icon : toggleIcon!) | ||
.font(.system(size: iconSize, weight: .regular)) | ||
.foregroundStyle(tintColor) | ||
} | ||
.frame(width: btnSize.width, height: btnSize.height) | ||
.background(bgColor) | ||
.clipShape(Circle()) | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
myot-si-ya/myot-si-ya/View/Components/Button/IconButton.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,64 @@ | ||
// | ||
// IconButton.swift | ||
// TokTakTokTak | ||
// | ||
// Created by 남유성 on 2/1/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct IconButton: View { | ||
|
||
@State private var isToggled: Bool = false | ||
|
||
private var name: String = "" | ||
private var nameForToggle: String? | ||
private var contentSize: CGFloat | ||
private var btnSize: CGSize | ||
private var content: String? | ||
|
||
private var action: () -> Void | ||
|
||
public init( | ||
_ name: String = "", | ||
_ nameForToggle: String? = nil, | ||
contentSize: CGFloat = 32, | ||
btnSize: CGSize = CGSize(width: 48, height: 48), | ||
action: @escaping () -> Void) { | ||
|
||
self.name = name | ||
self.nameForToggle = nameForToggle | ||
self.contentSize = contentSize | ||
self.btnSize = btnSize | ||
self.action = action | ||
} | ||
|
||
public init( | ||
text: String, | ||
contentSize: CGFloat = 32, | ||
btnSize: CGSize = CGSize(width: 48, height: 48), | ||
action: @escaping () -> Void) { | ||
|
||
self.content = text | ||
self.contentSize = contentSize | ||
self.btnSize = btnSize | ||
self.action = action | ||
} | ||
|
||
public var body: some View { | ||
Button { | ||
action() | ||
isToggled.toggle() | ||
} label: { | ||
if let content = content { | ||
Text(content) | ||
.font(.system(size: contentSize, weight: .thin)) | ||
.frame(width: btnSize.width, height: btnSize.height) | ||
} else { | ||
Image(systemName: nameForToggle == nil ? name : isToggled ? nameForToggle! : name) | ||
.font(.system(size: contentSize, weight: .thin)) | ||
.frame(width: btnSize.width, height: btnSize.height) | ||
} | ||
} | ||
} | ||
} |
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,23 @@ | ||
// | ||
// ClearBgView.swift | ||
// | ||
// | ||
// Created by 남유성 on 2/13/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ClearBgView: UIViewRepresentable { | ||
|
||
func makeUIView(context: Context) -> some UIView { | ||
let view = UIView() | ||
|
||
DispatchQueue.main.async { | ||
view.superview?.superview?.backgroundColor = .clear | ||
} | ||
|
||
return view | ||
} | ||
|
||
func updateUIView(_ uiView: UIViewType, context: Context) {} | ||
} |
89 changes: 89 additions & 0 deletions
89
myot-si-ya/myot-si-ya/View/Components/KoreanPronsView.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,89 @@ | ||
// | ||
// KoreanPronsView.swift | ||
// | ||
// | ||
// Created by 남유성 on 2/2/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct KoreanPronsListView: View { | ||
|
||
private let text: String | ||
private let detail: String | ||
private let prons: String | ||
private let detail2: String? | ||
private let prons2: String? | ||
private let textWidth: CGFloat | ||
private let pronsWidth: CGFloat | ||
|
||
init( | ||
_ text: String, | ||
_ detail: String, | ||
_ prons: String, | ||
_ detail2: String? = nil, | ||
_ prons2: String? = nil, | ||
textWidth: CGFloat = 82, | ||
pronsWidth: CGFloat = 140 | ||
) { | ||
self.text = text | ||
self.detail = detail | ||
self.prons = prons | ||
self.detail2 = detail2 | ||
self.prons2 = prons2 | ||
self.textWidth = textWidth | ||
self.pronsWidth = pronsWidth | ||
} | ||
|
||
var body: some View { | ||
HStack { | ||
HStack { | ||
Spacer() | ||
Text(text) | ||
} | ||
.frame(width: textWidth) | ||
|
||
Rectangle() | ||
.frame(width: 1, height: 12) | ||
.background(Color.gray3) | ||
.padding([.leading, .trailing], 8) | ||
|
||
HStack { | ||
KoreanPronsView(text: detail, prons: prons) | ||
Spacer() | ||
} | ||
.frame(width: pronsWidth) | ||
|
||
if detail2 != nil && prons2 != nil { | ||
Text("/") | ||
.aggro(.light, size: 17) | ||
KoreanPronsView(text: detail2!, prons: prons2!) | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct KoreanPronsView: View { | ||
|
||
private let text: String | ||
private let prons: String | ||
|
||
init(text: String, prons: String) { | ||
self.text = text | ||
self.prons = prons | ||
} | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 0) { | ||
HStack(spacing: 6) { | ||
Text(text) | ||
.aggro(.light, size: 17) | ||
.foregroundStyle(.primary) | ||
Text("[\(prons)]") | ||
.aggro(.light, size: 15) | ||
.foregroundStyle(.secondary) | ||
} | ||
} | ||
} | ||
} | ||
|
22 changes: 22 additions & 0 deletions
22
myot-si-ya/myot-si-ya/View/Components/Picker/CustomUIPickerView.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,22 @@ | ||
// | ||
// CustomUIPickerView.swift | ||
// | ||
// | ||
// Created by 남유성 on 2/5/24. | ||
// | ||
|
||
import UIKit | ||
|
||
class CustomUIPickerView: UIPickerView { | ||
|
||
let type: PickerType | ||
|
||
init(type: PickerType) { | ||
self.type = type | ||
super.init(frame: .zero) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
myot-si-ya/myot-si-ya/View/Components/Picker/MultiAlarmPickerView.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,82 @@ | ||
// | ||
// MultiAlarmPickerView.swift | ||
// | ||
// | ||
// Created by 남유성 on 2/7/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
enum TimeSection: CaseIterable { | ||
case am | ||
case pm | ||
|
||
var korean: String { | ||
switch self { | ||
case .am: | ||
return "오전" | ||
case .pm: | ||
return "오후" | ||
} | ||
} | ||
} | ||
|
||
struct MultiAlarmPickerView: View { | ||
|
||
@Binding var selectedAmPm: Int | ||
@Binding var selectedHour: Int | ||
@Binding var selectedMinute: Int | ||
|
||
let type: PickerType | ||
|
||
let sections = TimeSection.allCases.map { $0.korean } | ||
let hours = Array(0..<12).map { | ||
if $0 == 0 { | ||
return "열두" | ||
} | ||
return $0.nativeKoreanTime! | ||
} | ||
let minutes = Array(0..<60).map { $0.sinoKoreanTime! } | ||
|
||
var body: some View { | ||
ZStack { | ||
HStack(spacing: type == .large ? 24 : 16) { | ||
TimePickerView( | ||
selectedItem: $selectedAmPm, | ||
items: sections, | ||
isLoop: false, | ||
type: type | ||
) | ||
TimePickerView( | ||
selectedItem: $selectedHour, | ||
items: hours, | ||
isLoop: true, | ||
type: type | ||
) | ||
Text("시") | ||
TimePickerView( | ||
selectedItem: $selectedMinute, | ||
items: minutes, | ||
isLoop: true, | ||
type: type | ||
) | ||
Text("분") | ||
} | ||
.aggro(.medium, size: type == .large ? 40 : 24) | ||
|
||
VStack { // prevent touch | ||
Color.bg | ||
.contentShape(Rectangle()) | ||
.frame(height: 42) | ||
|
||
Spacer() | ||
|
||
Color.bg | ||
.contentShape(Rectangle()) | ||
.frame(height: 42) | ||
} | ||
.frame(height: type == .large ? 84 * 5 : 48 * 6) | ||
} | ||
.background(Color.bg) | ||
} | ||
} |
Oops, something went wrong.