diff --git a/DDooing/DDooing.xcodeproj/project.pbxproj b/DDooing/DDooing.xcodeproj/project.pbxproj index ad63f8b..b13e2a7 100644 --- a/DDooing/DDooing.xcodeproj/project.pbxproj +++ b/DDooing/DDooing.xcodeproj/project.pbxproj @@ -45,6 +45,8 @@ 4F3F81422BFE10AE008C920C /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF515932BF33F810056531C /* HomeView.swift */; }; 4F3F81542BFE63CA008C920C /* AppModelContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F3F81532BFE63CA008C920C /* AppModelContainer.swift */; }; 4F3F81552BFE63CA008C920C /* AppModelContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F3F81532BFE63CA008C920C /* AppModelContainer.swift */; }; + 4F8D878D2BFF864F006BEF4A /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4F8D878C2BFF84DF006BEF4A /* GoogleService-Info.plist */; }; + 4F8D878E2BFF8650006BEF4A /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4F8D878C2BFF84DF006BEF4A /* GoogleService-Info.plist */; }; 4FAD25B02BF3339A00EBD37A /* DDooingApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FAD25AF2BF3339A00EBD37A /* DDooingApp.swift */; }; 4FAD25B22BF3339A00EBD37A /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FAD25B12BF3339A00EBD37A /* MainView.swift */; }; 4FAD25B42BF3339B00EBD37A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FAD25B32BF3339B00EBD37A /* Assets.xcassets */; }; @@ -138,7 +140,7 @@ 4F3F813B2BFDDCEC008C920C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4F3F813D2BFDDDE2008C920C /* WidgetColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetColor.swift; sourceTree = ""; }; 4F3F81532BFE63CA008C920C /* AppModelContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppModelContainer.swift; sourceTree = ""; }; - 4F3F81582BFECEBA008C920C /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; + 4F8D878C2BFF84DF006BEF4A /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 4FAD25AC2BF3339A00EBD37A /* DDooing.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DDooing.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4FAD25AF2BF3339A00EBD37A /* DDooingApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DDooingApp.swift; sourceTree = ""; }; 4FAD25B12BF3339A00EBD37A /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = ""; }; @@ -322,7 +324,7 @@ 4FAD25A32BF3339A00EBD37A = { isa = PBXGroup; children = ( - 4F3F81582BFECEBA008C920C /* GoogleService-Info.plist */, + 4F8D878C2BFF84DF006BEF4A /* GoogleService-Info.plist */, 4FBE64CB2BFDCB80008363A0 /* DDooingWidgetExtension.entitlements */, 4FAD25AE2BF3339A00EBD37A /* DDooing */, 4FAD25BF2BF3339B00EBD37A /* DDooingTests */, @@ -387,7 +389,6 @@ 4FBE64AE2BFDA19E008363A0 /* Recovered References */ = { isa = PBXGroup; children = ( - 9F2C6FE52BFD76A000B5C7A7 /* GoogleService-Info.plist */, ); name = "Recovered References"; sourceTree = ""; @@ -415,13 +416,6 @@ name = Frameworks; sourceTree = ""; }; - 790BA2342BFDCFD100A1E364 /* Recovered References */ = { - isa = PBXGroup; - children = ( - ); - name = "Recovered References"; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -570,12 +564,11 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4F8D878D2BFF864F006BEF4A /* GoogleService-Info.plist in Resources */, 4FAD25B72BF3339B00EBD37A /* Preview Assets.xcassets in Resources */, 4F1A59492BF8892000C3EF2C /* Pretendard-Bold.otf in Resources */, - 9F2C6FE62BFD76A000B5C7A7 /* GoogleService-Info.plist in Resources */, 4F3F813C2BFDDCEC008C920C /* Assets.xcassets in Resources */, 4F1A59432BF8892000C3EF2C /* Pretendard-Regular.otf in Resources */, - 10CAF9592BFE66AE00318EB0 /* GoogleService-Info.plist in Resources */, 4F1A59552BF8892000C3EF2C /* Pretendard-SemiBold.otf in Resources */, 4F1A594C2BF8892000C3EF2C /* Pretendard-Thin.otf in Resources */, 4F1A594F2BF8892000C3EF2C /* Pretendard-Black.otf in Resources */, @@ -624,6 +617,7 @@ buildActionMask = 2147483647; files = ( 4F3F813F2BFDDEDC008C920C /* Assets.xcassets in Resources */, + 4F8D878E2BFF8650006BEF4A /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/DDooing/DDooing/Views/Home/HomeView.swift b/DDooing/DDooing/Views/Home/HomeView.swift index 3a4d42c..610ed8e 100644 --- a/DDooing/DDooing/Views/Home/HomeView.swift +++ b/DDooing/DDooing/Views/Home/HomeView.swift @@ -32,7 +32,6 @@ struct HomeView: View { var body: some View { NavigationStack{ VStack { - Image("Heart button") .resizable() .aspectRatio(contentMode: .fit) diff --git a/DDooing/DDooing/Views/ShowMessage/ShowMessageView.swift b/DDooing/DDooing/Views/ShowMessage/ShowMessageView.swift index c5a2cac..1acfe70 100644 --- a/DDooing/DDooing/Views/ShowMessage/ShowMessageView.swift +++ b/DDooing/DDooing/Views/ShowMessage/ShowMessageView.swift @@ -31,9 +31,7 @@ struct ShowMessageView: View { var body: some View { NavigationStack { VStack { - Spacer() - HStack { Text("오늘의 메세지") .font(.largeTitle.bold()) @@ -41,16 +39,14 @@ struct ShowMessageView: View { } .padding() .padding(.top, 10) - Spacer() - ScrollView { Image(imageName(for: recivedMessages.count)) .resizable() .frame(width: 140, height: 130) .scaledToFill() - + Text("오늘 받은 메세지만 확인할 수 있습니다.") .font(.pretendardThin14) .foregroundStyle(.secondary) @@ -62,7 +58,7 @@ struct ShowMessageView: View { Text("아직 받은 메세지가 없어요 ( ⚈̥̥̥̥̥́⌢⚈̥̥̥̥̥̀)") .font(.pretendardRegular16) .frame(width: 400,height: 400) - + } else { ForEach(recivedMessages.sorted(by: { $0.time > $1.time })) { message in @@ -107,26 +103,26 @@ struct ShowMessageView: View { } else { Spacer() } - Text(formattedTime(from: message.time)) - .foregroundStyle(.secondary) - .font(.footnote) - .padding(.trailing, 20) + Text(formattedTime(from: message.time)) + .foregroundStyle(.secondary) + .font(.footnote) + .padding(.trailing, 20) + } + .padding(.top, 20) } - .padding(.top, 20) } } } - } - .onAppear { - addObserveMessages() - - if let user = Auth.auth().currentUser { - self.checkAndDeleteOldMessages(userAUID: user.uid) + .onAppear { + addObserveMessages() + + if let user = Auth.auth().currentUser { + self.checkAndDeleteOldMessages(userAUID: user.uid) + } } } } } - // 메세지 개수에 따른 이미지 변경 함수 func imageName(for messageCount: Int) -> String { switch messageCount { @@ -150,45 +146,44 @@ struct ShowMessageView: View { private func addObserveMessages() { observeMessages { messageData in if let text = messageData["messageText"] as? String, - let timestamp = messageData["timeStamp"] as? Timestamp, - let isStarred = messageData["isStarred"] as? Bool, - let messageId = messageData["messageId"] as? String { - self.fetchMyConnectedNickname { nickname in - // 중복 체크: 이미 추가된 메시지인지 확인 - if !self.recivedMessages.contains(where: { $0.messageId == messageId }) { - let message = RecivedMessage(messageId: messageId, name: nickname, text: text, time: timestamp.dateValue(), isStarred: isStarred) - self.recivedMessages.append(message) - } + let timestamp = messageData["timeStamp"] as? Timestamp, + let isStarred = messageData["isStarred"] as? Bool, + let messageId = messageData["messageId"] as? String { + self.fetchMyConnectedNickname { nickname in + // 중복 체크: 이미 추가된 메시지인지 확인 + if !self.recivedMessages.contains(where: { $0.messageId == messageId }) { + let message = RecivedMessage(messageId: messageId, name: nickname, text: text, time: timestamp.dateValue(), isStarred: isStarred) + self.recivedMessages.append(message) } } + } } // db에서 메세지가 삭제되면 뷰에서도 삭제되게 하기 observeMessages { messageData, documentID, changeType in if let text = messageData["messageText"] as? String, - let timestamp = messageData["timeStamp"] as? Timestamp, - let isStarred = messageData["isStarred"] as? Bool, - let messageId = messageData["messageId"] as? String { - self.fetchMyConnectedNickname { nickname in - switch changeType { - case .added: - if !self.recivedMessages.contains(where: { $0.messageId == messageId }) { - let message = RecivedMessage(messageId: messageId, name: nickname, text: text, time: timestamp.dateValue(), isStarred: isStarred) - self.recivedMessages.append(message) - } - case .removed: - if let index = self.recivedMessages.firstIndex(where: { $0.messageId == messageId }) { - self.recivedMessages.remove(at: index) - } - default: - break + let timestamp = messageData["timeStamp"] as? Timestamp, + let isStarred = messageData["isStarred"] as? Bool, + let messageId = messageData["messageId"] as? String { + self.fetchMyConnectedNickname { nickname in + switch changeType { + case .added: + if !self.recivedMessages.contains(where: { $0.messageId == messageId }) { + let message = RecivedMessage(messageId: messageId, name: nickname, text: text, time: timestamp.dateValue(), isStarred: isStarred) + self.recivedMessages.append(message) + } + case .removed: + if let index = self.recivedMessages.firstIndex(where: { $0.messageId == messageId }) { + self.recivedMessages.remove(at: index) } + default: + break } } + } } } - func observeMessages(completion: @escaping ([String: Any]) -> Void) { let db = Firestore.firestore() @@ -285,6 +280,7 @@ struct ShowMessageView: View { + #Preview { ShowMessageView(partnerUID: nil) } diff --git a/DDooing/DDooingWidget/DDooingWidget.swift b/DDooing/DDooingWidget/DDooingWidget.swift index 6de644e..32586a5 100644 --- a/DDooing/DDooingWidget/DDooingWidget.swift +++ b/DDooing/DDooingWidget/DDooingWidget.swift @@ -69,6 +69,9 @@ struct SimpleEntry: TimelineEntry { } struct DDooingWidget: Widget { + init() { + FirebaseApp.configure() + } let kind: String = "DDooingWidget" diff --git a/DDooing/GoogleService-Info.plist b/DDooing/GoogleService-Info.plist deleted file mode 100644 index 47231dc..0000000 --- a/DDooing/GoogleService-Info.plist +++ /dev/null @@ -1,36 +0,0 @@ - - - - - CLIENT_ID - 752780593979-1avvvfte69oookeoh9lqjk6o2mmtu7b3.apps.googleusercontent.com - REVERSED_CLIENT_ID - com.googleusercontent.apps.752780593979-1avvvfte69oookeoh9lqjk6o2mmtu7b3 - API_KEY - AIzaSyAwf1U7zVB9zrctnZmQtRqbAaE7BdMYA7k - GCM_SENDER_ID - 752780593979 - PLIST_VERSION - 1 - BUNDLE_ID - com.iOSDevJoy.DDooing - PROJECT_ID - ddooing-8881b - STORAGE_BUCKET - ddooing-8881b.appspot.com - IS_ADS_ENABLED - - IS_ANALYTICS_ENABLED - - IS_APPINVITE_ENABLED - - IS_GCM_ENABLED - - IS_SIGNIN_ENABLED - - GOOGLE_APP_ID - 1:752780593979:ios:10788a37714cbc50dac51e - DATABASE_URL - https://ddooing-8881b-default-rtdb.firebaseio.com - - \ No newline at end of file