Skip to content

Commit

Permalink
Fix Arabic Number Bug and Improve Notes Sharing (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
yismailuofa authored Sep 19, 2024
1 parent 4a3fc40 commit 288e841
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
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

0 comments on commit 288e841

Please sign in to comment.