Skip to content

Commit 8e412c9

Browse files
Add loader
1 parent e819dcd commit 8e412c9

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

Core/Core/Features/People/APIUser.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,10 @@ public struct APIProfile: Codable, Equatable {
151151
public struct Permissions: Codable, Equatable {
152152
public let canUpdateName: Bool?
153153
public let canUpdateAvatar: Bool?
154-
public let limitParentAppWebAccess: Bool?
155154

156155
enum CodingKeys: String, CodingKey {
157156
case canUpdateName = "can_update_name"
158157
case canUpdateAvatar = "can_update_avatar"
159-
case limitParentAppWebAccess = "limit_parent_app_web_access"
160158
}
161159
}
162160
}

Horizon/Horizon/Sources/Features/Account/Profile/View/ProfileView.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,19 @@ struct ProfileView: View {
4646
Alert(title: Text(viewModel.errorMessage), message: Text(viewModel.errorMessage))
4747
}
4848
}
49+
.overlay { loaderView }
4950
}
5051

52+
@ViewBuilder
53+
private var loaderView: some View {
54+
if viewModel.isLoaderVisible {
55+
ZStack {
56+
Color.huiColors.surface.pageSecondary
57+
.ignoresSafeArea()
58+
HorizonUI.Spinner(size: .small, showBackground: true)
59+
}
60+
}
61+
}
5162
private var nameView: some View {
5263
HorizonUI.TextInput(
5364
$viewModel.name,
@@ -84,7 +95,7 @@ struct ProfileView: View {
8495
private var saveButton: some View {
8596
SavingButton(
8697
title: String(localized: "Save Changes", bundle: .horizon),
87-
isLoading: $viewModel.isLoading,
98+
isLoading: $viewModel.saveLoaderIsVisiable,
8899
isDisabled: $viewModel.isSaveDisabled,
89100
onSave: viewModel.save
90101
)

Horizon/Horizon/Sources/Features/Account/Profile/View/ProfileViewModel.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,25 @@ final class ProfileViewModel {
3131
}
3232
}
3333
var nameDisabled: Bool {
34-
isLoading || !canUpdateName
34+
saveLoaderIsVisiable || !canUpdateName
3535
}
3636
var nameError: String = " "
3737
private(set) var errorMessage: String = ""
3838
private(set) var canUpdateName = true
39+
private(set) var isLoaderVisible = true
3940
var displayName: String = "" {
4041
didSet {
4142
validateDisplayName()
4243
updateSaveDisabled()
4344
}
4445
}
4546
var displayNameDisabled: Bool {
46-
isLoading || !canUpdateName
47+
saveLoaderIsVisiable || !canUpdateName
4748
}
4849
var displayNameError: String = " "
4950
var email: String = ""
5051
var isSaveDisabled: Bool = true
51-
var isLoading: Bool = true
52+
var saveLoaderIsVisiable: Bool = false
5253

5354
// MARK: - Inputs / Output
5455

@@ -87,7 +88,7 @@ final class ProfileViewModel {
8788
self?.errorMessage = error.localizedDescription
8889
self?.isAlertErrorPresented = true
8990
}
90-
self?.isLoading = false
91+
self?.isLoaderVisible = false
9192
} receiveValue: { [weak self] (user, canUpdateName) in
9293
self?.canUpdateName = canUpdateName
9394
self?.nameOriginal = user.name
@@ -101,11 +102,11 @@ final class ProfileViewModel {
101102
// MARK: - Input Actions
102103

103104
func save() {
104-
isLoading = true
105+
saveLoaderIsVisiable = true
105106
updateUserProfileInteractor.set(name: name, shortName: displayName)
106107
.sink(
107108
receiveCompletion: { [weak self] _ in
108-
self?.isLoading = false
109+
self?.saveLoaderIsVisiable = false
109110
},
110111
receiveValue: { [weak self] userProfile in
111112
self?.nameOriginal = userProfile.name

0 commit comments

Comments
 (0)