不跟系统的暗黑模式,保持light模式;增加本地日志的读取;接入firebase
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
|
||||
import SwiftUI
|
||||
import ToastUI
|
||||
import FirebaseAnalytics
|
||||
|
||||
fileprivate struct BuyProView: View {
|
||||
var onTryForFree: () -> Void
|
||||
@ -27,6 +28,12 @@ fileprivate struct BuyProView: View {
|
||||
// 按钮动作
|
||||
// 触发显示VIP付费界面的事件
|
||||
onTryForFree()
|
||||
|
||||
// 记录事件
|
||||
Analytics.logEvent(globalAnalyticsEvents.eventEnterPurchase, parameters: [
|
||||
globalAnalyticsEvents.keyPurchaseEntry: globalAnalyticsEvents.valEntryBuyProBtn as NSObject,
|
||||
globalAnalyticsEvents.keyDeviceID: globalEnvironment.deviceID as NSObject
|
||||
])
|
||||
}
|
||||
.padding(.vertical, 6) // 调整高度为默认高度的2/3
|
||||
.padding(.horizontal, 20)
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
// Created by oscar on 2024/7/9.
|
||||
//
|
||||
import SwiftUI
|
||||
import FirebaseAnalytics
|
||||
|
||||
struct VIPPaymentView: View {
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
@ -159,6 +160,13 @@ struct VIPPaymentView: View {
|
||||
private func buyProduct() {
|
||||
let productId = products[selectedProductIndex].4
|
||||
logger.info("selected productId: \(productId.rawValue)")
|
||||
|
||||
// 记录事件
|
||||
Analytics.logEvent(globalAnalyticsEvents.eventPurchase, parameters: [
|
||||
globalAnalyticsEvents.keyPurchaseItem: productId.rawValue as NSObject,
|
||||
globalAnalyticsEvents.keyDeviceID: globalEnvironment.deviceID as NSObject
|
||||
])
|
||||
|
||||
if let product = iapManager.products.first(where: { $0.id == productId.rawValue }) {
|
||||
Task {
|
||||
await iapManager.buy(product: product) { result in
|
||||
|
||||
@ -9,6 +9,8 @@ import SwiftUI
|
||||
import ToastUI
|
||||
|
||||
import SafariServices
|
||||
import FirebaseAnalytics
|
||||
import SwiftyBeaver
|
||||
|
||||
struct FullScreenSafariView: UIViewControllerRepresentable {
|
||||
let url: URL
|
||||
@ -60,6 +62,8 @@ struct SettingsView: View {
|
||||
@State private var useSandboxEnvironment = false
|
||||
@State private var useDevelopmentEnvironment = false
|
||||
|
||||
@State private var showingLogShareSheet = false
|
||||
@State private var logFileURL: URL?
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
@ -69,6 +73,12 @@ struct SettingsView: View {
|
||||
settingItem(icon: "arrow.up.circle", text: "Upgrade to Premium", isBold: true)
|
||||
.onTapGesture {
|
||||
showVIPPaymentView = true
|
||||
|
||||
// 记录事件
|
||||
Analytics.logEvent(globalAnalyticsEvents.eventEnterPurchase, parameters: [
|
||||
globalAnalyticsEvents.keyPurchaseEntry: globalAnalyticsEvents.valEntrySettingsBtn as NSObject,
|
||||
globalAnalyticsEvents.keyDeviceID: globalEnvironment.deviceID as NSObject
|
||||
])
|
||||
}
|
||||
|
||||
// Feedback
|
||||
@ -114,10 +124,31 @@ struct SettingsView: View {
|
||||
VStack {
|
||||
Toggle("Sandbox", isOn: $useSandboxEnvironment)
|
||||
Toggle("TestEnv", isOn: $useDevelopmentEnvironment)
|
||||
Button("Save") {
|
||||
saveSettings()
|
||||
showingAdvancedSettings = false
|
||||
HStack {
|
||||
Button("View Logs") {
|
||||
if let logURL = getLogFileURL() {
|
||||
if FileManager.default.fileExists(atPath: logURL.path) {
|
||||
logger.info("Log file exists: \(logURL.path)")
|
||||
self.logFileURL = logURL
|
||||
self.showingLogShareSheet = true
|
||||
} else {
|
||||
logger.error("Log file does not exist.")
|
||||
self.toastText = "Log file not found."
|
||||
self.showingToast = true
|
||||
}
|
||||
} else {
|
||||
self.toastText = "Log file not found."
|
||||
self.showingToast = true
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
Button("Save") {
|
||||
saveSettings()
|
||||
showingAdvancedSettings = false
|
||||
}
|
||||
}
|
||||
.padding(.horizontal,15)
|
||||
.padding(.top, 15)
|
||||
}
|
||||
.padding(.vertical,10)
|
||||
.padding(.horizontal, 20)
|
||||
@ -135,6 +166,11 @@ struct SettingsView: View {
|
||||
self.showingAdvancedSettings = false // 确保隐藏组件在视图消失时不显示
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showingLogShareSheet) {
|
||||
if let url = logFileURL {
|
||||
ShareSheetLog(activityItems: [url])
|
||||
}
|
||||
}
|
||||
.toast(isPresented: $showingToast, dismissAfter: globalEnvironment.toastPresentMsNormal) {
|
||||
HStack {
|
||||
Image(systemName: "exclamationmark.bubble")
|
||||
@ -152,12 +188,12 @@ struct SettingsView: View {
|
||||
LoadingView()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 定义隐藏功能
|
||||
private var gestureArea: some View {
|
||||
Color.clear
|
||||
.contentShape(Rectangle()) // 为透明色定义一个矩形可命中区域
|
||||
.frame(height: 150) // 可以根据需要调整手势区域的大小
|
||||
.frame(height: 50) // 可以根据需要调整手势区域的大小
|
||||
.gesture(
|
||||
DragGesture(minimumDistance: 50, coordinateSpace: .global)
|
||||
.onEnded { value in
|
||||
@ -229,6 +265,20 @@ struct SettingsView: View {
|
||||
|
||||
}
|
||||
|
||||
|
||||
struct ShareSheetLog: UIViewControllerRepresentable {
|
||||
var activityItems: [Any]
|
||||
|
||||
func makeUIViewController(context: Context) -> UIActivityViewController {
|
||||
let controller = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
|
||||
return controller
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {
|
||||
// Nothing to update here
|
||||
}
|
||||
}
|
||||
|
||||
struct SettingsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SettingsView()
|
||||
|
||||
Reference in New Issue
Block a user