mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
implemented the space selection list and the selection logic
# Conflicts: # ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomScreen.swift
This commit is contained in:
@@ -204,6 +204,8 @@ internal enum L10n {
|
||||
internal static var actionEndPoll: String { return L10n.tr("Localizable", "action_end_poll") }
|
||||
/// Enter PIN
|
||||
internal static var actionEnterPin: String { return L10n.tr("Localizable", "action_enter_pin") }
|
||||
/// Explore public spaces
|
||||
internal static var actionExplorePublicSpaces: String { return L10n.tr("Localizable", "action_explore_public_spaces") }
|
||||
/// Finish
|
||||
internal static var actionFinish: String { return L10n.tr("Localizable", "action_finish") }
|
||||
/// Forgot password?
|
||||
@@ -1634,6 +1636,12 @@ internal enum L10n {
|
||||
internal static var screenCreateRoomRoomAddressSectionTitle: String { return L10n.tr("Localizable", "screen_create_room_room_address_section_title") }
|
||||
/// Room visibility
|
||||
internal static var screenCreateRoomRoomVisibilitySectionTitle: String { return L10n.tr("Localizable", "screen_create_room_room_visibility_section_title") }
|
||||
/// (no space)
|
||||
internal static var screenCreateRoomSpaceSelectionNoSpaceDescription: String { return L10n.tr("Localizable", "screen_create_room_space_selection_no_space_description") }
|
||||
/// Home
|
||||
internal static var screenCreateRoomSpaceSelectionNoSpaceTitle: String { return L10n.tr("Localizable", "screen_create_room_space_selection_no_space_title") }
|
||||
/// Add to space
|
||||
internal static var screenCreateRoomSpaceSelectionSheetTitle: String { return L10n.tr("Localizable", "screen_create_room_space_selection_sheet_title") }
|
||||
/// Topic (optional)
|
||||
internal static var screenCreateRoomTopicLabel: String { return L10n.tr("Localizable", "screen_create_room_topic_label") }
|
||||
/// Add description…
|
||||
|
||||
@@ -234,7 +234,10 @@ struct CreateRoomScreen: View {
|
||||
context.showSpaceSelectionSheet = true
|
||||
})
|
||||
} else {
|
||||
ListRow(label: .default(title: "Test", icon: \.home),
|
||||
ListRow(label: .default(title: L10n.screenCreateRoomSpaceSelectionNoSpaceTitle,
|
||||
description: L10n.screenCreateRoomSpaceSelectionNoSpaceDescription,
|
||||
icon: \.home,
|
||||
iconAlignment: .top),
|
||||
kind: .navigationLink {
|
||||
context.showSpaceSelectionSheet = true
|
||||
})
|
||||
|
||||
@@ -5,18 +5,80 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct CreateRoomSpaceSelectionSheet: View {
|
||||
@ObservedObject var context: CreateRoomScreenViewModel.Context
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
private var dragIndicatorVisibilty: Visibility {
|
||||
if #available(iOS 26, *) {
|
||||
.hidden
|
||||
} else {
|
||||
.automatic
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
EmptyView()
|
||||
NavigationStack {
|
||||
List {
|
||||
Section {
|
||||
ListRow(label: .default(title: L10n.screenCreateRoomSpaceSelectionNoSpaceTitle,
|
||||
description: L10n.screenCreateRoomSpaceSelectionNoSpaceDescription,
|
||||
icon: \.home),
|
||||
kind: .selection(isSelected: context.selectedSpace == nil) {
|
||||
context.selectedSpace = nil
|
||||
dismiss()
|
||||
})
|
||||
ForEach(context.viewState.topLevelSpaces, id: \.id) { space in
|
||||
ListRow(label: .avatar(title: space.name,
|
||||
description: space.canonicalAlias,
|
||||
icon: RoomAvatarImage(avatar: space.avatar,
|
||||
avatarSize: .room(on: .createRoomSelectSpace),
|
||||
mediaProvider: context.mediaProvider)),
|
||||
kind: .selection(isSelected: context.selectedSpace?.id == space.id) {
|
||||
context.selectedSpace = space
|
||||
dismiss()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.environment(\.defaultMinListRowHeight, 66)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
|
||||
.navigationTitle(L10n.screenCreateRoomSpaceSelectionSheetTitle)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .topBarTrailing) {
|
||||
ToolbarButton(role: .cancel) {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
.presentationDetents([.medium, .large])
|
||||
.presentationDragIndicator(dragIndicatorVisibilty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CreateRoomSpaceSelectionSheet_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = {
|
||||
let clientProxy = ClientProxyMock(.init(userID: "@userid:example.com"))
|
||||
clientProxy.spaceService = SpaceServiceProxyMock(.init(topLevelSpaces: .mockJoinedSpaces2))
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
return CreateRoomScreenViewModel(isSpace: false,
|
||||
spaceSelectionMode: .list,
|
||||
shouldShowCancelButton: false,
|
||||
userSession: userSession,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
EmptyView()
|
||||
CreateRoomSpaceSelectionSheet(context: viewModel.context)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user