Skip to content

Conversation

@insub4067
Copy link
Member

@insub4067 insub4067 commented Sep 12, 2022

  • json fetch 후 view에 data를 전달하는 구조로 refactoring 하였습니다

  • struct 를 codable 로 수정하였고 요청에 의해 구조가 수정되었습니다

@unnnyong
Copy link
Collaborator

diff --git a/AsyncSwift/Observed/EventDetailView+Observed.swift b/AsyncSwift/Observed/EventDetailView+Observed.swift
index cf01070..a91b44c 100644
--- a/AsyncSwift/Observed/EventDetailView+Observed.swift
+++ b/AsyncSwift/Observed/EventDetailView+Observed.swift
@@ -11,7 +11,11 @@ import EventKit
 extension EventDetailView {
     final class Observed: ObservableObject {

-        @Published var event = Event()
+        init(event: Event) {
+            self.event = event
+        }
+
+        @Published var event: Event
         @Published var isShowingSheet = false
         @Published var isShowingAddEventConfirmationAlert = false
         @Published var isShowingAddEventSuccessAlert = false
diff --git a/AsyncSwift/Views/EventDetailView.swift b/AsyncSwift/Views/EventDetailView.swift
index 4cb63d1..3bc215d 100644
--- a/AsyncSwift/Views/EventDetailView.swift
+++ b/AsyncSwift/Views/EventDetailView.swift
@@ -9,10 +9,10 @@ import SwiftUI

 struct EventDetailView: View {

-    @StateObject var observed = Observed()
+    @ObservedObject var observed: Observed

     init(event: Event) {
-//        self.observed.event = event
+        self.observed = Observed(event: event)
     }

     var body: some View {

예정된 행사, 진행중인 행사, 지나간 행사를
계산하고 화면을 그려주는 기능
@insub4067 insub4067 changed the title [init] [Feat] JsonParsing Sep 12, 2022
- Padding, Stack 등을 수정 디자인이 미흡하게 반영된 허점을 수정하였습니다
@song-cool song-cool added this to the v1.0 milestone Sep 13, 2022
.font(.title3)
.fontWeight(.semibold)
.padding(.vertical, 24)
VStack(alignment: .leading, spacing: 8) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VStack(alignment: .leading, spacing: 8) {
VStack(alignment: .leading) {

8이 default value였던 것 같아서 생략 가능할까요 ?

- Struct 구조 수정
- EventView+Observed 내부 변수 수정
- Portraint Mode Only
- Light Mode Only
Copy link
Collaborator

@unnnyong unnnyong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏


import Foundation

struct Event: Codable {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO로 get만 할 때는 Decodable도 되지 않을까 싶네요

guard let self = self else { return }
do {
let decodedData = try JSONDecoder().decode(Event.self, from: data)
withAnimation {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이게 트리거로 멋진 애니메이션이 나오는거였군요 👾

Copy link
Collaborator

@unnnyong unnnyong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

お疲れ様でした! 🍵 🍵 🍵 🍵

@insub4067 insub4067 merged commit 48dec52 into develop Sep 14, 2022
@insub4067 insub4067 deleted the JSONParsing branch September 14, 2022 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants