Skip to content

Commit

Permalink
업데이트 유도 팝업 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ghkdemrdus committed Oct 27, 2024
1 parent 8078229 commit 8ca5f7b
Show file tree
Hide file tree
Showing 29 changed files with 403 additions and 72 deletions.
2 changes: 1 addition & 1 deletion App/Moda/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>CFBundleShortVersionString</key>
<string>1.1.0</string>
<key>CFBundleVersion</key>
<string>1.1.0.4</string>
<string>1.2.0.0</string>
<key>GoogleServiceFileName</key>
<string>$(ENV_GOOGLE_INFO_PLIST)</string>
<key>ITSAppUsesNonExemptEncryption</key>
Expand Down
5 changes: 5 additions & 0 deletions App/Moda/Resources/FirebaseRemoteConfigDefaults.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
10 changes: 5 additions & 5 deletions App/Moda/Resources/GoogleService-Debug-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>AIzaSyCmBBRh_wg9otAnUZR8eVAPdKz3zq20SDE</string>
<string>AIzaSyCsevHzMHryAGUYJ5tXs01s3oPb24OdzWs</string>
<key>GCM_SENDER_ID</key>
<string>632358549337</string>
<string>236283048119</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.pinto.moda.debug</string>
<key>PROJECT_ID</key>
<string>moda-pinto</string>
<string>modadebug</string>
<key>STORAGE_BUCKET</key>
<string>moda-pinto.appspot.com</string>
<string>modadebug.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
Expand All @@ -25,6 +25,6 @@
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:632358549337:ios:0d0e6a1084f873fb68be48</string>
<string>1:236283048119:ios:f4372ca59a1c2364fedd32</string>
</dict>
</plist>
13 changes: 13 additions & 0 deletions App/Moda/Sources/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import FirebaseCore
import FirebaseRemoteConfig
import SwiftUI

final class AppDelegate: NSObject, UIApplicationDelegate {
Expand All @@ -17,8 +18,20 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
if let filename = Bundle.main.googleServiceFileName,
let path = Bundle.main.path(forResource: filename, ofType: "plist"),
let fileopts = FirebaseOptions(contentsOfFile: path) {

FirebaseApp.configure(options: fileopts)
}

let remoteConfig = RemoteConfig.remoteConfig()
let settings = RemoteConfigSettings()
#if DEBUG
settings.minimumFetchInterval = 60 * 1
#else
settings.minimumFetchInterval = 60 * 60
#endif
remoteConfig.configSettings = settings
remoteConfig.setDefaults(fromPlist: "FirebaseRemoteConfigDefaults")
remoteConfig.fetchAndActivate()
return true
}

Expand Down
2 changes: 2 additions & 0 deletions App/Moda/Sources/App/ModaApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct ModaApp: App {
RootView()
.globalToast()
.globalBottomSheet()
.versionNoticeAlert()
.updateNotificationAlert()
.modelContainer(todoModelContainer)
.onAppear {
UITextField.appearance().tintColor = UIColor(.brandStrong)
Expand Down
40 changes: 40 additions & 0 deletions App/Moda/Sources/Firebase/FirebaseRemoteConfiguration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// FirebaseRemoteConfiguration.swift
// Moda
//
// Created by 황득연 on 10/27/24.
// Copyright © 2024 Moda. All rights reserved.
//

import FirebaseRemoteConfig
import ComposableArchitecture

final class FirebaseRemoteConfiguration {
var updateNotification: UpdateNotification? {
let value = RemoteConfig.remoteConfig().configValue(forKey: "updateNotification").stringValue
print(value)
if let data = value.data(using: .utf8), let result = try? JSONDecoder().decode(UpdateNotification.self, from: data) {
return result
}
return nil
}
}

struct UpdateNotification: Codable {
let lastestVersion: String
let imageURL: String
let description: String
}

// MARK: - Dependency

extension DependencyValues {
var remoteConfig: FirebaseRemoteConfiguration {
get { self[FirebaseRemoteConfiguration.self] }
set { self[FirebaseRemoteConfiguration.self] = newValue }
}
}

extension FirebaseRemoteConfiguration: DependencyKey {
public static let liveValue = FirebaseRemoteConfiguration()
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ struct BookmarkTodoInputBottomSheet: View {
case memo
}

@State var todo: BookmarkTodo = .init(content: "")
@Binding var isPresented: Bool
@Binding var todo: BookmarkTodo

@State var isExternalLinkActive: Bool = false
@State var isMemoActive: Bool = false
Expand All @@ -26,26 +27,24 @@ struct BookmarkTodoInputBottomSheet: View {

@State var isDismissing: Bool = false

@Binding var isPresented: Bool
@FocusState var focused: Option?

let bookmark: Bookmark
let initialTodo: BookmarkTodo
let isAdding: Bool
let onConfirm: (Bookmark, BookmarkTodo) -> Void
let onDismiss: () -> Void

init(
isPresented: Binding<Bool>,
bookmark: Bookmark,
todo: BookmarkTodo,
todo: Binding<BookmarkTodo>,
isAdding: Bool = true,
onConfirm: @escaping (Bookmark, BookmarkTodo) -> Void,
onDismiss: @escaping () -> Void
) {
self._isPresented = isPresented
self.bookmark = bookmark
self.initialTodo = todo
self._todo = todo
self.isAdding = isAdding
self.onConfirm = onConfirm
self.onDismiss = onDismiss
Expand All @@ -58,9 +57,6 @@ struct BookmarkTodoInputBottomSheet: View {
focused = .content
}
}
.onChange(of: initialTodo) {
initializeTodo(prev: $1)
}
}

private func initializeTodo(prev: BookmarkTodo) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// UpdateNotificationAlertModifier.swift
// Moda
//
// Created by 황득연 on 10/27/24.
// Copyright © 2024 Moda. All rights reserved.
//

import SwiftUI

struct UpdateNotificationAlertModifier: ViewModifier {

@ObservedObject var manager = UpdateNotificationManager.shared

func body(content: Content) -> some View {
ZStack {
content

ZStack {
Color.black
.ignoresSafeArea()
.opacity(manager.isPresented ? 0.5 : 0)
.onTapGesture {}

if manager.isPresented {
UpdateNotificationAlertView(
config: manager.config,
onClose: {
manager.dismiss()
}
)
.zIndex(1)
}
}
.animation(.spring(duration: 0.4), value: manager.isPresented)
.ignoresSafeArea(edges: .bottom)
}
}
}

public extension View {
func updateNotificationAlert() -> some View {
modifier(UpdateNotificationAlertModifier())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//
// UpdateNotificationAlertView.swift
// Moda
//
// Created by 황득연 on 10/27/24.
// Copyright © 2024 Moda. All rights reserved.
//

import SwiftUI

struct UpdateNotificationAlertView: View {

let config: UpdateNotificationManager.Configuration

let onClose: () -> Void

init(
config: UpdateNotificationManager.Configuration,
onClose: @escaping () -> Void
) {
self.config = config
self.onClose = onClose
}

var body: some View {
VStack(spacing: 0) {
AsyncImage(
url: URL(string: config.imageURL),
content: {
$0.resizable()
.scaledToFit()
.frame(maxWidth: .infinity)
.clipped()
.overlay(alignment: .topTrailing) {
PlainButton {
onClose()
} label: {
Image.icClose
.padding(.top, 24)
.padding(.trailing, 16)
}
}
},
placeholder: {
Color.clear
.frame(maxWidth: .infinity)
.aspectRatio(320 / 256, contentMode: .fit)
.overlay {
ProgressView()
}
}
)

Text(config.description)
.font(.spoqaHans(size: 13))
.foregroundStyle(Color.textSecondary)
.padding(16)
.multilineTextAlignment(.center)

PlainButton(
action: {
URLOpener.openAppStore()
onClose()
},
label: {
Text("좋아요!")
.font(.spoqaHans(size: 16, weight: .bold))
.foregroundStyle(.white)
.frame(maxWidth: .infinity)
.padding(.vertical, 14)
.background(
RoundedRectangle(cornerRadius: 12)
.fill(Color.brandStrong)
)
}
)
.padding(.top, 8)
.padding([.bottom, .horizontal], 16)
}
.background(Color.backgroundPrimary)
.clipShape(
RoundedRectangle(cornerRadius: 16)
)
// .background(
// RoundedRectangle(cornerRadius: 16)
// .fill(Color.backgroundPrimary)
// )
// .clipped()
.padding(.horizontal, 35)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// UpdateNotificationManager.swift
// Moda
//
// Created by 황득연 on 10/27/24.
// Copyright © 2024 Moda. All rights reserved.
//

import SwiftUI

@MainActor
public final class UpdateNotificationManager: ObservableObject {

public struct Configuration {
public let imageURL: String
public let description: String
}

public static let shared = UpdateNotificationManager()
private init() {}

@Published public private(set) var isPresented: Bool = false
public var config: Configuration = .init(imageURL: "", description: "")
private var continuation: CheckedContinuation<Void, Never>?

public func show(config: Configuration) async {
self.config = config
self.isPresented = true
return await withCheckedContinuation { continuation in
self.continuation = continuation
}
}

public func dismiss() {
isPresented = false
continuation?.resume()
continuation = nil
}
}
4 changes: 1 addition & 3 deletions App/Moda/Sources/Root/Base/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ struct RootView: View {
}
.colorScheme(customColorScheme ?? colorScheme)
.onReceive(userData.displayMode.$value) { mode in
withAnimation(.spring(duration: 0.4)) {
customColorScheme = mode.colorScheme
}
customColorScheme = mode.colorScheme
}
}
}
8 changes: 1 addition & 7 deletions App/Moda/Sources/Root/Bookmark/BookmarkCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ struct BookmarkCore: Reducer {
enum Action: ViewAction {
case view(View)
case todoAdded(Bookmark, BookmarkTodo)
case transientCleared

case edit(BookmarkEditCore.Action)
case todoEdit(BookmarkTodoEditCore.Action)
Expand Down Expand Up @@ -93,7 +92,7 @@ struct BookmarkCore: Reducer {
}

case .editTapped:
let bookmarks = state.bookmarks.isEmpty ? [.init(title: "")] : state.bookmarks
let bookmarks = state.bookmarks
state.edit = .init(bookmarks: bookmarks)
state.isEditPresented = true
return .none
Expand Down Expand Up @@ -147,11 +146,6 @@ struct BookmarkCore: Reducer {
state.isTodoAddBottomSheetPresented = false
return .none

case .transientCleared:
// state.addedBookmark = nil
// state.addedTodo = nil
return .none

case let .edit(childAction):
switch childAction {
case let .view(.doneTapped(bookmarks)):
Expand Down
Loading

0 comments on commit 8ca5f7b

Please sign in to comment.