Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-amisha-i committed Jan 1, 2025
1 parent 0ea7531 commit 920a8ed
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ class ExpenseDetailsViewModel: BaseViewModel, ObservableObject {

func restoreExpense() {
guard let group, group.isActive else {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.showAlertFor(title: "Error",
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
self?.showAlertFor(title: "Error",
message: "The group associated with this expense has been deleted, so it cannot be restored.")
}
return
Expand Down Expand Up @@ -216,8 +216,8 @@ class ExpenseDetailsViewModel: BaseViewModel, ObservableObject {
let missingMemberIds = Set(expense.splitTo + Array(expense.paidBy.keys)).subtracting(group.members)

if !missingMemberIds.isEmpty {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.showAlertFor(message: "This expense involves a person who has left the group, and thus it can no longer be \(action). If you wish to change this expense, you must first add that person back to your group.")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
self?.showAlertFor(message: "This expense involves a person who has left the group, and thus it can no longer be \(action). If you wish to change this expense, you must first add that person back to your group.")
}
return false
}
Expand All @@ -227,8 +227,8 @@ class ExpenseDetailsViewModel: BaseViewModel, ObservableObject {

private func validateUserPermission(operationText: String, action: String) -> Bool {
guard let userId = preference.user?.id, let group, group.members.contains(userId) else {
DispatchQueue.main.async {
self.showAlertFor(title: "Error",
DispatchQueue.main.async { [weak self] in
self?.showAlertFor(title: "Error",
message: "This expense could not be \(operationText). You do not have permission to \(action) this expense, Sorry!")
}
return false
Expand Down
66 changes: 34 additions & 32 deletions Splito/UI/Home/Groups/Create Group/CreateGroupView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,43 @@ struct CreateGroupView: View {

var body: some View {
VStack(alignment: .center, spacing: 0) {
ScrollView {
VStack(spacing: 0) {
VSpacer(40)

AddGroupImageView(showImagePickerOptions: $viewModel.showImagePickerOptions,
image: viewModel.profileImage, imageUrl: viewModel.profileImageUrl,
handleProfileTap: viewModel.handleProfileTap,
handleActionSelection: viewModel.handleActionSelection(_:))

VSpacer(30)

AddGroupNameView(groupName: $viewModel.groupName)
.focused($isFocused)

Spacer(minLength: 130)
VStack(alignment: .center, spacing: 0) {
ScrollView {
VStack(spacing: 0) {
VSpacer(40)

AddGroupImageView(showImagePickerOptions: $viewModel.showImagePickerOptions,
image: viewModel.profileImage, imageUrl: viewModel.profileImageUrl,
handleProfileTap: viewModel.handleProfileTap,
handleActionSelection: viewModel.handleActionSelection(_:))

VSpacer(30)

AddGroupNameView(groupName: $viewModel.groupName)
.focused($isFocused)

Spacer(minLength: 130)
}
.padding(.horizontal, 16)
}
.scrollIndicators(.hidden)
.scrollBounceBehavior(.basedOnSize)

PrimaryButton(text: viewModel.group != nil ? "Save" : "Create", isEnabled: viewModel.groupName.count >= 3, showLoader: viewModel.showLoader, onClick: {
Task {
let isSucceed = await viewModel.handleDoneAction()
if isSucceed {
dismiss()
} else {
viewModel.showSaveFailedToast()
}
}
})
.padding(.bottom, 20)
.padding(.horizontal, 16)
}
.scrollIndicators(.hidden)
.scrollBounceBehavior(.basedOnSize)

PrimaryButton(text: viewModel.group != nil ? "Save" : "Create", isEnabled: viewModel.groupName.count >= 3, showLoader: viewModel.showLoader, onClick: {
Task {
let isSucceed = await viewModel.handleDoneAction()
if isSucceed {
dismiss()
} else {
viewModel.showSaveFailedToast()
}
}
})
.padding(.bottom, 20)
.padding(.horizontal, 16)
.frame(maxWidth: isIpad ? 600 : nil, alignment: .center)
.frame(maxWidth: .infinity, alignment: .center)
}
.task { isFocused = true }
.onDisappear { isFocused = false }
Expand All @@ -59,8 +63,6 @@ struct CreateGroupView: View {
.background(surfaceColor)
.toastView(toast: $viewModel.toast)
.alertView.alert(isPresented: $viewModel.showAlert, alertStruct: viewModel.alert)
.frame(maxWidth: isIpad ? 600 : nil, alignment: .center)
.frame(maxWidth: .infinity, alignment: .center)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
NavigationTitleTextView(text: viewModel.group == nil ? "Create a group" : "Edit group")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ struct GroupPaymentView: View {
handleActionSelection: viewModel.handleActionSelection(_:))
}
}
.frame(maxWidth: isIpad ? 600 : nil, alignment: .center)
.frame(maxWidth: .infinity, alignment: .center)
}
.task { isAmountFocused = true }
.onTapGesture { isAmountFocused = false }
.onDisappear { isAmountFocused = false }
.background(surfaceColor)
.frame(maxWidth: isIpad ? 600 : nil, alignment: .center)
.frame(maxWidth: .infinity, alignment: .center)
.toolbarRole(.editor)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ class GroupTransactionListViewModel: BaseViewModel, ObservableObject {
}

if !group.members.contains(transaction.payerId) || !group.members.contains(transaction.receiverId) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.showAlertFor(message: "This payment involves a person who has left the group, and thus it can no longer be deleted. If you wish to change this payment, you must first add that person back to your group.")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
self?.showAlertFor(message: "This payment involves a person who has left the group, and thus it can no longer be deleted. If you wish to change this payment, you must first add that person back to your group.")
}
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ class GroupTransactionDetailViewModel: BaseViewModel, ObservableObject {

func restoreTransaction() {
guard let group, group.isActive else {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.showAlertFor(title: "Error",
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
self?.showAlertFor(title: "Error",
message: "The group associated with this payment has been deleted, so it cannot be restored.")
}
return
Expand Down Expand Up @@ -223,8 +223,8 @@ class GroupTransactionDetailViewModel: BaseViewModel, ObservableObject {
}

if !(group.members.contains(transaction.payerId)) || !(group.members.contains(transaction.receiverId)) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.showAlertFor(message: "This payment involves a person who has left the group, and thus it can no longer be \(action). If you wish to change this payment, you must first add that person back to your group.")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
self?.showAlertFor(message: "This payment involves a person who has left the group, and thus it can no longer be \(action). If you wish to change this payment, you must first add that person back to your group.")
}
return false
}
Expand All @@ -234,8 +234,8 @@ class GroupTransactionDetailViewModel: BaseViewModel, ObservableObject {

private func validateUserPermission(operationText: String, action: String) -> Bool {
guard let userId = preference.user?.id, let group, group.members.contains(userId) else {
DispatchQueue.main.async {
self.showAlertFor(title: "Error",
DispatchQueue.main.async { [weak self] in
self?.showAlertFor(title: "Error",
message: "This payment could not be \(operationText). You do not have permission to \(action) this payment, Sorry!")
}
return false
Expand Down
4 changes: 2 additions & 2 deletions Splito/UI/Home/Groups/Group/GroupHomeViewModelExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ extension GroupHomeViewModel {
let missingMemberIds = Set(expense.splitTo + Array(expense.paidBy.keys)).subtracting(group.members)

if !missingMemberIds.isEmpty {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.showAlertFor(message: "This expense involves a person who has left the group, and thus it can no longer be deleted. If you wish to change this expense, you must first add that person back to your group.")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
self?.showAlertFor(message: "This expense involves a person who has left the group, and thus it can no longer be deleted. If you wish to change this expense, you must first add that person back to your group.")
}
return false
}
Expand Down
8 changes: 4 additions & 4 deletions Splito/UI/Onboard/OnboardViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class OnboardViewModel: BaseViewModel, ObservableObject {

func handleGetStartedBtnVisibility(isLastIndex: Bool) {
if isLastIndex {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
withAnimation {
self.showGetStartedButton = true
self?.showGetStartedButton = true
}
}
} else {
withAnimation {
showGetStartedButton = false
withAnimation { [weak self] in
self?.showGetStartedButton = false
}
}
}
Expand Down

0 comments on commit 920a8ed

Please sign in to comment.