Skip to content

Commit

Permalink
Refactor: #9 Move files to Xcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
99yuseong committed Mar 2, 2024
1 parent 5925c9a commit d42169d
Show file tree
Hide file tree
Showing 38 changed files with 3,452 additions and 13 deletions.
10 changes: 0 additions & 10 deletions myot-si-ya.swiftpm/Utils/Extension/Color+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@

import SwiftUI

extension Color {
static let bg = Color("bg")
static let gray1 = Color("gray1")
static let gray2 = Color("gray2")
static let gray3 = Color("gray3")
static let gray4 = Color("gray4")
static let gray5 = Color("gray5")
static let quaternary = Color("quaternary")
}

extension Color {
init(hex: String) {
let scanner = Scanner(string: hex)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// File.swift
//
// AnyTransition+.swift
//
//
// Created by 남유성 on 2/14/24.
//
Expand Down
43 changes: 43 additions & 0 deletions myot-si-ya/myot-si-ya/View/Components/Button/ControlButton.swift
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 myot-si-ya/myot-si-ya/View/Components/Button/IconButton.swift
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)
}
}
}
}
23 changes: 23 additions & 0 deletions myot-si-ya/myot-si-ya/View/Components/ClearBgView.swift
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 myot-si-ya/myot-si-ya/View/Components/KoreanPronsView.swift
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)
}
}
}
}

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")
}
}
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)
}
}
Loading

0 comments on commit d42169d

Please sign in to comment.