mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-03 03:22:22 +00:00
Profile edit: Allow re order of fields
This commit is contained in:
parent
293d680510
commit
cc4768b5e7
3 changed files with 7 additions and 4 deletions
|
@ -24,6 +24,7 @@ public struct EditAccountView: View {
|
|||
accountSection
|
||||
}
|
||||
}
|
||||
.environment(\.editMode, .constant(.active))
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
|
@ -108,6 +109,9 @@ public struct EditAccountView: View {
|
|||
TextField("account.edit.metadata-value-placeholder", text: $field.value)
|
||||
}
|
||||
}
|
||||
.onMove(perform: { indexSet, newOffset in
|
||||
viewModel.fields.move(fromOffsets: indexSet, toOffset: newOffset)
|
||||
})
|
||||
.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
viewModel.fields.remove(at: index)
|
||||
|
|
|
@ -93,6 +93,7 @@ public final class Client: ObservableObject, Equatable, Identifiable, Hashable {
|
|||
if let json = endpoint.jsonValue {
|
||||
let encoder = JSONEncoder()
|
||||
encoder.keyEncodingStrategy = .convertToSnakeCase
|
||||
encoder.outputFormatting = .sortedKeys
|
||||
do {
|
||||
let jsonData = try encoder.encode(json)
|
||||
request.httpBody = jsonData
|
||||
|
|
|
@ -199,10 +199,8 @@ public struct UpdateCredentialsData: Encodable, Sendable {
|
|||
self.discoverable = discoverable
|
||||
|
||||
var fieldAttributes: [String: FieldData] = [:]
|
||||
var index: Int = 0
|
||||
for fieldsAttribute in fieldsAttributes {
|
||||
fieldAttributes[String(index)] = fieldsAttribute
|
||||
index += 1
|
||||
for (index, field) in fieldsAttributes.enumerated() {
|
||||
fieldAttributes[String(index)] = field
|
||||
}
|
||||
self.fieldsAttributes = fieldAttributes
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue