Skip to content

Commit

Permalink
feature #54: 탭 전환 버튼 추가 및 에셋 조금 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
enebin committed Aug 18, 2023
1 parent 4e43489 commit 5b89512
Show file tree
Hide file tree
Showing 31 changed files with 429 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public class HapticManager {
generator.notificationOccurred(.error)
}

/// 톡
public func tok() {
let generator = UIImpactFeedbackGenerator(style: .rigid)
generator.prepare()
generator.impactOccurred()
}

/// 패턴 재생(패턴은 추후 협의 후 개발해서 추가)
public func playHapticPattern() {
do {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "감성.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "계획적.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "돈관리.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "먹거리.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "센스.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "신체.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "애정.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "열정.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "유머.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "인간관계.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "지능.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
122 changes: 122 additions & 0 deletions Projects/DSKit/Sources/Button/SegmentControlView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
//
// SegmentControlView.swift
// DSKit
//
// Created by Young Bin on 2023/08/16.
// Copyright © 2023 team.humanwave. All rights reserved.
//

import SwiftUI
import SwiftUIIntrospect
import Core

public struct SegmentControlView<SegmentType: Identifiable, Content: View>: View {
let segments: [SegmentType]
@Binding var selected: SegmentType

var titleNormalColor: Color = .white
var titleSelectedColor: Color = .black

let selectedBackgroundColor: Color = .white
let viewBackgroundColor: Color = .hex("3c3c3c")

@ViewBuilder var content: (SegmentType) -> Content

@Namespace private var namespace

public init(
segments: [SegmentType],
selected: Binding<SegmentType>,
content: @escaping (SegmentType) -> Content
) {
self.segments = segments
self._selected = selected
self.content = content
}

public var body: some View {
GeometryReader { bounds in
HStack(alignment: .center, spacing: 0) {
ForEach(segments) { segment in
SegmentButton(
id: segment,
selectedId: $selected,
titleNormalColor: titleNormalColor,
titleSelectedColor: titleSelectedColor,
bgColor: selectedBackgroundColor,
namespace: namespace
) {
content(segment)
}
.frame(width: bounds.size.width / CGFloat(segments.count))
}
}
}
.padding(4)

.background {
BackgroundBlurringView(style: .systemChromeMaterialDark)
.cornerRadius(16)
.overlay(
RoundedRectangle(cornerRadius: 16, style: .continuous)
.stroke(Color.hex("232323"), lineWidth: 1)
)
}
}
}

extension SegmentControlView {
struct SegmentButton<SegmentType: Identifiable, Content: View> : View {
let id: SegmentType
@Binding var selectedId: SegmentType

var titleNormalColor: Color
var titleSelectedColor: Color

var bgColor: Color
var namespace: Namespace.ID

@ViewBuilder var content: () -> Content

var body: some View {
GeometryReader { bounds in
Button(action: {
HapticManager.shared.tok()
withAnimation(Animation.customInteractiveSpring()) {
selectedId = id
}
}) {
content()
}
.frame(width: bounds.size.width, height: bounds.size.height)
}
.foregroundColor(selectedId.id == id.id ? titleSelectedColor : titleNormalColor)
.background(buttonBackground)
}

@ViewBuilder private var buttonBackground: some View {
if selectedId.id == id.id {
RoundedRectangle(cornerRadius: 16, style: .continuous)
.fill(bgColor)
.matchedGeometryEffect(id: "SelectedTab", in: namespace)
}
}
}
}

public enum Segment: Identifiable, CaseIterable {
case similar, different

public var id: String {
title
}

public var title: String {
switch self {
case .similar:
return "가장 비슷한"
case .different:
return "가장 차이나는"
}
}
}
2 changes: 1 addition & 1 deletion Projects/DSKit/Sources/MyPage/CircleContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public struct CircleContentView: View {
VStack(spacing: imageSize / 4) {
metadata.icon
.resizable()
.frame(width: imageSize, height: imageSize)
.scaledToFit()
.frame(height: imageSize)
.opacity(showSubText ? 0.6 : 1)
.matchedGeometryEffect(id: contentIconEffectID, in: namespace)

Expand Down
Loading

0 comments on commit 5b89512

Please sign in to comment.