diff --git a/Fyreplace/Resources/Localizable.xcstrings b/Fyreplace/Resources/Localizable.xcstrings index 5eafaef..886f2a5 100644 --- a/Fyreplace/Resources/Localizable.xcstrings +++ b/Fyreplace/Resources/Localizable.xcstrings @@ -669,7 +669,7 @@ "en" : { "stringUnit" : { "state" : "translated", - "value" : "This file is too heavy; please select a file under 1M." + "value" : "Uploaded files can only go up to 10M." } } } @@ -709,7 +709,7 @@ "en" : { "stringUnit" : { "state" : "translated", - "value" : "This file you have selected is not supported." + "value" : "The type of file you have selected is not supported." } } } diff --git a/Fyreplace/Views/Components/EditableAvatar.swift b/Fyreplace/Views/Components/EditableAvatar.swift index ff1657a..492d3ab 100644 --- a/Fyreplace/Views/Components/EditableAvatar.swift +++ b/Fyreplace/Views/Components/EditableAvatar.swift @@ -21,12 +21,10 @@ struct EditableAvatar: View { private var avatarItem: PhotosPickerItem? var body: some View { - let opacity = showEditOverlay ? 1.0 : 0.0 - let blurred = showEditOverlay Button { showPhotosPicker = true } label: { - Avatar(user: user, blurred: blurred) + Avatar(user: user, blurred: showEditOverlay) .overlay { Image(systemName: "pencil") .resizable() @@ -35,7 +33,7 @@ struct EditableAvatar: View { .padding() .background(.black.opacity(0.5)) .foregroundStyle(.white) - .opacity(opacity) + .opacity(showEditOverlay ? 1.0 : 0.0) .clipShape(.circle) } } diff --git a/Fyreplace/Views/Screens/SettingsScreen.swift b/Fyreplace/Views/Screens/SettingsScreen.swift index 03f842f..561e40f 100644 --- a/Fyreplace/Views/Screens/SettingsScreen.swift +++ b/Fyreplace/Views/Screens/SettingsScreen.swift @@ -14,6 +14,9 @@ struct SettingsScreen: View, SettingsScreenProtocol { @State var currentUser: Components.Schemas.User? + @State + var isLoadingAvatar = false + @Environment(\.config) private var config @@ -32,11 +35,17 @@ struct SettingsScreen: View, SettingsScreenProtocol { let logoutButton = Button("Settings.Logout", role: .destructive, action: logout) HStack { - EditableAvatar( - user: currentUser, - avatarSelected: updateAvatar, - avatarRemoved: removeAvatar - ) + ZStack { + if isLoadingAvatar { + ProgressView() + } else { + EditableAvatar( + user: currentUser, + avatarSelected: updateAvatar, + avatarRemoved: removeAvatar + ) + } + } .frame(width: .logoSize, height: .logoSize) VStack(alignment: .leading, spacing: 4) { diff --git a/Fyreplace/Views/Screens/SettingsScreenProtocol.swift b/Fyreplace/Views/Screens/SettingsScreenProtocol.swift index 83512d5..9c9c7d6 100644 --- a/Fyreplace/Views/Screens/SettingsScreenProtocol.swift +++ b/Fyreplace/Views/Screens/SettingsScreenProtocol.swift @@ -7,6 +7,7 @@ protocol SettingsScreenProtocol: ViewProtocol { var token: String { get nonmutating set } var currentUser: Components.Schemas.User? { get nonmutating set } + var isLoadingAvatar: Bool { get nonmutating set } } @MainActor @@ -34,6 +35,8 @@ extension SettingsScreenProtocol { } func updateAvatar(with data: Data) async { + isLoadingAvatar = true + await call { let response = try await api.setCurrentUserAvatar(body: .binary(.init(data))) @@ -65,9 +68,13 @@ extension SettingsScreenProtocol { return .error() } } + + isLoadingAvatar = false } func removeAvatar() async { + isLoadingAvatar = true + await call { let response = try await api.deleteCurrentUserAvatar() @@ -83,6 +90,8 @@ extension SettingsScreenProtocol { return .error() } } + + isLoadingAvatar = false } func logout() {