Primera build enviada
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import SwiftUI
|
||||
import StoreKit
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
struct SettingsView: View {
|
||||
private let iapService: IAPService
|
||||
@@ -67,6 +68,9 @@ struct SettingsView: View {
|
||||
.sheet(isPresented: $viewModel.showingExportOptions) {
|
||||
ExportOptionsSheet(viewModel: viewModel)
|
||||
}
|
||||
.sheet(item: $viewModel.shareItem) { shareItem in
|
||||
ActivityView(activityItems: [shareItem.url])
|
||||
}
|
||||
.sheet(isPresented: $viewModel.showingImportSheet) {
|
||||
ImportDataView()
|
||||
}
|
||||
@@ -578,6 +582,22 @@ struct SettingsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Activity View
|
||||
|
||||
struct ActivityView: UIViewControllerRepresentable {
|
||||
let activityItems: [Any]
|
||||
let applicationActivities: [UIActivity]? = nil
|
||||
|
||||
func makeUIViewController(context: Context) -> UIActivityViewController {
|
||||
UIActivityViewController(
|
||||
activityItems: activityItems,
|
||||
applicationActivities: applicationActivities
|
||||
)
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
|
||||
}
|
||||
|
||||
// MARK: - Export Options Sheet
|
||||
|
||||
struct ExportOptionsSheet: View {
|
||||
@@ -587,59 +607,75 @@ struct ExportOptionsSheet: View {
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
List {
|
||||
Section {
|
||||
Button {
|
||||
viewModel.exportData(format: .csv)
|
||||
dismiss()
|
||||
} label: {
|
||||
HStack {
|
||||
Image(systemName: "tablecells")
|
||||
.foregroundColor(.positiveGreen)
|
||||
.frame(width: 30)
|
||||
if viewModel.isExporting {
|
||||
Section {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
ProgressView(value: viewModel.exportProgress)
|
||||
.progressViewStyle(.linear)
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text("CSV")
|
||||
.font(.headline)
|
||||
Text("Compatible with Excel, Google Sheets")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
Text(viewModel.exportStatus)
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.padding(.vertical, 8)
|
||||
} header: {
|
||||
Text("Exporting...")
|
||||
}
|
||||
} else {
|
||||
Section {
|
||||
Button {
|
||||
viewModel.exportData(format: .csv)
|
||||
} label: {
|
||||
HStack {
|
||||
Image(systemName: "tablecells")
|
||||
.foregroundColor(.positiveGreen)
|
||||
.frame(width: 30)
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text("CSV")
|
||||
.font(.headline)
|
||||
Text("Compatible with Excel, Google Sheets")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
viewModel.exportData(format: .json)
|
||||
dismiss()
|
||||
} label: {
|
||||
HStack {
|
||||
Image(systemName: "doc.text")
|
||||
.foregroundColor(.appPrimary)
|
||||
.frame(width: 30)
|
||||
Button {
|
||||
viewModel.exportData(format: .json)
|
||||
} label: {
|
||||
HStack {
|
||||
Image(systemName: "doc.text")
|
||||
.foregroundColor(.appPrimary)
|
||||
.frame(width: 30)
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text("JSON")
|
||||
.font(.headline)
|
||||
Text("Full data structure for backup")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
VStack(alignment: .leading) {
|
||||
Text("JSON")
|
||||
.font(.headline)
|
||||
Text("Full data structure for backup")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
Text("Select Format")
|
||||
}
|
||||
} header: {
|
||||
Text("Select Format")
|
||||
}
|
||||
}
|
||||
.navigationTitle("Export Data")
|
||||
.navigationTitle(viewModel.isExporting ? "Exporting" : "Export Data")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button("Cancel") {
|
||||
dismiss()
|
||||
}
|
||||
.disabled(viewModel.isExporting)
|
||||
}
|
||||
}
|
||||
}
|
||||
.presentationDetents([.medium])
|
||||
.interactiveDismissDisabled(viewModel.isExporting)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user