Add monthly check-in sharing
This commit is contained in:
@@ -6,6 +6,29 @@ class ShareService {
|
|||||||
|
|
||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
|
func shareText(_ content: String) {
|
||||||
|
guard let viewController = ShareService.topViewController() else { return }
|
||||||
|
|
||||||
|
let activityVC = UIActivityViewController(
|
||||||
|
activityItems: [content],
|
||||||
|
applicationActivities: nil
|
||||||
|
)
|
||||||
|
|
||||||
|
if let popover = activityVC.popoverPresentationController {
|
||||||
|
popover.sourceView = viewController.view
|
||||||
|
popover.sourceRect = CGRect(
|
||||||
|
x: viewController.view.bounds.midX,
|
||||||
|
y: viewController.view.bounds.midY,
|
||||||
|
width: 0,
|
||||||
|
height: 0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
viewController.present(activityVC, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func shareTextFile(content: String, fileName: String) {
|
func shareTextFile(content: String, fileName: String) {
|
||||||
guard let viewController = ShareService.topViewController() else { return }
|
guard let viewController = ShareService.topViewController() else { return }
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,15 @@ struct MonthlyCheckInView: View {
|
|||||||
}
|
}
|
||||||
.navigationTitle("Monthly Check-in")
|
.navigationTitle("Monthly Check-in")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
.toolbar {
|
||||||
|
ToolbarItem(placement: .navigationBarTrailing) {
|
||||||
|
Button {
|
||||||
|
shareMonthlyCheckIn()
|
||||||
|
} label: {
|
||||||
|
Image(systemName: "square.and.arrow.up")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
viewModel.selectedAccount = accountStore.selectedAccount
|
viewModel.selectedAccount = accountStore.selectedAccount
|
||||||
viewModel.showAllAccounts = accountStore.showAllAccounts
|
viewModel.showAllAccounts = accountStore.showAllAccounts
|
||||||
@@ -444,6 +453,30 @@ struct MonthlyCheckInView: View {
|
|||||||
.cornerRadius(AppConstants.UI.cornerRadius)
|
.cornerRadius(AppConstants.UI.cornerRadius)
|
||||||
.shadow(color: .black.opacity(0.05), radius: 8, y: 2)
|
.shadow(color: .black.opacity(0.05), radius: 8, y: 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func shareMonthlyCheckIn() {
|
||||||
|
let summary = viewModel.monthlySummary
|
||||||
|
let text = """
|
||||||
|
\(summary.periodLabel) Check-in
|
||||||
|
Starting: \(summary.formattedStartingValue)
|
||||||
|
Ending: \(summary.formattedEndingValue)
|
||||||
|
Contributions: \(summary.formattedContributions)
|
||||||
|
Net performance: \(summary.formattedNetPerformance) (\(summary.formattedNetPerformancePercentage))
|
||||||
|
|
||||||
|
Shared from \(appDisplayName)
|
||||||
|
"""
|
||||||
|
ShareService.shared.shareText(text)
|
||||||
|
}
|
||||||
|
|
||||||
|
private var appDisplayName: String {
|
||||||
|
if let name = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
if let name = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
return "Portfolio Journal"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AchievementsView: View {
|
struct AchievementsView: View {
|
||||||
|
|||||||
Reference in New Issue
Block a user