mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
UI on create room screen
This commit is contained in:
@@ -21,6 +21,7 @@ enum FormRowAccessory: View {
|
|||||||
case navigationLink
|
case navigationLink
|
||||||
case progressView
|
case progressView
|
||||||
case selection(isSelected: Bool)
|
case selection(isSelected: Bool)
|
||||||
|
case singleSelection(isSelected: Bool)
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
switch self {
|
switch self {
|
||||||
@@ -34,6 +35,10 @@ enum FormRowAccessory: View {
|
|||||||
Image(systemName: isSelected ? "checkmark.circle.fill" : "circle")
|
Image(systemName: isSelected ? "checkmark.circle.fill" : "circle")
|
||||||
.font(.compound.bodyLG)
|
.font(.compound.bodyLG)
|
||||||
.foregroundColor(isSelected ? .element.primaryContent : .element.tertiaryContent)
|
.foregroundColor(isSelected ? .element.primaryContent : .element.tertiaryContent)
|
||||||
|
case .singleSelection(let isSelected):
|
||||||
|
Image(systemName: "checkmark")
|
||||||
|
.font(.compound.bodyLG)
|
||||||
|
.foregroundColor(isSelected ? .element.primaryContent : .clear)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,13 +48,15 @@ enum FormRowAccessory: View {
|
|||||||
/// The primitive style is needed to set the list row insets to `0`. The inner style is then needed
|
/// The primitive style is needed to set the list row insets to `0`. The inner style is then needed
|
||||||
/// to change the background colour depending on whether the button is currently pressed or not.
|
/// to change the background colour depending on whether the button is currently pressed or not.
|
||||||
struct FormButtonStyle: PrimitiveButtonStyle {
|
struct FormButtonStyle: PrimitiveButtonStyle {
|
||||||
|
var iconAlignment: VerticalAlignment = .firstTextBaseline
|
||||||
|
|
||||||
/// An accessory to be added on the trailing side of the row.
|
/// An accessory to be added on the trailing side of the row.
|
||||||
var accessory: FormRowAccessory?
|
var accessory: FormRowAccessory?
|
||||||
|
|
||||||
func makeBody(configuration: Configuration) -> some View {
|
func makeBody(configuration: Configuration) -> some View {
|
||||||
Button(action: configuration.trigger) {
|
Button(action: configuration.trigger) {
|
||||||
configuration.label
|
configuration.label
|
||||||
.labelStyle(FormRowLabelStyle(role: configuration.role))
|
.labelStyle(FormRowLabelStyle(alignment: iconAlignment, role: configuration.role))
|
||||||
.frame(maxHeight: .infinity) // Make sure the label fills the cell vertically.
|
.frame(maxHeight: .infinity) // Make sure the label fills the cell vertically.
|
||||||
}
|
}
|
||||||
.buttonStyle(Style(accessory: accessory))
|
.buttonStyle(Style(accessory: accessory))
|
||||||
@@ -133,6 +140,14 @@ struct FormButtonStyles_Previews: PreviewProvider {
|
|||||||
Text("Selection")
|
Text("Selection")
|
||||||
}
|
}
|
||||||
.buttonStyle(FormButtonStyle(accessory: .selection(isSelected: false)))
|
.buttonStyle(FormButtonStyle(accessory: .selection(isSelected: false)))
|
||||||
|
Button { } label: {
|
||||||
|
VStack(alignment: .listRowSeparatorLeading, spacing: 0) {
|
||||||
|
Label("Hello world", systemImage: "globe")
|
||||||
|
Text("subtitle\nsubtitle")
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.buttonStyle(FormButtonStyle(iconAlignment: .top, accessory: .singleSelection(isSelected: true)))
|
||||||
}
|
}
|
||||||
.formSectionStyle()
|
.formSectionStyle()
|
||||||
|
|
||||||
|
|||||||
@@ -34,38 +34,41 @@ struct CreateRoomScreen: View {
|
|||||||
|
|
||||||
/// The main content of the view to be shown in a scroll view.
|
/// The main content of the view to be shown in a scroll view.
|
||||||
var mainContent: some View {
|
var mainContent: some View {
|
||||||
VStack(alignment: .center, spacing: 24) {
|
Form {
|
||||||
// TODO: check spacing
|
|
||||||
roomSection
|
roomSection
|
||||||
Form {
|
topicSection
|
||||||
topicSection
|
|
||||||
}
|
|
||||||
selectedUsersSection
|
selectedUsersSection
|
||||||
|
// TODO: Spacer not working properly
|
||||||
Spacer()
|
Spacer()
|
||||||
Form {
|
.listRowBackground(Color.clear)
|
||||||
securitySection
|
securitySection
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ScaledMetric private var roomIconSide: CGFloat = 64
|
||||||
private var roomSection: some View {
|
private var roomSection: some View {
|
||||||
// TODO: Style better
|
Section {
|
||||||
HStack(alignment: .top, spacing: 0) {
|
HStack(alignment: .center, spacing: 16) {
|
||||||
Image(systemName: "camera")
|
Image(systemName: "camera")
|
||||||
.frame(width: 70, height: 70)
|
.foregroundColor(.element.secondaryContent)
|
||||||
.clipShape(Circle())
|
.frame(width: roomIconSide, height: roomIconSide)
|
||||||
Form {
|
.background(Color.element.quinaryContent)
|
||||||
Section {
|
.clipShape(Circle())
|
||||||
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
|
Text(L10n.screenCreateRoomRoomNameLabel.uppercased())
|
||||||
|
.formSectionHeader()
|
||||||
TextField(L10n.screenCreateRoomRoomNameLabel,
|
TextField(L10n.screenCreateRoomRoomNameLabel,
|
||||||
text: $context.roomName,
|
text: $context.roomName,
|
||||||
prompt: Text(L10n.screenCreateRoomRoomNamePlaceholder),
|
prompt: Text(L10n.screenCreateRoomRoomNamePlaceholder),
|
||||||
axis: .horizontal)
|
axis: .horizontal)
|
||||||
} header: {
|
.padding(FormRow.insets)
|
||||||
Text(L10n.screenCreateRoomRoomNameLabel)
|
.background(Color.element.formRowBackground)
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: 8))
|
||||||
}
|
}
|
||||||
.formSectionStyle()
|
|
||||||
}
|
}
|
||||||
|
.listRowBackground(Color.clear)
|
||||||
}
|
}
|
||||||
|
.formSectionStyle()
|
||||||
}
|
}
|
||||||
|
|
||||||
private var topicSection: some View {
|
private var topicSection: some View {
|
||||||
@@ -83,33 +86,46 @@ struct CreateRoomScreen: View {
|
|||||||
|
|
||||||
@ScaledMetric private var cellWidth: CGFloat = 64
|
@ScaledMetric private var cellWidth: CGFloat = 64
|
||||||
private var selectedUsersSection: some View {
|
private var selectedUsersSection: some View {
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
Section {
|
||||||
HStack(spacing: 28) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
ForEach(context.viewState.selectedUsers, id: \.userID) { user in
|
HStack(spacing: 28) {
|
||||||
InviteUsersScreenSelectedItem(user: user, imageProvider: context.imageProvider) {
|
ForEach(context.viewState.selectedUsers, id: \.userID) { user in
|
||||||
deselect(user)
|
InviteUsersScreenSelectedItem(user: user, imageProvider: context.imageProvider) {
|
||||||
|
deselect(user)
|
||||||
|
}
|
||||||
|
.frame(width: cellWidth)
|
||||||
}
|
}
|
||||||
.frame(width: cellWidth)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 18)
|
.listRowBackground(Color.clear)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var securitySection: some View {
|
private var securitySection: some View {
|
||||||
Section {
|
Section {
|
||||||
// TODO: style this items with descrition text and proper selection image
|
|
||||||
Button(action: selectPrivate) {
|
Button(action: selectPrivate) {
|
||||||
Label(L10n.screenCreateRoomPrivateOptionTitle, systemImage: "lock.shield")
|
VStack(alignment: .listRowSeparatorLeading, spacing: 0) {
|
||||||
|
Label(L10n.screenCreateRoomPrivateOptionTitle, systemImage: "lock.shield")
|
||||||
|
Text(L10n.screenCreateRoomPrivateOptionDescription)
|
||||||
|
.font(.compound.bodyMD)
|
||||||
|
// TODO: padding not working properly
|
||||||
|
.padding(.horizontal, 20)
|
||||||
|
.foregroundColor(.element.secondaryContent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.buttonStyle(FormButtonStyle(accessory: .selection(isSelected: context.isRoomPrivate)))
|
.buttonStyle(FormButtonStyle(iconAlignment: .top, accessory: .singleSelection(isSelected: context.isRoomPrivate)))
|
||||||
Button(action: selectPublic) {
|
Button(action: selectPublic) {
|
||||||
Label(L10n.screenCreateRoomPublicOptionTitle, systemImage: "exclamationmark.shield")
|
VStack(alignment: .listRowSeparatorLeading, spacing: 0) {
|
||||||
|
Label(L10n.screenCreateRoomPublicOptionTitle, systemImage: "exclamationmark.shield")
|
||||||
|
Text(L10n.screenCreateRoomPublicOptionDescription)
|
||||||
|
.font(.compound.bodyMD)
|
||||||
|
.padding(.horizontal)
|
||||||
|
.foregroundColor(.element.secondaryContent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.buttonStyle(FormButtonStyle(accessory: .selection(isSelected: !context.isRoomPrivate)))
|
.buttonStyle(FormButtonStyle(iconAlignment: .top, accessory: .singleSelection(isSelected: !context.isRoomPrivate)))
|
||||||
} header: {
|
} header: {
|
||||||
// TODO: localize
|
Text(L10n.commonSecurity.uppercased())
|
||||||
Text("SECURITY")
|
|
||||||
}
|
}
|
||||||
.formSectionStyle()
|
.formSectionStyle()
|
||||||
}
|
}
|
||||||
@@ -140,7 +156,9 @@ struct CreateRoom_Previews: PreviewProvider {
|
|||||||
static let viewModel = {
|
static let viewModel = {
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@userid:example.com"),
|
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@userid:example.com"),
|
||||||
mediaProvider: MockMediaProvider())
|
mediaProvider: MockMediaProvider())
|
||||||
return CreateRoomViewModel(userSession: userSession, selectedUsers: [.mockAlice, .mockBob, .mockCharlie])
|
let parameters = CreateRoomVolatileParameters()
|
||||||
|
parameters.selectedUsers = [.mockAlice, .mockBob, .mockCharlie]
|
||||||
|
return CreateRoomViewModel(userSession: userSession, createRoomParameters: parameters)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
|
|||||||
Reference in New Issue
Block a user