Skip to content

Commit

Permalink
Fixed: not able to pullToRefresh on list&getting all selected in spli…
Browse files Browse the repository at this point in the history
…tOption&Showed alert when remove user add comment
  • Loading branch information
cp-nirali-s committed Jan 9, 2025
1 parent 2ede7ec commit 315a1ac
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Splito/UI/Home/Expense/AddExpenseViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class AddExpenseViewModel: BaseViewModel, ObservableObject {
do {
viewState = .loading
let expense = try await expenseRepository.fetchExpenseBy(groupId: groupId, expenseId: expenseId)
await updateViewModelFieldsWithExpense(expense: expense)
await fetchAndUpdateGroupData(groupId: groupId)
await updateViewModelFieldsWithExpense(expense: expense)
viewState = .initial
LogD("AddExpenseViewModel: \(#function) Expense details with members fetched successfully.")
} catch {
Expand Down
10 changes: 6 additions & 4 deletions Splito/UI/Home/Expense/Expense Detail/ExpenseDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ struct ExpenseDetailsView: View {
}
}

AddCommentTextField(comment: $viewModel.comment, isFocused: $isFocused,
showLoader: viewModel.showLoader, onSendCommentBtnTap: viewModel.onSendCommentBtnTap)
if (viewModel.expense?.isActive ?? false) && (viewModel.group?.isActive ?? false) {
AddCommentTextField(comment: $viewModel.comment, isFocused: $isFocused,
showLoader: viewModel.showLoader, onSendCommentBtnTap: viewModel.onSendCommentBtnTap)
}
}
}
.background(surfaceColor)
Expand Down Expand Up @@ -240,9 +242,9 @@ private struct AddCommentTextField: View {
.frame(width: 40, height: 40)
.foregroundStyle(primaryColor)
.padding(.vertical, 12)
.padding(.trailing, 6)
.padding(.trailing, 4)
}
.disabled(comment.isEmpty)
.disabled(comment.trimming(spaces: .leadingAndTrailing).isEmpty)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,12 @@ class ExpenseDetailsViewModel: BaseViewModel, ObservableObject {
}

func onSendCommentBtnTap() {
guard let expense, expense.isActive, let userId = preference.user?.id,
let group, group.members.contains(userId) else { return }
guard let expense, let group, let userId = preference.user?.id else { return }
if !group.members.contains(userId) {
showAlertFor(title: "Error",
message: "You do not have permission to add a comment on this expense. Only group members can comment, Sorry!")
return
}

Task { [weak self] in
guard let self else { return }
Expand Down
1 change: 0 additions & 1 deletion Splito/UI/Home/Groups/GroupListWithDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ struct GroupListWithDetailView: View {
perform: viewModel.manageScrollToTopBtnVisibility(offset:))
})
}
.scrollBounceBehavior(.basedOnSize)
.refreshable { viewModel.fetchGroupsInitialData() }
.overlay(alignment: .bottomTrailing) {
if viewModel.showScrollToTopBtn {
Expand Down

0 comments on commit 315a1ac

Please sign in to comment.