Skip to content

Commit 2bfbf42

Browse files
committed
Merge remote-tracking branch 'origin/feature/edit-profile' into develop
2 parents 79cebb4 + f4e7008 commit 2bfbf42

File tree

4 files changed

+77
-26
lines changed

4 files changed

+77
-26
lines changed

Modules/Sources/ProfileFeature/Edit/EditFeature.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ public struct EditFeature: Reducer, Sendable {
4141

4242
@ObservableState
4343
public struct State: Equatable {
44+
public enum Field: CaseIterable { case status, signature, about, city }
45+
4446
@Presents public var destination: Destination.State?
4547

4648
let user: User
4749
var draftUser: User
48-
var avatarReloadId = UUID()
50+
var focus: Field?
4951

5052
var isSending = false
5153
var isAvatarUploading = false

Modules/Sources/ProfileFeature/Edit/EditScreen.swift

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public struct EditScreen: View {
2020

2121
@State private var pickerItem: PhotosPickerItem?
2222

23-
@FocusState var isStatusFocused: Bool
23+
@FocusState var focus: EditFeature.State.Field?
2424

2525
public init(store: StoreOf<EditFeature>) {
2626
self.store = store
@@ -38,20 +38,23 @@ public struct EditScreen: View {
3838
if store.isUserCanEditStatus {
3939
Field(
4040
content: Binding(unwrapping: $store.draftUser.status, default: ""),
41-
title: LocalizedStringKey("Status")
41+
title: LocalizedStringKey("Status"),
42+
focusEqual: .status
4243
)
4344
} else {
4445
// TODO: Some notify about it?
4546
}
4647

4748
Field(
4849
content: Binding(unwrapping: $store.draftUser.signature, default: ""),
49-
title: LocalizedStringKey("Signature")
50+
title: LocalizedStringKey("Signature"),
51+
focusEqual: .signature
5052
)
5153

5254
Field(
5355
content: Binding(unwrapping: $store.draftUser.aboutMe, default: ""),
54-
title: LocalizedStringKey("About me")
56+
title: LocalizedStringKey("About me"),
57+
focusEqual: .about
5558
)
5659

5760
Section {
@@ -63,14 +66,15 @@ public struct EditScreen: View {
6366

6467
Field(
6568
content: Binding(unwrapping: $store.draftUser.city, default: ""),
66-
title: LocalizedStringKey("City")
69+
title: LocalizedStringKey("City"),
70+
focusEqual: .city
6771
)
6872
}
6973
.scrollContentBackground(.hidden)
7074
}
7175
.navigationTitle(Text("Edit profile", bundle: .module))
7276
.navigationBarTitleDisplayMode(.inline)
73-
.safeAreaInset(edge: .bottom) {
77+
._safeAreaBar(edge: .bottom) {
7478
SendButton()
7579
}
7680
.toolbar {
@@ -84,6 +88,10 @@ public struct EditScreen: View {
8488
.disabled(store.isSending)
8589
}
8690
}
91+
.bind($store.focus, to: $focus)
92+
.onTapGesture {
93+
focus = nil
94+
}
8795
.onAppear {
8896
send(.onAppear)
8997
}
@@ -115,7 +123,13 @@ public struct EditScreen: View {
115123
.frame(height: 48)
116124
.padding(.vertical, 8)
117125
.padding(.horizontal, 16)
118-
.background(Color(.Background.primary))
126+
.background {
127+
if #available(iOS 26, *) {
128+
// No background
129+
} else {
130+
Color(.Background.primary)
131+
}
132+
}
119133
}
120134

121135
// MARK: - User Birthday Picker
@@ -286,6 +300,7 @@ public struct EditScreen: View {
286300
Image(systemSymbol: .trash)
287301
}
288302
}
303+
.tint(.red)
289304
}
290305
} label: {
291306
Image(systemSymbol: .ellipsis)
@@ -306,15 +321,43 @@ public struct EditScreen: View {
306321
@ViewBuilder
307322
private func Field(
308323
content: Binding<String>,
309-
title: LocalizedStringKey
324+
title: LocalizedStringKey,
325+
focusEqual: EditFeature.State.Field
310326
) -> some View {
311327
Section {
312-
SharedUI.Field(
313-
text: content,
314-
description: "",
315-
guideText: "",
316-
isFocused: $isStatusFocused
317-
)
328+
Group {
329+
TextField(text: content, axis: .vertical) {
330+
Text("Input...", bundle: .module)
331+
.font(.body)
332+
.foregroundStyle(Color(.Labels.quaternary))
333+
}
334+
.focused($focus, equals: focusEqual)
335+
.font(.body)
336+
.foregroundStyle(Color(.Labels.primary))
337+
.multilineTextAlignment(.leading)
338+
.fixedSize(horizontal: false, vertical: true)
339+
.frame(minHeight: nil, alignment: .top)
340+
}
341+
.padding(.vertical, 15)
342+
.padding(.horizontal, 12)
343+
.background {
344+
if #available(iOS 26, *) {
345+
ConcentricRectangle()
346+
.fill(Color(.Background.teritary))
347+
} else {
348+
RoundedRectangle(cornerRadius: 14)
349+
.fill(Color(.Background.teritary))
350+
}
351+
}
352+
.overlay {
353+
if #available(iOS 26, *) {
354+
ConcentricRectangle()
355+
.stroke($focus.wrappedValue == focusEqual ? tintColor : Color(.Separator.primary), lineWidth: 0.67)
356+
} else {
357+
RoundedRectangle(cornerRadius: 14)
358+
.stroke($focus.wrappedValue == focusEqual ? tintColor : Color(.Separator.primary), lineWidth: 0.67)
359+
}
360+
}
318361
} header: {
319362
Header(title: title)
320363
}

Modules/Sources/ProfileFeature/ProfileScreen.swift

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,17 @@ public struct ProfileScreen: View {
103103

104104
ToolbarItem {
105105
Button {
106-
send(.settingsButtonTapped)
106+
send(.editButtonTapped)
107107
} label: {
108-
Image(systemSymbol: .gearshape)
108+
Image(systemSymbol: .pencil)
109109
}
110110
}
111111

112-
if let userId = store.userId,
113-
let userSession = store.userSession,
114-
userSession.userId == userId {
115-
ToolbarItem {
116-
Button {
117-
send(.editButtonTapped)
118-
} label: {
119-
Image(systemSymbol: .pencil)
120-
}
112+
ToolbarItem {
113+
Button {
114+
send(.settingsButtonTapped)
115+
} label: {
116+
Image(systemSymbol: .gearshape)
121117
}
122118
}
123119
}

Modules/Sources/ProfileFeature/Resources/Localizable.xcstrings

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@
241241
}
242242
}
243243
},
244+
"Input..." : {
245+
"localizations" : {
246+
"ru" : {
247+
"stringUnit" : {
248+
"state" : "translated",
249+
"value" : "Введите…"
250+
}
251+
}
252+
}
253+
},
244254
"Karma" : {
245255
"localizations" : {
246256
"ru" : {

0 commit comments

Comments
 (0)