Skip to content

Commit

Permalink
Added focused in texteditor
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-nirali-s committed Nov 26, 2024
1 parent ca6e739 commit 172e282
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
11 changes: 9 additions & 2 deletions Splito/UI/Home/Expense/AddExpenseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,17 @@ struct ExpenseNotesView: View {
.frame(width: 24, height: 24)
.padding(.horizontal, 8)
.padding(.vertical, 4)
.onTouchGesture(handleNotesTap)
.onTapGestureForced(perform: handleNotesTap)
}
}

struct ExpenseAddNotesView: View {
private struct ExpenseAddNotesView: View {
@Environment(\.dismiss) var dismiss

@Binding var expenseNotes: String

@State private var tempNotes: String
@FocusState private var isFocused: Bool

init(expenseNotes: Binding<String>) {
self._expenseNotes = expenseNotes
Expand All @@ -313,8 +314,11 @@ struct ExpenseAddNotesView: View {
.foregroundColor(primaryText)
.lineSpacing(5)
.multilineTextAlignment(.leading)
.scrollContentBackground(.hidden)
.focused($isFocused)
}
.padding(.horizontal, 16)
.background(surfaceColor)
.navigationTitle("Add notes")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
Expand All @@ -331,5 +335,8 @@ struct ExpenseAddNotesView: View {
}
}
}
.onAppear {
isFocused = true
}
}
}
9 changes: 5 additions & 4 deletions Splito/UI/Home/Expense/AddExpenseViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ extension AddExpenseViewModel {
showImagePickerOptions = true
}

func handleNotesAction() {
UIApplication.shared.endEditing()
showAddNotesEditor = true
}

func handleActionSelection(_ action: ActionsOfSheet) {
switch action {
case .camera:
Expand Down Expand Up @@ -301,10 +306,6 @@ extension AddExpenseViewModel {
showSplitTypeSelection = true
}

func handleNotesAction() {
showAddNotesEditor = true
}

func handleSplitTypeSelectionAction(members: [String], splitData: [String: Double], splitType: SplitType) {
Task {
await handleSplitTypeSelection(members: members, splitData: splitData, splitType: splitType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ struct ExpenseDetailsView: View {
if let notes = viewModel.expense?.notes {
Text(notes)
.padding(16)
.frame(maxWidth: .infinity, alignment: .leading)
.background(container2Color)
.cornerRadius(8)
.frame(maxWidth: .infinity, alignment: .leading)
}

VSpacer(24)
Expand Down

0 comments on commit 172e282

Please sign in to comment.