Skip to content

Commit bf53a5e

Browse files
committed
Gender picker improvements in profile edit
1 parent 0e37850 commit bf53a5e

File tree

5 files changed

+35
-85
lines changed

5 files changed

+35
-85
lines changed

Modules/Sources/Models/Profile/User.swift

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,12 @@ public extension User {
206206

207207
// MARK: Gender
208208

209-
enum Gender: Int, Codable, Hashable, Sendable {
209+
enum Gender: Int, CaseIterable, Codable, Hashable, Sendable, Identifiable {
210210
case unknown = 0
211211
case male
212212
case female
213213

214-
public var title: LocalizedStringKey {
215-
switch self {
216-
case .unknown:
217-
"Not set"
218-
case .male:
219-
"Male"
220-
case .female:
221-
"Female"
222-
}
223-
}
214+
public var id: Self { self }
224215
}
225216

226217
// MARK: Device

Modules/Sources/Models/Resources/Localizable.xcstrings

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@
4141
}
4242
}
4343
},
44-
"Female" : {
45-
"localizations" : {
46-
"ru" : {
47-
"stringUnit" : {
48-
"state" : "translated",
49-
"value" : "Женский"
50-
}
51-
}
52-
}
53-
},
5444
"First page" : {
5545
"localizations" : {
5646
"ru" : {
@@ -81,16 +71,6 @@
8171
}
8272
}
8373
},
84-
"Male" : {
85-
"localizations" : {
86-
"ru" : {
87-
"stringUnit" : {
88-
"state" : "translated",
89-
"value" : "Мужской"
90-
}
91-
}
92-
}
93-
},
9474
"No comment text" : {
9575
"localizations" : {
9676
"ru" : {
@@ -101,16 +81,6 @@
10181
}
10282
}
10383
},
104-
"Not set" : {
105-
"localizations" : {
106-
"ru" : {
107-
"stringUnit" : {
108-
"state" : "translated",
109-
"value" : "Не указан"
110-
}
111-
}
112-
}
113-
},
11484
"Profile" : {
11585
"localizations" : {
11686
"ru" : {

Modules/Sources/ProfileFeature/Edit/EditFeature.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ public struct EditFeature: Reducer, Sendable {
100100

101101
case wipeBirthdayDate
102102
case setBirthdayDate
103-
case selectGenderType(User.Gender)
104103

105104
case saveButtonTapped
106105
case cancelButtonTapped
@@ -153,10 +152,6 @@ public struct EditFeature: Reducer, Sendable {
153152
case .view(.avatarBadFileSizeTooBig):
154153
return showToast(ToastMessage(text: Localization.avatarFileSizeError, haptic: .error))
155154

156-
case .view(.selectGenderType(let type)):
157-
state.draftUser.gender = type
158-
return .none
159-
160155
case .view(.setBirthdayDate):
161156
state.birthdayDate = state.draftUser.birthdayDate ?? Date()
162157
return .none

Modules/Sources/ProfileFeature/Edit/EditScreen.swift

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import SwiftUI
99
import ComposableArchitecture
1010
import NukeUI
11+
import Models
1112
import SharedUI
1213
import PhotosUI
1314

@@ -168,47 +169,18 @@ public struct EditScreen: View {
168169

169170
@ViewBuilder
170171
private func UserGender() -> some View {
171-
Menu {
172-
Button {
173-
send(.selectGenderType(.unknown))
174-
} label: {
175-
Text("Not set", bundle: .module)
176-
}
177-
178-
Button {
179-
send(.selectGenderType(.male))
180-
} label: {
181-
Text("Male", bundle: .module)
172+
Picker(
173+
LocalizedStringResource("Gender", bundle: .module),
174+
selection: Binding(unwrapping: $store.draftUser.gender, default: .unknown)
175+
) {
176+
ForEach(User.Gender.allCases) { gender in
177+
Text(gender.title, bundle: .module)
178+
.tag(gender)
182179
}
183-
184-
Button {
185-
send(.selectGenderType(.female))
186-
} label: {
187-
Text("Female", bundle: .module)
188-
}
189-
} label: {
190-
HStack {
191-
Text("Gender", bundle: .module)
192-
.font(.body)
193-
.foregroundStyle(Color(.Labels.primary))
194-
195-
Spacer()
196-
197-
HStack {
198-
let gender = store.draftUser.gender ?? .unknown
199-
Text(gender.title, bundle: .module)
200-
.font(.body)
201-
.foregroundStyle(Color(.Labels.quaternary))
202-
.padding(.leading, 16)
203-
204-
Image(systemSymbol: .chevronUpChevronDown)
205-
.foregroundStyle(Color(.Labels.quaternary))
206-
}
207-
}
208-
.padding(12)
209-
.frame(height: 60)
210-
.cornerRadius(10)
211180
}
181+
.padding(12)
182+
.frame(height: 60)
183+
.cornerRadius(10)
212184
}
213185

214186
// MARK: - Avatar
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// User.Gender+Extension.swift
3+
// ForPDA
4+
//
5+
// Created by Xialtal on 9.11.25.
6+
//
7+
8+
import SwiftUI
9+
import Models
10+
11+
extension User.Gender {
12+
var title: LocalizedStringKey {
13+
switch self {
14+
case .unknown:
15+
"Not set"
16+
case .male:
17+
"Male"
18+
case .female:
19+
"Female"
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)