Skip to content

Commit

Permalink
Showed You instead currentUser fullName in whole project
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-nirali-s committed Dec 5, 2024
1 parent 16bed55 commit 6cc30c8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
13 changes: 10 additions & 3 deletions Splito/Localization/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@
},
"%@" : {

},
"%@ %@ " : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "%1$@ %2$@ "
}
}
}
},
"%@ %@ %@" : {
"localizations" : {
Expand All @@ -61,9 +71,6 @@
},
"%@ and %@" : {
"extractionState" : "manual"
},
"%@ owes " : {

},
"%@ owes you " : {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import SwiftUI
import BaseStyle
import Data

struct GroupBalancesView: View {

Expand Down Expand Up @@ -71,6 +72,8 @@ struct GroupBalancesView: View {
@MainActor
private struct GroupBalanceItemView: View {

@Inject private var preference: SplitoPreference

let memberBalance: MembersCombinedBalance
let viewModel: GroupBalancesViewModel

Expand All @@ -88,7 +91,7 @@ private struct GroupBalanceItemView: View {

let hasDue = memberBalance.totalOwedAmount < 0
let name = viewModel.getMemberName(id: memberBalance.id, needFullName: true)
let owesOrGetsBack = hasDue ? "owes" : "gets back"
let owesOrGetsBack = hasDue ? (memberBalance.id == preference.user?.id ? "owe" : "owes") : (memberBalance.id == preference.user?.id ? "get back" : "gets back")

if memberBalance.totalOwedAmount == 0 {
Group {
Expand Down Expand Up @@ -142,6 +145,8 @@ private struct GroupBalanceItemView: View {
private struct GroupBalanceItemMemberView: View {
let SUB_IMAGE_HEIGHT: CGFloat = 24

@Inject private var preference: SplitoPreference

let id: String
let balances: [String: Double]
let viewModel: GroupBalancesViewModel
Expand All @@ -156,13 +161,14 @@ private struct GroupBalanceItemMemberView: View {
let imageUrl = viewModel.getMemberImage(id: memberId)
let owesMemberName = viewModel.getMemberName(id: hasDue ? memberId : id)
let owedMemberName = viewModel.getMemberName(id: hasDue ? id : memberId)
let owesText = ((hasDue ? id : memberId) == preference.user?.id) ? "owe" : "owes"

VStack(alignment: .leading, spacing: 8) {
HStack(alignment: .center, spacing: 16) {
MemberProfileImageView(imageUrl: imageUrl, height: SUB_IMAGE_HEIGHT, scaleEffect: 0.6)

Group {
Text("\(owedMemberName) owes ")
Text("\(owedMemberName.capitalized) \(owesText.localized) ")

+ Text(amount.formattedCurrency)
.foregroundColor(hasDue ? errorColor : successColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ class GroupBalancesViewModel: BaseViewModel, ObservableObject {
}

func getMemberName(id: String, needFullName: Bool = false) -> String {
guard let member = getMemberDataBy(id: id) else { return "" }
return needFullName ? member.fullName : member.nameWithLastInitial
guard let userId = preference.user?.id, let member = getMemberDataBy(id: id) else { return "" }
return needFullName ? (id == userId ? "You" : member.fullName) : (id == userId ? "you" : member.nameWithLastInitial)
}

// MARK: - User Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ struct GroupWhoIsPayingView: View {

struct GroupPayingMemberView: View {

@Inject private var preference: SplitoPreference

let member: AppUser

let isSelected: Bool
Expand All @@ -61,6 +63,14 @@ struct GroupPayingMemberView: View {

let onMemberTap: (String) -> Void

private var memberName: String {
if let user = preference.user, user.id == member.id {
return "You"
} else {
return member.fullName
}
}

init(member: AppUser, isSelected: Bool = false, isLastMember: Bool, disableMemberTap: Bool = false, onMemberTap: @escaping (String) -> Void) {
self.member = member
self.isSelected = isSelected
Expand All @@ -73,7 +83,7 @@ struct GroupPayingMemberView: View {
HStack(alignment: .center, spacing: 16) {
MemberProfileImageView(imageUrl: member.imageUrl)

Text(member.fullName.localized)
Text(memberName.localized)
.font(.subTitle2())
.foregroundStyle(primaryText)
.lineLimit(1)
Expand Down

0 comments on commit 6cc30c8

Please sign in to comment.