mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Knock a room - added a char counter for the message (#3570)
* added a char counter * moved code
This commit is contained in:
@@ -9,6 +9,7 @@ import Compound
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct JoinRoomScreen: View {
|
struct JoinRoomScreen: View {
|
||||||
|
private let maxKnockMessageLength = 500
|
||||||
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
|
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
|
||||||
|
|
||||||
@ObservedObject var context: JoinRoomScreenViewModel.Context
|
@ObservedObject var context: JoinRoomScreenViewModel.Context
|
||||||
@@ -104,13 +105,20 @@ struct JoinRoomScreen: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var knockMessageFooterString: String {
|
||||||
|
guard !context.knockMessage.isEmpty else {
|
||||||
|
return L10n.screenJoinRoomKnockMessageDescription
|
||||||
|
}
|
||||||
|
return "\(context.knockMessage.count)/\(maxKnockMessageLength)"
|
||||||
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var knockMessage: some View {
|
private var knockMessage: some View {
|
||||||
VStack(alignment: .leading, spacing: 12) {
|
VStack(alignment: .leading, spacing: 12) {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
TextField("", text: $context.knockMessage, axis: .vertical)
|
TextField("", text: $context.knockMessage, axis: .vertical)
|
||||||
.onChange(of: context.knockMessage) { _, newValue in
|
.onChange(of: context.knockMessage) { _, newValue in
|
||||||
context.knockMessage = String(newValue.prefix(500))
|
context.knockMessage = String(newValue.prefix(maxKnockMessageLength))
|
||||||
}
|
}
|
||||||
.lineLimit(4, reservesSpace: true)
|
.lineLimit(4, reservesSpace: true)
|
||||||
.font(.compound.bodyMD)
|
.font(.compound.bodyMD)
|
||||||
@@ -125,8 +133,8 @@ struct JoinRoomScreen: View {
|
|||||||
.stroke(.compound.borderInteractivePrimary)
|
.stroke(.compound.borderInteractivePrimary)
|
||||||
}
|
}
|
||||||
|
|
||||||
Text(L10n.screenJoinRoomKnockMessageDescription)
|
Text(knockMessageFooterString)
|
||||||
.font(.compound.bodyMD)
|
.font(.compound.bodySM)
|
||||||
.foregroundStyle(.compound.textSecondary)
|
.foregroundStyle(.compound.textSecondary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:2347df221ddac84740cf5436620bb07bf3e7f24aea85e6dceec11f8d374a66d0
|
oid sha256:659cf8286eb523208e2fca0ba19578ff4b33a0076dea962fc3f133a089f5bca9
|
||||||
size 1817511
|
size 1816652
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:69ad1bad58cd73c5626fdf52923f6a0955221f5673b4485c131048d64b215c84
|
oid sha256:563f7440384e75819f985d659108c5e37bd8c5bca2ca79fbdb2c1ee0617ed17d
|
||||||
size 1825976
|
size 1824851
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:438018482d1792510fd3d07df8f9ba72ca7ddf3f1e69d7ab0b0adcdbe7a8b0f8
|
oid sha256:6f3d9a81bc16d26c4048e4bd59fefe56159a10f2a0f32139ee84ecef7f4d001f
|
||||||
size 729066
|
size 728704
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:03f9fedddcc22df3d14c21cb5314cdd8fdf17592032f57bb762b7c1fe1bbf5ca
|
oid sha256:6cbcee4066b91f8649d34a66b1b42dfd036541ed7eb7043bff6618089192ae1a
|
||||||
size 738216
|
size 736832
|
||||||
|
|||||||
Reference in New Issue
Block a user