mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Use Compound icons within the user indicators.
This commit is contained in:
@@ -885,6 +885,6 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol {
|
||||
flowParameters.userIndicatorController.submitIndicator(UserIndicator(id: Self.failureIndicatorIdentifier,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1067,7 +1067,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
case .cancel:
|
||||
break
|
||||
case .finish:
|
||||
flowParameters.userIndicatorController.submitIndicator(UserIndicator(title: L10n.commonReportSubmitted, iconName: "checkmark"))
|
||||
flowParameters.userIndicatorController.submitIndicator(UserIndicator(title: L10n.commonReportSubmitted, icon: \.check))
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Compound
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
enum UserIndicatorType: Equatable {
|
||||
case toast(progress: UserIndicator.Progress?)
|
||||
@@ -40,7 +42,7 @@ struct UserIndicator: Equatable, Identifiable {
|
||||
var type: UserIndicatorType = .toast
|
||||
var title: String
|
||||
var message: String?
|
||||
var iconName: String?
|
||||
var icon: KeyPath<CompoundIcons, Image>?
|
||||
var persistent = false
|
||||
|
||||
// MARK: - Associated values from the type
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct UserIndicatorModalView: View {
|
||||
@@ -23,9 +24,8 @@ struct UserIndicatorModalView: View {
|
||||
}
|
||||
|
||||
HStack(spacing: 8) {
|
||||
if let iconName = indicator.iconName {
|
||||
Image(systemName: iconName)
|
||||
.font(titleFont)
|
||||
if let icon = indicator.icon {
|
||||
CompoundIcon(icon, size: .medium, relativeTo: .compound.headingMDBold)
|
||||
.foregroundColor(.compound.iconPrimary)
|
||||
}
|
||||
|
||||
@@ -76,24 +76,24 @@ struct UserIndicatorModalView_Previews: PreviewProvider, TestablePreview {
|
||||
VStack(spacing: 0) {
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
|
||||
title: "Successfully logged in",
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal(progress: .published(CurrentValueSubject<Double, Never>(0.5).asCurrentValuePublisher()),
|
||||
interactiveDismissDisabled: false,
|
||||
allowsInteraction: false),
|
||||
title: "Successfully logged in",
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal(progress: .none,
|
||||
interactiveDismissDisabled: false,
|
||||
allowsInteraction: false),
|
||||
title: "Successfully logged in",
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
|
||||
title: "Successfully logged in",
|
||||
message: "You can now be happy.",
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct UserIndicatorToastView: View {
|
||||
@@ -18,9 +19,8 @@ struct UserIndicatorToastView: View {
|
||||
.controlSize(.small)
|
||||
.tint(.compound.iconPrimary)
|
||||
}
|
||||
if let iconName = indicator.iconName {
|
||||
Image(systemName: iconName)
|
||||
.font(.compound.bodyMD)
|
||||
if let icon = indicator.icon {
|
||||
CompoundIcon(icon, size: .small, relativeTo: .compound.bodyMD)
|
||||
.foregroundColor(.compound.iconPrimary)
|
||||
}
|
||||
Text(indicator.title)
|
||||
@@ -48,7 +48,7 @@ struct UserIndicatorToastView_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
VStack(spacing: 30) {
|
||||
UserIndicatorToastView(indicator: UserIndicator(title: "Successfully logged in",
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
|
||||
UserIndicatorToastView(indicator: UserIndicator(title: "Toast without icon"))
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ class OAuthAuthenticationPresenter: NSObject {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: failureIndicatorID,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,6 @@ final class BugReportScreenCoordinator: CoordinatorProtocol {
|
||||
}
|
||||
|
||||
private func showError(label: String) {
|
||||
parameters.userIndicatorController?.submitIndicator(UserIndicator(title: label, iconName: "xmark"))
|
||||
parameters.userIndicatorController?.submitIndicator(UserIndicator(title: label, icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,6 @@ class DeclineAndBlockScreenViewModel: DeclineAndBlockScreenViewModelType, Declin
|
||||
}
|
||||
|
||||
private func showSuccess() {
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.commonSuccess, iconName: "checkmark"))
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.commonSuccess, icon: \.check))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,21 +213,21 @@ class TimelineMediaPreviewViewModel: TimelineMediaPreviewViewModelType {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: statusIndicatorID,
|
||||
type: .toast,
|
||||
title: L10n.commonFileDeleted,
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
}
|
||||
|
||||
private func showSavedIndicator() {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: statusIndicatorID,
|
||||
type: .toast,
|
||||
title: L10n.commonFileSaved,
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
}
|
||||
|
||||
private func showErrorIndicator() {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: statusIndicatorID,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
|
||||
private func showTimelineEndIndicator() {
|
||||
|
||||
@@ -453,7 +453,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: UUID().uuidString,
|
||||
type: .toast,
|
||||
title: L10n.commonCurrentUserLeftRoom,
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
actionsSubject.send(.roomLeft(roomIdentifier: roomID))
|
||||
}
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.statusIndicatorID,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
|
||||
private func showLoader() {
|
||||
|
||||
@@ -140,7 +140,7 @@ class ManageRoomMemberSheetViewModel: ManageRoomMemberSheetViewModelType, Manage
|
||||
|
||||
private func showManageMemberFailure(title: String) {
|
||||
userIndicatorController.retractIndicatorWithId(title)
|
||||
userIndicatorController.submitIndicator(UserIndicator(title: L10n.commonFailed, iconName: "xmark"))
|
||||
userIndicatorController.submitIndicator(UserIndicator(title: L10n.commonFailed, icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class ReportRoomScreenViewModel: ReportRoomScreenViewModelType, ReportRoomScreen
|
||||
await leaveRoom(showLoading: false)
|
||||
} else {
|
||||
hideLoadingIndicator()
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.dialogRoomReported, iconName: "checkmark"))
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.dialogRoomReported, icon: \.check))
|
||||
actionsSubject.send(.dismiss(shouldLeaveRoom: false))
|
||||
}
|
||||
case .failure:
|
||||
@@ -70,7 +70,7 @@ class ReportRoomScreenViewModel: ReportRoomScreenViewModelType, ReportRoomScreen
|
||||
|
||||
switch result {
|
||||
case .success:
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.dialogRoomReportedAndLeft, iconName: "checkmark"))
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.dialogRoomReportedAndLeft, icon: \.check))
|
||||
actionsSubject.send(.dismiss(shouldLeaveRoom: true))
|
||||
case .failure:
|
||||
state.bindings.alert = .init(id: .leaveRoomFailed,
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ class ResolveVerifiedUserSendFailureScreenViewModel: ResolveVerifiedUserSendFail
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.failureIndicatorIdentifier,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ class RoomDirectorySearchScreenViewModel: RoomDirectorySearchScreenViewModelType
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.errorID,
|
||||
type: .toast,
|
||||
title: L10n.screenRoomDirectorySearchLoadingError,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
|
||||
// Add a small delay to allow the rooms to be published,
|
||||
|
||||
+1
-1
@@ -273,6 +273,6 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: statusIndicatorIdentifier,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ class RoomMembersListScreenViewModel: RoomMembersListScreenViewModelType, RoomMe
|
||||
|
||||
private func showManageMemberFailure(title: String) {
|
||||
userIndicatorController.retractIndicatorWithId(title)
|
||||
userIndicatorController.submitIndicator(UserIndicator(title: L10n.commonFailed, iconName: "xmark"))
|
||||
userIndicatorController.submitIndicator(UserIndicator(title: L10n.commonFailed, icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -169,6 +169,6 @@ class RoomRolesAndPermissionsScreenViewModel: RoomRolesAndPermissionsScreenViewM
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.successIndicatorID,
|
||||
type: .toast,
|
||||
title: L10n.commonSuccess,
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ final class SecureBackupRecoveryKeyScreenCoordinator: CoordinatorProtocol {
|
||||
parameters.userIndicatorController.submitIndicator(.init(id: .init(),
|
||||
type: .toast(progress: nil),
|
||||
title: title,
|
||||
iconName: "checkmark",
|
||||
icon: \.check,
|
||||
persistent: false))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class LeaveSpaceViewModel: LeaveSpaceViewModelType {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.failureIndicatorID,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -187,6 +187,6 @@ class SpaceAddRoomsScreenViewModel: SpaceAddRoomsScreenViewModelType, SpaceAddRo
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: failureIndicatorID,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,6 +295,6 @@ class SpaceScreenViewModel: SpaceScreenViewModelType, SpaceScreenViewModelProtoc
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.failureIndicatorID,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,6 @@ class SpacesScreenViewModel: SpacesScreenViewModelType, SpacesScreenViewModelPro
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.failureIndicatorID,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1106,7 +1106,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Constants.toastErrorID,
|
||||
type: .toast,
|
||||
title: title,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -190,6 +190,6 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: statusIndicatorIdentifier,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
icon: \.close))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user