mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
Compound icons part III - Revenge of the SF Symbol (#2093)
* Use Compound in StartChat screen. * Update location sharing icons.
This commit is contained in:
@@ -65,10 +65,10 @@ internal enum Asset {
|
||||
internal static let settingsIconWithBadge = ImageAsset(name: "images/settings-icon-with-badge")
|
||||
internal static let signOut = ImageAsset(name: "images/sign-out")
|
||||
internal static let launchBackground = ImageAsset(name: "images/launch-background")
|
||||
internal static let locationMarker = ImageAsset(name: "images/location-marker")
|
||||
internal static let locationPin = ImageAsset(name: "images/location-pin")
|
||||
internal static let locationPointerFull = ImageAsset(name: "images/location-pointer-full")
|
||||
internal static let locationPointer = ImageAsset(name: "images/location-pointer")
|
||||
internal static let locationMarkerShape = ImageAsset(name: "images/location-marker-shape")
|
||||
internal static let locationNavigatorCentred = ImageAsset(name: "images/location-navigator-centred")
|
||||
internal static let locationNavigator = ImageAsset(name: "images/location-navigator")
|
||||
internal static let locationPinSolid = ImageAsset(name: "images/location-pin-solid")
|
||||
internal static let lock = ImageAsset(name: "images/lock")
|
||||
internal static let mediaPause = ImageAsset(name: "images/media-pause")
|
||||
internal static let mediaPlay = ImageAsset(name: "images/media-play")
|
||||
|
||||
@@ -14,15 +14,56 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct LocationMarkerView: View {
|
||||
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
|
||||
|
||||
var mode: Mode = .map
|
||||
enum Mode { case map, button }
|
||||
|
||||
private let pinColor: Color = .compound.iconOnSolidPrimary
|
||||
private let pinInsets = EdgeInsets(top: 13, leading: 12, bottom: 15, trailing: 12)
|
||||
private let buttonScale: Double = 28 / 52
|
||||
|
||||
var body: some View {
|
||||
Image(Asset.Images.locationMarker.name)
|
||||
switch mode {
|
||||
case .map: mapMarker
|
||||
case .button: buttonMarker
|
||||
}
|
||||
}
|
||||
|
||||
var mapMarker: some View {
|
||||
CompoundIcon(asset: Asset.Images.locationPinSolid)
|
||||
.dynamicTypeSize(.large)
|
||||
.foregroundStyle(pinColor)
|
||||
.padding(pinInsets)
|
||||
.background {
|
||||
backgroundShape
|
||||
.shadow(color: .black.opacity(0.2), radius: 4.1129, x: 0, y: 4.93548)
|
||||
}
|
||||
.alignmentGuide(VerticalAlignment.center) { dimensions in
|
||||
dimensions[.bottom]
|
||||
}
|
||||
.shadow(color: .black.opacity(0.2), radius: 8, x: 0, y: 5)
|
||||
}
|
||||
|
||||
var buttonMarker: some View {
|
||||
CompoundIcon(asset: Asset.Images.locationPinSolid, size: .custom(13), relativeTo: .body)
|
||||
.foregroundStyle(pinColor)
|
||||
.scaledPadding(.top, pinInsets.top * buttonScale)
|
||||
.scaledPadding(.bottom, pinInsets.bottom * buttonScale)
|
||||
.scaledPadding(.horizontal, pinInsets.leading * buttonScale)
|
||||
.background {
|
||||
backgroundShape
|
||||
}
|
||||
}
|
||||
|
||||
var backgroundShape: some View {
|
||||
Image(asset: Asset.Images.locationMarkerShape)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.foregroundStyle(.compound.iconPrimary)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +74,11 @@ struct LocationMarkerView_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
LocationMarkerView()
|
||||
.colorScheme(.dark)
|
||||
|
||||
LocationMarkerView(mode: .button)
|
||||
|
||||
LocationMarkerView(mode: .button)
|
||||
.colorScheme(.dark)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct StaticLocationScreen: View {
|
||||
@@ -109,10 +110,7 @@ struct StaticLocationScreen: View {
|
||||
context.send(viewAction: .selectLocation)
|
||||
} label: {
|
||||
HStack(spacing: 8) {
|
||||
Image(asset: Asset.Images.locationMarker)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.scaledFrame(size: 28)
|
||||
LocationMarkerView(mode: .button)
|
||||
Text(context.viewState.isSharingUserLocation ? L10n.screenShareMyLocationAction : L10n.screenShareThisLocationAction)
|
||||
}
|
||||
}
|
||||
@@ -122,8 +120,11 @@ struct StaticLocationScreen: View {
|
||||
Button {
|
||||
context.send(viewAction: .centerToUser)
|
||||
} label: {
|
||||
Image(asset: context.viewState.isSharingUserLocation ? Asset.Images.locationPointerFull : Asset.Images.locationPointer)
|
||||
CompoundIcon(asset: context.viewState.isSharingUserLocation ? Asset.Images.locationNavigatorCentred : Asset.Images.locationNavigator)
|
||||
.padding(8)
|
||||
.background(.compound.bgCanvasDefault, in: RoundedRectangle(cornerRadius: 6))
|
||||
}
|
||||
.dynamicTypeSize(.large)
|
||||
.padding(16)
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ final class StartChatScreenCoordinator: CoordinatorProtocol {
|
||||
self.parameters = parameters
|
||||
|
||||
viewModel = StartChatScreenViewModel(userSession: parameters.userSession,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
userSuggestionsEnabled: ServiceLocator.shared.settings.userSuggestionsEnabled,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
userDiscoveryService: parameters.userDiscoveryService)
|
||||
|
||||
@@ -21,7 +21,7 @@ typealias StartChatScreenViewModelType = StateStoreViewModel<StartChatScreenView
|
||||
|
||||
class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenViewModelProtocol {
|
||||
private let userSession: UserSessionProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let userSuggestionsEnabled: Bool
|
||||
private let analytics: AnalyticsService
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let userDiscoveryService: UserDiscoveryServiceProtocol
|
||||
@@ -33,12 +33,12 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
|
||||
}
|
||||
|
||||
init(userSession: UserSessionProtocol,
|
||||
appSettings: AppSettings,
|
||||
userSuggestionsEnabled: Bool,
|
||||
analytics: AnalyticsService,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
userDiscoveryService: UserDiscoveryServiceProtocol) {
|
||||
self.userSession = userSession
|
||||
self.appSettings = appSettings
|
||||
self.userSuggestionsEnabled = userSuggestionsEnabled
|
||||
self.analytics = analytics
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.userDiscoveryService = userDiscoveryService
|
||||
@@ -115,7 +115,7 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
|
||||
}
|
||||
|
||||
private func fetchSuggestions() {
|
||||
guard appSettings.userSuggestionsEnabled else {
|
||||
guard userSuggestionsEnabled else {
|
||||
state.usersSection = .init(type: .suggestions, users: [])
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,16 +28,12 @@ struct StartChatScreen: View {
|
||||
searchContent
|
||||
}
|
||||
}
|
||||
.compoundForm()
|
||||
.compoundList()
|
||||
.track(screen: .startChat)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
.navigationTitle(L10n.actionStartChat)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
closeButton
|
||||
}
|
||||
}
|
||||
.toolbar { toolbar }
|
||||
.disableInteractiveDismissOnSearch()
|
||||
.dismissSearchOnDisappear()
|
||||
.searchable(text: $context.searchQuery, placement: .navigationBarDrawer(displayMode: .always), prompt: L10n.commonSearchForSomeone)
|
||||
@@ -67,25 +63,23 @@ struct StartChatScreen: View {
|
||||
|
||||
private var createRoomSection: some View {
|
||||
Section {
|
||||
Button(action: createRoom) {
|
||||
Label(L10n.screenCreateRoomActionCreateRoom, systemImage: "person.3")
|
||||
.imageScale(.small)
|
||||
}
|
||||
.buttonStyle(FormButtonStyle(accessory: .navigationLink))
|
||||
.accessibilityIdentifier(A11yIdentifiers.startChatScreen.createRoom)
|
||||
ListRow(label: .default(title: L10n.screenCreateRoomActionCreateRoom,
|
||||
icon: \.plus),
|
||||
kind: .navigationLink { context.send(viewAction: .createRoom) })
|
||||
.accessibilityIdentifier(A11yIdentifiers.startChatScreen.createRoom)
|
||||
}
|
||||
.compoundFormSection()
|
||||
}
|
||||
|
||||
private var inviteFriendsSection: some View {
|
||||
Section {
|
||||
MatrixUserShareLink(userID: context.viewState.userID) {
|
||||
Label(L10n.actionInvitePeopleToApp(InfoPlistReader.main.bundleDisplayName), systemImage: "square.and.arrow.up")
|
||||
}
|
||||
.buttonStyle(FormButtonStyle())
|
||||
ListRow(kind: .custom {
|
||||
MatrixUserShareLink(userID: context.viewState.userID) {
|
||||
ListLabel.default(title: L10n.actionInvitePeopleToApp(InfoPlistReader.main.bundleDisplayName),
|
||||
icon: CompoundIcon(asset: Asset.Images.shareIos))
|
||||
}
|
||||
})
|
||||
.accessibilityIdentifier(A11yIdentifiers.startChatScreen.inviteFriends)
|
||||
}
|
||||
.compoundFormSection()
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
@@ -93,17 +87,21 @@ struct StartChatScreen: View {
|
||||
if !context.viewState.usersSection.users.isEmpty {
|
||||
Section {
|
||||
ForEach(context.viewState.usersSection.users, id: \.userID) { user in
|
||||
Button { context.send(viewAction: .selectUser(user)) } label: {
|
||||
UserProfileCell(user: user, membership: nil, imageProvider: context.imageProvider)
|
||||
}
|
||||
.buttonStyle(FormButtonStyle())
|
||||
ListRow(kind: .custom {
|
||||
Button { context.send(viewAction: .selectUser(user)) } label: {
|
||||
UserProfileCell(user: user, membership: nil, imageProvider: context.imageProvider)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
|
||||
.padding(.horizontal, ListRowPadding.horizontal)
|
||||
.padding(.vertical, 8)
|
||||
}
|
||||
})
|
||||
}
|
||||
} header: {
|
||||
if let title = context.viewState.usersSection.title {
|
||||
Text(title)
|
||||
.compoundListSectionHeader()
|
||||
}
|
||||
}
|
||||
.compoundFormSection()
|
||||
} else {
|
||||
Section.empty
|
||||
}
|
||||
@@ -118,17 +116,13 @@ struct StartChatScreen: View {
|
||||
.accessibilityIdentifier(A11yIdentifiers.startChatScreen.searchNoResults)
|
||||
}
|
||||
|
||||
private var closeButton: some View {
|
||||
Button(L10n.actionCancel, action: close)
|
||||
private var toolbar: some ToolbarContent {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button(L10n.actionCancel) {
|
||||
context.send(viewAction: .close)
|
||||
}
|
||||
.accessibilityIdentifier(A11yIdentifiers.startChatScreen.closeStartChat)
|
||||
}
|
||||
|
||||
private func createRoom() {
|
||||
context.send(viewAction: .createRoom)
|
||||
}
|
||||
|
||||
private func close() {
|
||||
context.send(viewAction: .close)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +137,7 @@ struct StartChatScreen_Previews: PreviewProvider, TestablePreview {
|
||||
userDiscoveryService.fetchSuggestionsReturnValue = .success([.mockAlice])
|
||||
userDiscoveryService.searchProfilesWithReturnValue = .success([.mockAlice])
|
||||
let viewModel = StartChatScreenViewModel(userSession: userSession,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
userSuggestionsEnabled: true,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userDiscoveryService: userDiscoveryService)
|
||||
|
||||
Reference in New Issue
Block a user