mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 13:37:11 +00:00
Knock a room - added a char counter for the message (#3570)
* added a char counter * moved code
This commit is contained in:
parent
b8085356fb
commit
c7afde3801
@ -9,6 +9,7 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct JoinRoomScreen: View {
|
||||
private let maxKnockMessageLength = 500
|
||||
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
|
||||
|
||||
@ObservedObject var context: JoinRoomScreenViewModel.Context
|
||||
@ -103,6 +104,13 @@ struct JoinRoomScreen: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var knockMessageFooterString: String {
|
||||
guard !context.knockMessage.isEmpty else {
|
||||
return L10n.screenJoinRoomKnockMessageDescription
|
||||
}
|
||||
return "\(context.knockMessage.count)/\(maxKnockMessageLength)"
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var knockMessage: some View {
|
||||
@ -110,7 +118,7 @@ struct JoinRoomScreen: View {
|
||||
HStack(spacing: 0) {
|
||||
TextField("", text: $context.knockMessage, axis: .vertical)
|
||||
.onChange(of: context.knockMessage) { _, newValue in
|
||||
context.knockMessage = String(newValue.prefix(500))
|
||||
context.knockMessage = String(newValue.prefix(maxKnockMessageLength))
|
||||
}
|
||||
.lineLimit(4, reservesSpace: true)
|
||||
.font(.compound.bodyMD)
|
||||
@ -125,8 +133,8 @@ struct JoinRoomScreen: View {
|
||||
.stroke(.compound.borderInteractivePrimary)
|
||||
}
|
||||
|
||||
Text(L10n.screenJoinRoomKnockMessageDescription)
|
||||
.font(.compound.bodyMD)
|
||||
Text(knockMessageFooterString)
|
||||
.font(.compound.bodySM)
|
||||
.foregroundStyle(.compound.textSecondary)
|
||||
}
|
||||
}
|
||||
|
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Knock.png
(Stored with Git LFS)
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Knock.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Knock.png
(Stored with Git LFS)
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Knock.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Knock.png
(Stored with Git LFS)
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Knock.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Knock.png
(Stored with Git LFS)
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Knock.png
(Stored with Git LFS)
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user