-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8078229
commit 8ca5f7b
Showing
29 changed files
with
403 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
App/Moda/Sources/Firebase/FirebaseRemoteConfiguration.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
App/Moda/Sources/Modifier/UpdateNotificationAlert/UpdateNotificationAlertModifier.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
App/Moda/Sources/Modifier/UpdateNotificationAlert/UpdateNotificationAlertView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
App/Moda/Sources/Modifier/UpdateNotificationAlert/UpdateNotificationManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.