Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/develop'
Browse files Browse the repository at this point in the history
HanGyeongjun committed Nov 23, 2022
2 parents cab0b63 + b3cf8c3 commit 5b50d30
Showing 10 changed files with 265 additions and 184 deletions.
15 changes: 15 additions & 0 deletions HappyAnding/HappyAnding/Extensions/View+Extension.swift
Original file line number Diff line number Diff line change
@@ -39,4 +39,19 @@ extension View {
})
)
}

func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View {
clipShape( RoundedCorner(radius: radius, corners: corners) )
}
}

struct RoundedCorner: Shape {

var radius: CGFloat = .infinity
var corners: UIRectCorner = .allCorners

func path(in rect: CGRect) -> Path {
let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
return Path(path.cgPath)
}
}
15 changes: 11 additions & 4 deletions HappyAnding/HappyAnding/Model/Comment.swift
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

import Foundation

struct Comments: Identifiable, Codable {
struct Comments: Identifiable, Codable, Equatable {
var id: String //댓글이 달린 단축어 id
var comments: [Comment]

@@ -19,7 +19,8 @@ struct Comments: Identifiable, Codable {

struct Comment: Identifiable, Codable, Hashable {
var id = UUID().uuidString
var bundel_id = "\(Date().getDate())_\(UUID().uuidString)" //원댓글과 대댓글을 묶는 id
var bundle_id = "\(Date().getDate())_\(UUID().uuidString)" //원댓글과 대댓글을 묶는 id
var user_nickname: String //작성자 닉네임
var user_id: String //작성자 uid
var date: String //처음 작성한 날짜만 저장
var depth: Int //0이면 원댓글, 1이면 대댓글
@@ -29,15 +30,21 @@ struct Comment: Identifiable, Codable, Hashable {
extension Comments {
func fetchSortedComment() -> [Comment] {
let sortedComments = self.comments.sorted(by: { lhs, rhs in
if lhs.bundel_id == rhs.bundel_id {
if lhs.bundle_id == rhs.bundle_id {
if lhs.depth < rhs.depth {
return true
}
} else if lhs.bundel_id < rhs.bundel_id {
} else if lhs.bundle_id < rhs.bundle_id {
return true
}
return false
})
return sortedComments
}
}

extension Comment {
func resetComment() -> Comment {
Comment(user_nickname: "", user_id: "", date: "", depth: 0, contents: "")
}
}
47 changes: 28 additions & 19 deletions HappyAnding/HappyAnding/ViewModel/ShortcutsZipViewModel.swift
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ class ShortcutsZipViewModel: ObservableObject {

@Published var curationsMadeByUser: [Curation] = [] // 유저가 만든 큐레이션배열
@Published var userCurations: [Curation] = []
@Published var personalCurations: [Curation] = [] // "땡땡님을 위한 모음집" 큐레이션배열
@Published var adminCurations: [Curation] = []

@Published var allComments: [Comments] = []
@@ -63,6 +64,9 @@ class ShortcutsZipViewModel: ObservableObject {
fetchKeyword { keywords in
self.keywords = keywords
}
fetchCommentAll { comments in
self.allComments = comments
}
}

func initUserShortcut(user: User) {
@@ -421,6 +425,8 @@ class ShortcutsZipViewModel: ObservableObject {
var increment = 0
if isMyLike {
increment = 1
shortcutsUserLiked.append(shortcut)
userInfo?.likedShortcuts.append(shortcut.id)
self.fetchUser(userID: self.currentUser()) { data in
var user = data
user.likedShortcuts.append(shortcut.id)
@@ -433,10 +439,11 @@ class ShortcutsZipViewModel: ObservableObject {
}
} else {
increment = -1
shortcutsUserLiked.removeAll(where: { $0.id == shortcut.id })
userInfo?.likedShortcuts.removeAll(where: { $0 == shortcut.id })
self.fetchUser(userID: self.currentUser()) { data in
var user = data
user.likedShortcuts.removeAll(where: { $0 == shortcut.id })

self.db.collection("User").document(user.id).setData(user.dictionary) { error in
if let error {
print(error.localizedDescription)
@@ -720,7 +727,7 @@ class ShortcutsZipViewModel: ObservableObject {

//MARK: 모든 댓글을 가져오는 함수

func fetchCommentAll(shortcutID: String, completionHandler: @escaping ([Comments]) -> ()) {
func fetchCommentAll(completionHandler: @escaping ([Comments]) -> ()) {
var comments: [Comments] = []
var query: Query!

@@ -731,6 +738,7 @@ class ShortcutsZipViewModel: ObservableObject {
print("Error fetching snapshots: \(error!)")
return
}
print(snapshot.metadata.isFromCache ? "**local cache" : "**server")
snapshot.documentChanges.forEach { diff in
let decoder = JSONDecoder()

@@ -743,12 +751,12 @@ class ShortcutsZipViewModel: ObservableObject {
comments.insert(comment, at: 0)
}
if (diff.type == .modified) {
if let index = self.allComments.firstIndex(where: { $0.id == shortcutID}) {
self.allComments[index] = comment
if let index = comments.firstIndex(where: {$0.id == comment.id}) {
comments[index] = comment
}
}
if (diff.type == .removed) {
comments.removeAll(where: { $0.id == shortcutID})
comments.removeAll(where: { $0.id == comment.id})
}
} catch let error {
print("error: \(error)")
@@ -760,33 +768,34 @@ class ShortcutsZipViewModel: ObservableObject {

//MARK: 단축어 ID에 해당하는 댓글 목록 불러오는 함수

func fetchComment(shortcutID: String) -> Comments? {
func fetchComment(shortcutID: String) -> Comments {
if let index = allComments.firstIndex(where: {$0.id == shortcutID}) {
allComments[index].comments = allComments[index].fetchSortedComment()
return allComments[index]
}
return nil
return Comments(id: shortcutID, comments: [])
}

func updateComment(shortcutID: String, comment: Comment) {
if var comments = fetchComment(shortcutID: shortcutID) {
comments.comments.append(comment)
setData(model: comments)
}
var data = comment
data.date = Date().getDate()
data.user_id = self.userInfo!.id
var comments = fetchComment(shortcutID: shortcutID)
comments.comments.append(data)
setData(model: comments)
}

//대댓글 삭제 시 이용
func deleteComment(shortcutID: String, commentID: String) {
if var comments = fetchComment(shortcutID: shortcutID) {
comments.comments.removeAll(where: { $0.id == commentID })
setData(model: comments)
}
var comments = fetchComment(shortcutID: shortcutID)
comments.comments.removeAll(where: { $0.id == commentID })
setData(model: comments)
}

//원댓글 삭제 시 이용
func deleteCommentByBundleID(shortcutID: String, bundleID: String) {
if var comments = fetchComment(shortcutID: shortcutID) {
comments.comments.removeAll(where: { $0.bundel_id == bundleID })
setData(model: comments)
}
var comments = fetchComment(shortcutID: shortcutID)
comments.comments.removeAll(where: { $0.bundle_id == bundleID })
setData(model: comments)
}
}
18 changes: 14 additions & 4 deletions HappyAnding/HappyAnding/Views/Components/CurationListView.swift
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import SwiftUI

struct CurationListView: View {

@EnvironmentObject var shortcutsZipViewModel: ShortcutsZipViewModel
@State var data: NavigationListCurationType
@Binding var userCurations: [Curation]

@@ -41,17 +42,26 @@ struct CurationListView: View {
}

struct CurationListHeader: View {

@EnvironmentObject var shortcutsZipViewModel: ShortcutsZipViewModel
@Binding var userCurations: [Curation]

@State var data: NavigationListCurationType
let navigationParentView: NavigationParentView

var body: some View {
HStack(alignment: .bottom) {
Text(data.title ?? "")
.Title2()
.foregroundColor(.Gray5)
.onTapGesture { }
if data.type == .personalCuration {
Text("\(shortcutsZipViewModel.userInfo?.nickname ?? "")\(data.type.rawValue)")
.Title2()
.foregroundColor(.Gray5)
.onTapGesture { }
} else {
Text(data.title ?? "")
.Title2()
.foregroundColor(.Gray5)
.onTapGesture { }
}
Spacer()

NavigationLink(value: data) {
Original file line number Diff line number Diff line change
@@ -20,13 +20,22 @@ struct ExploreCurationView: View {
.padding(.top, 20)
.padding(.bottom, 32)

//나의 큐레이션
UserCurationListView(data: NavigationListCurationType(type: .myCuration,
title: "내가 작성한 큐레이션",
isAllUser: false,
navigationParentView: .curations),
userCurations: $shortcutsZipViewModel.curationsMadeByUser)
.padding(.bottom, 20)
//땡땡니을 위한 모음집
CurationListView(data: NavigationListCurationType(type: .personalCuration,
title: "",
isAllUser: false,
navigationParentView: .curations),
userCurations: $shortcutsZipViewModel.personalCurations)
.onAppear {
shortcutsZipViewModel.personalCurations.removeAll()
let personalCurationIDs = Set(shortcutsZipViewModel.shortcutsUserDownloaded.flatMap({ $0.curationIDs }))
for curationID in personalCurationIDs {
if let curation = shortcutsZipViewModel.userCurations.first(where: { $0.id == curationID }) {
shortcutsZipViewModel.personalCurations.append(curation)
}
}
}
.padding(.bottom, 32)

//추천 유저 큐레이션
CurationListView(data: NavigationListCurationType(type: .userCuration,
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import SwiftUI
enum CurationType: String {
case myCuration = "내가 작성한 큐레이션"
case userCuration = "큐레이션 모아보기"
case personalCuration = "님을 위한 모음집"
}

/**
Original file line number Diff line number Diff line change
@@ -43,12 +43,14 @@ struct ReadAdminCurationView: View {
titleAndSubtitle
.padding(.bottom, 8)

ForEach(Array(curation.shortcuts.enumerated()), id: \.offset) { index, shortcut in
let data = NavigationReadShortcutType(shortcutID: shortcut.id,
navigationParentView: .curations)
NavigationLink(value: data) {
ShortcutCell(shortcutCell: shortcut,
navigationParentView: .curations)
VStack(spacing: 0) {
ForEach(Array(curation.shortcuts.enumerated()), id: \.offset) { index, shortcut in
let data = NavigationReadShortcutType(shortcutID: shortcut.id,
navigationParentView: .curations)
NavigationLink(value: data) {
ShortcutCell(shortcutCell: shortcut,
navigationParentView: .curations)
}
}
}

Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ struct ReadUserCurationView: View {
}
.frame(minHeight: 371)

VStack{
VStack {
userInformation
.padding(.top, 103)
.padding(.bottom, 22)
@@ -44,16 +44,19 @@ struct ReadUserCurationView: View {
.padding(.bottom, 12)
}
}
ForEach(Array(self.data.userCuration.shortcuts.enumerated()), id: \.offset) { index, shortcut in
let data = NavigationReadShortcutType(shortcutID: shortcut.id,
navigationParentView: self.data.navigationParentView)

NavigationLink(value: data) {
ShortcutCell(shortcutCell: shortcut,
navigationParentView: self.data.navigationParentView)
.padding(.bottom, index == self.data.userCuration.shortcuts.count - 1 ? 44 : 0)
VStack(spacing: 0){
ForEach(Array(self.data.userCuration.shortcuts.enumerated()), id: \.offset) { index, shortcut in
let data = NavigationReadShortcutType(shortcutID: shortcut.id,
navigationParentView: self.data.navigationParentView)

NavigationLink(value: data) {
ShortcutCell(shortcutCell: shortcut,
navigationParentView: self.data.navigationParentView)
.padding(.bottom, index == self.data.userCuration.shortcuts.count - 1 ? 44 : 0)
}
}
}

}
.onChange(of: isWriting) { _ in
if !isWriting {
Original file line number Diff line number Diff line change
@@ -8,39 +8,54 @@
import SwiftUI

struct ReadShortcutCommentView: View {
@EnvironmentObject var shortcutsZipViewModel: ShortcutsZipViewModel
@Binding var addedComment: Comment
@State var comments = [Comment]()
@State var isReply = true
@Binding var comments: Comments
@Binding var nestedCommentInfoText: String
@State var isTappedDeleteButton = false
@State var deletedComment: Comment = Comment(user_nickname: "", user_id: "", date: "", depth: 0, contents: "")
let shortcutID: String

var body: some View {
VStack(alignment: .leading) {
if comments.isEmpty {
if comments.comments.isEmpty {
Text("등록된 댓글이 없습니다")
.Body2()
.foregroundColor(.Gray4)

} else {
comment
Spacer()
}
}
.padding(.top, 16)
.onAppear {
//TODO: 댓글 데이터 불러오기
for _ in 0...10 {
let comment = Comment(user_id: "1", date: "2022112211",
depth: Int.random(in: 0...1),
contents: "댓글을남겨요")
comments.append(comment)
.alert("댓글 삭제", isPresented: $isTappedDeleteButton) {
Button(role: .cancel) {

} label: {
Text("닫기")
}

Button(role: .destructive) {
if deletedComment.depth == 0 {
comments.comments.removeAll(where: { $0.bundle_id == deletedComment.bundle_id})
} else {
comments.comments.removeAll(where: { $0.id == deletedComment.id})
}

shortcutsZipViewModel.setData(model: comments)
} label: {
Text("삭제")
}
} message: {
Text("답글도 함께 삭제됩니다. 댓글을 삭제하시겠습니까?")
}
}

var comment: some View {
ForEach(comments, id: \.self) { comment in
ForEach(comments.comments, id: \.self) { comment in

HStack(alignment: .top, spacing: 8) {
if comment.depth == 0 {
if comment.depth == 1 {
Image(systemName: "arrow.turn.down.right")
.foregroundColor(.Gray4)
}
@@ -54,7 +69,7 @@ struct ReadShortcutCommentView: View {
.frame(width: 24, height: 24)
.foregroundColor(.Gray4)

Text(comment.user_id)
Text(comment.user_nickname)
.Body2()
.foregroundColor(.Gray4)
}
@@ -71,25 +86,26 @@ struct ReadShortcutCommentView: View {
// MARK: Button
HStack(spacing: 16) {
Button {
print("답글")
addedComment.bundel_id = comment.bundel_id
nestedCommentInfoText = comment.user_nickname
addedComment.bundle_id = comment.bundle_id
addedComment.depth = 1
} label: {
Text("답글")
.Footnote()
.foregroundColor(.Gray4)
}

Button {
print("수정")
} label: {
Text("수정")
.Footnote()
.foregroundColor(.Gray4)
}
// Button {
// print("수정")
// } label: {
// Text("수정")
// .Footnote()
// .foregroundColor(.Gray4)
// }

Button {
print("삭제")
isTappedDeleteButton.toggle()
deletedComment = comment
} label: {
Text("삭제")
.Footnote()
Original file line number Diff line number Diff line change
@@ -30,7 +30,9 @@ struct ReadShortcutView: View {
@State var isClickDownload = false

@State var data: NavigationReadShortcutType
@State var comment: Comment = Comment(user_id: "", date: "", depth: 0, contents: "")
@State var comments: Comments = Comments(id: "", comments: [])
@State var comment: Comment = Comment(user_nickname: "", user_id: "", date: "", depth: 0, contents: "")
@State var nestedCommentInfoText: String = ""

@State var height: CGFloat = UIScreen.screenHeight / 2
@State var currentTab: Int = 0
@@ -39,7 +41,7 @@ struct ReadShortcutView: View {
@Namespace var namespace

private let contentSize = UIScreen.screenHeight / 2
private let tabItems = ["기본 정보", "버전 정보"/*, "댓글"*/]
private let tabItems = ["기본 정보", "버전 정보", "댓글"]

var body: some View {
ScrollView {
@@ -78,41 +80,8 @@ struct ReadShortcutView: View {
}
}
.background(Color.Background)
.onAppear() {
data.shortcut = shortcutsZipViewModel.fetchShortcutDetail(id: data.shortcutID)
isMyLike = shortcutsZipViewModel.checkLikedShortrcut(shortcutID: data.shortcutID)
isFirstMyLike = isMyLike
}
.onAppear(perform: {UINavigationBar.appearance().standardAppearance.configureWithTransparentBackground() })
.onChange(of: isEdit) { _ in
if !isEdit {
data.shortcut = shortcutsZipViewModel.fetchShortcutDetail(id: data.shortcutID)
}
}
.onDisappear() {
if let shortcut = data.shortcut {
let isAlreadyContained = shortcutsZipViewModel.userInfo?.downloadedShortcuts.firstIndex(where: { $0.id == self.data.shortcutID}) == nil
if isClickDownload && isAlreadyContained {
shortcutsZipViewModel.updateNumberOfDownload(shortcut: shortcut)
shortcutsZipViewModel.shortcutsUserDownloaded.insert(shortcut, at: 0)

let downloadedShortcut = DownloadedShortcut(id: shortcut.id, downloadLink: shortcut.downloadLink[0])
shortcutsZipViewModel.userInfo?.downloadedShortcuts.insert(downloadedShortcut, at: 0)
}
if isMyLike != isFirstMyLike {
shortcutsZipViewModel.updateNumberOfLike(isMyLike: isMyLike, shortcut: shortcut)
if isMyLike {
shortcutsZipViewModel.userInfo?.likedShortcuts.insert(self.data.shortcutID, at: 0)
shortcutsZipViewModel.shortcutsUserLiked.insert(shortcut, at: 0)
} else {
shortcutsZipViewModel.userInfo?.likedShortcuts.removeAll(where: { $0 == self.data.shortcutID })
shortcutsZipViewModel.shortcutsUserLiked.removeAll(where: { $0.id == self.data.shortcutID })
}
}
}
}
.safeAreaInset(edge: .bottom, spacing: 0) {

VStack {
if currentTab == 2 {
textField
@@ -141,24 +110,28 @@ struct ReadShortcutView: View {
}
.ignoresSafeArea(.keyboard)
}
.background(Color.Background)
.onAppear() {
UINavigationBar.appearance().standardAppearance.configureWithTransparentBackground()
data.shortcut = shortcutsZipViewModel.fetchShortcutDetail(id: data.shortcutID)
isMyLike = shortcutsZipViewModel.checkLikedShortrcut(shortcutID: data.shortcutID)
isFirstMyLike = isMyLike
self.comments = shortcutsZipViewModel.fetchComment(shortcutID: data.shortcutID)
}
.onChange(of: isEdit || isUpdating) { _ in
if !isEdit || !isUpdating {
data.shortcut = shortcutsZipViewModel.fetchShortcutDetail(id: data.shortcutID)
}
}
.onChange(of: shortcutsZipViewModel.allComments) { _ in
self.comments = shortcutsZipViewModel.fetchComment(shortcutID: data.shortcutID)
}
.onDisappear() {
if let shortcut = data.shortcut {
let isAlreadyContained = shortcutsZipViewModel.userInfo?.downloadedShortcuts.firstIndex(where: { $0.id == self.data.shortcutID}) == nil
if isClickDownload && isAlreadyContained {
shortcutsZipViewModel.updateNumberOfDownload(shortcut: shortcut)
shortcutsZipViewModel.shortcutsUserDownloaded.insert(shortcut, at: 0)

let downloadedShortcut = DownloadedShortcut(id: shortcut.id, downloadLink: shortcut.downloadLink[0])
shortcutsZipViewModel.userInfo?.downloadedShortcuts.insert(downloadedShortcut, at: 0)
}
@@ -234,31 +207,69 @@ struct ReadShortcutView: View {
}

var textField: some View {
HStack {

VStack(spacing: 0) {
if comment.depth == 1 {
Image(systemName: "arrow.turn.down.right")
.foregroundColor(.Gray4)
nestedCommentInfo
}
TextField("댓글을 입력하세요", text: $commentText, axis: .vertical)
.Body2()
.focused($isFocused)

HStack {
if comment.depth == 1 {
Image(systemName: "arrow.turn.down.right")
.foregroundColor(.Gray4)
}
TextField("댓글을 입력하세요", text: $commentText, axis: .vertical)
.Body2()
.focused($isFocused)

Button {
comment.contents = commentText
comment.date = Date().getDate()
comment.user_id = shortcutsZipViewModel.userInfo!.id
comment.user_nickname = shortcutsZipViewModel.userInfo!.nickname
comments.comments.append(comment)
shortcutsZipViewModel.setData(model: comments)
commentText = ""
comment = comment.resetComment()
} label: {
Image(systemName: "paperplane.fill")
.foregroundColor(commentText == "" ? Color.Gray2 : Color.Gray5)
}
.disabled(commentText == "" ? true : false)
}
.padding(.vertical, 12)
.padding(.horizontal, 16)
.background(
Rectangle()
.fill(Color.Gray1)
.cornerRadius(12 ,corners: comment.depth == 0 ? .allCorners : [.bottomLeft, .bottomRight])
)
.padding(.horizontal, 16)
.padding(.bottom, 20)
}
}
var nestedCommentInfo: some View {
HStack {
Text("@ \(nestedCommentInfoText)")
.Footnote()
.foregroundColor(.Gray5)
Spacer()
Button {
//TODO: 서버에 데이터 전송
print("click")
comment.bundle_id = "\(Date().getDate())_\(UUID().uuidString)"
comment.depth = 0
} label: {
Image(systemName: "paperplane.fill")
Image(systemName: "xmark")
.font(Font(UIFont.systemFont(ofSize: 17, weight: .medium)))
.foregroundColor(.Gray5)
}
}
.padding(.vertical, 12)
.padding(.horizontal, 16)
.padding(.vertical, 11)
.background(
RoundedRectangle(cornerRadius: 12)
.fill(Color.Gray1)
Rectangle()
.fill(Color.Gray2)
.cornerRadius(12 ,corners: [.topLeft, .topRight])
)
.padding(.horizontal, 16)
.padding(.bottom, 20)
}
}

@@ -330,66 +341,65 @@ extension ReadShortcutView {

var detailInformationView: some View {
VStack {
if let shortcut = data.shortcut {
ZStack {
TabView(selection: self.$currentTab) {
Color.clear.tag(0)
Color.clear.tag(1)
Color.clear.tag(2)
}
.tabViewStyle(.page(indexDisplayMode: .never))
.frame(height: height)

switch(currentTab) {
case 0:
ReadShortcutContentView(shortcut: $data.shortcut.unwrap()!)
.background(
GeometryReader { geometryProxy in
Color.clear
.preference(key: SizePreferenceKey.self,
value: geometryProxy.size)
})
case 1:
ReadShortcutVersionView(shortcut: $data.shortcut.unwrap()!, isUpdating: $isUpdating)
.background(
GeometryReader { geometryProxy in
Color.clear
.preference(key: SizePreferenceKey.self, value:
geometryProxy.size)
})
// case 2:
// ReadShortcutCommentView(addedComment: $comment)
// .background(
// GeometryReader { geometryProxy in
// Color.clear
// .preference(key: SizePreferenceKey.self,
// value: geometryProxy.size)
// })
default:
EmptyView()
}
ZStack {
TabView(selection: self.$currentTab) {
Color.clear.tag(0)
Color.clear.tag(1)
Color.clear.tag(2)
}
.tabViewStyle(.page(indexDisplayMode: .never))
.frame(height: height)

.animation(.easeInOut, value: currentTab)
.onPreferenceChange(SizePreferenceKey.self) { newSize in
height = contentSize > newSize.height ? contentSize : newSize.height
switch(currentTab) {
case 0:
ReadShortcutContentView(shortcut: $data.shortcut.unwrap()!)
.background(
GeometryReader { geometryProxy in
Color.clear
.preference(key: SizePreferenceKey.self,
value: geometryProxy.size)
})
case 1:
ReadShortcutVersionView(shortcut: $data.shortcut.unwrap()!, isUpdating: $isUpdating)
.background(
GeometryReader { geometryProxy in
Color.clear
.preference(key: SizePreferenceKey.self, value:
geometryProxy.size)
})
case 2:
ReadShortcutCommentView(addedComment: $comment, comments: $comments, nestedCommentInfoText: $nestedCommentInfoText, shortcutID: data.shortcutID)
.background(
GeometryReader { geometryProxy in
Color.clear
.preference(key: SizePreferenceKey.self,
value: geometryProxy.size)
})
default:
EmptyView()
}
.gesture(DragGesture(minimumDistance: 20, coordinateSpace: .global)
.onEnded { value in
let horizontalAmount = value.translation.width
let verticalAmount = value.translation.height

if abs(horizontalAmount) > abs(verticalAmount) {
if horizontalAmount < 0 {
if currentTab < 2 {
currentTab += 1
}
}

.animation(.easeInOut, value: currentTab)
.onPreferenceChange(SizePreferenceKey.self) { newSize in
height = contentSize > newSize.height ? contentSize : newSize.height
}
.gesture(DragGesture(minimumDistance: 20, coordinateSpace: .global)
.onEnded { value in
let horizontalAmount = value.translation.width
let verticalAmount = value.translation.height

if abs(horizontalAmount) > abs(verticalAmount) {
if horizontalAmount < 0 {
if currentTab < 2 {
currentTab += 1
}
} else {
if currentTab > 0 {
currentTab -= 1
} else {
if currentTab > 0 {
currentTab -= 1
} else {

// MARK: Navigation pop 코드

// MARK: Navigation pop 코드
// print("swipe back")
// switch data.navigationParentView {
// case .shortcuts:
@@ -403,11 +413,10 @@ extension ReadShortcutView {
// case .writeShortcut:
// writeShortcutNavigation.navigationPath.removeLast()
// }
}
}
}
})
}
}
})
}
}

0 comments on commit 5b50d30

Please sign in to comment.