Skip to content

Commit

Permalink
use localised strings
Browse files Browse the repository at this point in the history
  • Loading branch information
pelumy committed Jan 13, 2025
1 parent f4f51cf commit b23d1d9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Nos/Models/NotificationViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class NotificationViewModel: ObservableObject, Identifiable {
var range = Range(uncheckedBounds: (authorName.startIndex, authorName.endIndex))
authorName[range].font = .boldSystemFont(ofSize: 17)

actionText = authorName + AttributedString(String(localized: "followed you"))
actionText = authorName + AttributedString(String(localized: "startedFollowingYou"))
range = Range(uncheckedBounds: (actionText.startIndex, actionText.endIndex))
actionText[range].foregroundColor = .primaryTxt
self.actionText = actionText
Expand Down
2 changes: 1 addition & 1 deletion Nos/Views/Notifications/FollowsNotificationCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct FollowsNotificationCard: View {
}
}

Text("started following you")
Text(viewModel.actionText)
.lineLimit(2)
}

Expand Down
2 changes: 1 addition & 1 deletion Nos/Views/Notifications/NotificationCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct NotificationCard: View {

func showNote() {
guard let noteID = viewModel.noteID,
let note = Event.find(by: noteID, context: viewContext) else {
let note = Event.find(by: noteID, context: viewContext) else {
return
}
router.push(note.referencedNote() ?? note)
Expand Down
41 changes: 25 additions & 16 deletions Nos/Views/Notifications/NotificationsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,24 @@ struct NotificationsView: View {
.overlay(Color.cardDividerTop)
.shadow(color: .cardDividerTopShadow, radius: 0, x: 0, y: 1)
HStack {
TabButton(title: "Follows", isSelected: selectedTab == 0) {
TabButton(
title: String(localized: "follows"),
isSelected: selectedTab == 0
) {
selectedTab = 0
}
Spacer()
TabButton(title: "In Network", isSelected: selectedTab == 1) {
TabButton(
title: String(localized: "inNetwork"),
isSelected: selectedTab == 1
) {
selectedTab = 1
}
Spacer()
TabButton(title: "Out of Network", isSelected: selectedTab == 2) {
TabButton(
title: String(localized: "outOfNetwork"),
isSelected: selectedTab == 2
) {
selectedTab = 2
}
}
Expand Down Expand Up @@ -355,19 +364,19 @@ struct NotificationsView_Previews: PreviewProvider {
inNetworkNotification.event = inNetworkNote

// Creates mention from Eve (out-of-network since Bob doesn't follow Eve)
let outNetworkNote = Event(context: context)
outNetworkNote.content = "Hey @bob!"
outNetworkNote.createdAt = .now
outNetworkNote.author = eve
let outNetworkAuthorRef = AuthorReference(context: context)
outNetworkAuthorRef.pubkey = bob.hexadecimalPublicKey
outNetworkNote.authorReferences = NSMutableOrderedSet(array: [outNetworkAuthorRef])
try? outNetworkNote.sign(withKey: KeyFixture.eve)

let outNetworkNotification = NosNotification(context: context)
outNetworkNotification.createdAt = .now
outNetworkNotification.user = bob
outNetworkNotification.event = outNetworkNote
let outOfNetworkNote = Event(context: context)
outOfNetworkNote.content = "Hey @bob!"
outOfNetworkNote.createdAt = .now
outOfNetworkNote.author = eve
let outOfNetworkAuthorRef = AuthorReference(context: context)
outOfNetworkAuthorRef.pubkey = bob.hexadecimalPublicKey
outOfNetworkNote.authorReferences = NSMutableOrderedSet(array: [outOfNetworkAuthorRef])
try? outOfNetworkNote.sign(withKey: KeyFixture.eve)

let outOfNetworkNotification = NosNotification(context: context)
outOfNetworkNotification.createdAt = .now
outOfNetworkNotification.user = bob
outOfNetworkNotification.event = outOfNetworkNote

try? context.save()
}
Expand Down

0 comments on commit b23d1d9

Please sign in to comment.