Add monthly check-in sharing
This commit is contained in:
@@ -73,6 +73,15 @@ struct MonthlyCheckInView: View {
|
||||
}
|
||||
.navigationTitle("Monthly Check-in")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
shareMonthlyCheckIn()
|
||||
} label: {
|
||||
Image(systemName: "square.and.arrow.up")
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
viewModel.selectedAccount = accountStore.selectedAccount
|
||||
viewModel.showAllAccounts = accountStore.showAllAccounts
|
||||
@@ -444,6 +453,30 @@ struct MonthlyCheckInView: View {
|
||||
.cornerRadius(AppConstants.UI.cornerRadius)
|
||||
.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 {
|
||||
|
||||
Reference in New Issue
Block a user