Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Arabic Number Bug and Improve Notes Sharing #667

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Localization/NumberFormatter+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension NumberFormatter {

public static var arabicNumberFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.locale = Locale(identifier: "ar")
formatter.locale = Locale(identifier: "ar-SA")
return formatter
}()
}
Expand Down
3 changes: 2 additions & 1 deletion Features/AyahMenuFeature/AyahMenuViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ final class AyahMenuViewModel {
logger.info("AyahMenu: share. Verses: \(deps.verses)")
Task {
if let lines = try? await retrieveSelectedAyahText() {
listener?.shareText(lines, in: self.deps.sourceView, at: self.deps.pointInView)
let withNewLines = lines.joined(separator: "\n")
listener?.shareText([withNewLines], in: self.deps.sourceView, at: self.deps.pointInView)
}
}
}
Expand Down
20 changes: 13 additions & 7 deletions Features/NotesFeature/NotesViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,23 @@ final class NotesViewModel: ObservableObject {
func prepareNotesForSharing() async throws -> String {
try await crasher.recordError("Failed to share notes") {
var notesText = [String]()
for note in await notes {
let title = if let noteContent = note.note.note, noteContent != "" {
"\(noteContent.trimmingCharacters(in: .newlines))\n\n"
let notes: [NoteItem] = await self.notes
for (index, note) in notes.enumerated() {
let title: [String] = if let noteContent = note.note.note, noteContent != "" {
[
"\(noteContent.trimmingCharacters(in: .newlines))", "",
]
} else {
""
[]
}
let verses = try await textRetriever.textForVerses(Array(note.note.verses)).joined(separator: "\n")
let verses = try await textRetriever.textForVerses(Array(note.note.verses))

notesText.append("\(title)\(verses)")
notesText.append(contentsOf: title + verses)
if index != notes.count - 1 {
notesText.append(contentsOf: ["", "", ""])
}
}
return notesText.joined(separator: "\n\n\n\n")
return notesText.joined(separator: "\n")
}
}

Expand Down
Loading