Skip to content

Commit

Permalink
feat: Save author mail address
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinperignon committed Nov 22, 2024
1 parent 9cdfef0 commit bd79773
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions SwissTransferFeatures/NewTransferView/NewTransferDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
*/

import InfomaniakCoreSwiftUI
import InfomaniakDI
import STCore
import STResources
import SwiftUI
import SwissTransferCore
import SwissTransferCoreUI
import InfomaniakDI

struct NewTransferDetailsView: View {
@FocusState private var isMessageFieldFocused
Expand All @@ -36,16 +36,11 @@ struct NewTransferDetailsView: View {
var body: some View {
VStack(spacing: IKPadding.medium) {
if transferType == .mail {
TextField(STResourcesStrings.Localizable.senderMailAddressPlaceholder, text: $authorEmail)
.textFieldStyle(NewTransferTextFieldStyle())
.keyboardType(.emailAddress)
.onSubmit {
print("On Submit")
Task {
@InjectService var settingsManager: AppSettingsManager
try? await settingsManager.setLastAuthorEmail(authorEmail: authorEmail)
}
}
TextField(STResourcesStrings.Localizable.senderMailAddressPlaceholder, text: $authorEmail) { _ in
saveAuthorMailAddress()
}
.textFieldStyle(NewTransferTextFieldStyle())
.keyboardType(.emailAddress)

TextField(STResourcesStrings.Localizable.recipientMailAddressPlaceholder, text: $recipientEmail)
.textFieldStyle(NewTransferTextFieldStyle())
Expand All @@ -62,6 +57,13 @@ struct NewTransferDetailsView: View {
)
}
}

private func saveAuthorMailAddress() {
Task {
@InjectService var settingsManager: AppSettingsManager
try? await settingsManager.setLastAuthorEmail(authorEmail: authorEmail)
}
}
}

#Preview {
Expand Down

0 comments on commit bd79773

Please sign in to comment.