@@ -2,11 +2,10 @@ package com.bff.wespot.message.screen.send
2
2
3
3
import androidx.compose.foundation.clickable
4
4
import androidx.compose.foundation.layout.Arrangement
5
- import androidx.compose.foundation.layout.Box
6
5
import androidx.compose.foundation.layout.Column
6
+ import androidx.compose.foundation.layout.PaddingValues
7
7
import androidx.compose.foundation.layout.Row
8
8
import androidx.compose.foundation.layout.Spacer
9
- import androidx.compose.foundation.layout.fillMaxSize
10
9
import androidx.compose.foundation.layout.fillMaxWidth
11
10
import androidx.compose.foundation.layout.padding
12
11
import androidx.compose.material3.ExperimentalMaterial3Api
@@ -21,6 +20,7 @@ import androidx.compose.runtime.setValue
21
20
import androidx.compose.ui.Alignment
22
21
import androidx.compose.ui.Modifier
23
22
import androidx.compose.ui.focus.FocusRequester
23
+ import androidx.compose.ui.layout.SubcomposeLayout
24
24
import androidx.compose.ui.platform.LocalContext
25
25
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
26
26
import androidx.compose.ui.res.stringResource
@@ -96,79 +96,92 @@ fun MessageWriteScreen(
96
96
)
97
97
},
98
98
) {
99
- Column (
99
+ SubcomposeLayout (
100
100
modifier = Modifier
101
101
.padding(it)
102
102
.padding(horizontal = 20 .dp),
103
- ) {
104
- Text (
105
- modifier = Modifier
106
- .fillMaxWidth()
107
- .padding(horizontal = 3 .dp),
108
- text = stringResource(R .string.message_write_title),
109
- style = StaticTypeScale .Default .header1,
110
- color = WeSpotThemeManager .colors.txtTitleColor,
111
- )
103
+ ) { constraints ->
104
+ val buttonPlaceable = subcompose(" button" ) {
105
+ WSButton (
106
+ onClick = {
107
+ if (state.isReservedMessage) {
108
+ navigator.navigateUp()
109
+ } else {
110
+ navigator.navigateMessageEditScreen(EditMessageScreenArgs ())
111
+ }
112
+ },
113
+ paddingValues = PaddingValues (0 .dp),
114
+ enabled = state.messageInput.length in 1 .. MESSAGE_MAX_LENGTH && state.hasProfanity.not (),
115
+ text = stringResource(
116
+ if (navArgs.isEditing) R .string.edit_done else R .string.write_done,
117
+ ),
118
+ content = { it() },
119
+ )
120
+ }.first().measure(constraints)
112
121
113
- Spacer (modifier = Modifier .padding(top = 16 .dp))
122
+ val contentMaxHeight = constraints.maxHeight - buttonPlaceable.height
123
+ val contentPlaceable = subcompose(" content" ) {
124
+ Column {
125
+ Text (
126
+ modifier = Modifier
127
+ .fillMaxWidth()
128
+ .padding(horizontal = 3 .dp),
129
+ text = stringResource(R .string.message_write_title),
130
+ style = StaticTypeScale .Default .header1,
131
+ color = WeSpotThemeManager .colors.txtTitleColor,
132
+ )
114
133
115
- WsTextField (
116
- value = state.messageInput,
117
- onValueChange = { text ->
118
- action(SendAction .OnMessageChanged (text))
119
- },
120
- placeholder = stringResource(R .string.message_write_text_holder),
121
- isError = false ,
122
- focusRequester = focusRequester,
123
- textFieldType = WsTextFieldType .Message ,
124
- )
134
+ Spacer (modifier = Modifier .padding(top = 16 .dp))
135
+
136
+ WsTextField (
137
+ value = state.messageInput,
138
+ onValueChange = { text ->
139
+ action(SendAction .OnMessageChanged (text))
140
+ },
141
+ placeholder = stringResource(R .string.message_write_text_holder),
142
+ isError = false ,
143
+ focusRequester = focusRequester,
144
+ textFieldType = WsTextFieldType .Message ,
145
+ )
125
146
126
- Row (
127
- modifier = Modifier .fillMaxWidth(),
128
- verticalAlignment = Alignment .CenterVertically ,
129
- horizontalArrangement = Arrangement .SpaceBetween ,
130
- ) {
131
- val warningMessage = when {
132
- state.messageInput.length > MESSAGE_MAX_LENGTH -> {
133
- stringResource(R .string.message_length_limit)
147
+ Row (
148
+ modifier = Modifier .fillMaxWidth(),
149
+ verticalAlignment = Alignment .CenterVertically ,
150
+ horizontalArrangement = Arrangement .SpaceBetween ,
151
+ ) {
152
+ val warningMessage = when {
153
+ state.messageInput.length > MESSAGE_MAX_LENGTH -> {
154
+ stringResource(R .string.message_length_limit)
155
+ }
156
+
157
+ state.hasProfanity -> {
158
+ stringResource(com.bff.wespot.designsystem.R .string.has_profanity)
159
+ }
160
+ else -> " "
161
+ }
162
+
163
+ Text (
164
+ modifier = Modifier .padding(top = 5 .dp, start = 10 .dp, end = 10 .dp),
165
+ text = warningMessage,
166
+ style = StaticTypeScale .Default .body7,
167
+ color = WeSpotThemeManager .colors.dangerColor,
168
+ )
169
+
170
+ LetterCountIndicator (currentCount = state.messageInput.length, maxCount = 200 )
134
171
}
135
172
136
- state.hasProfanity -> {
137
- stringResource(com.bff.wespot.designsystem.R .string.has_profanity)
138
- }
139
- else -> " "
173
+ Spacer (modifier = Modifier .weight(1f ))
140
174
}
175
+ }.first().measure(constraints.copy(maxHeight = contentMaxHeight))
141
176
142
- Text (
143
- modifier = Modifier .padding(top = 5 .dp, start = 10 .dp, end = 10 .dp),
144
- text = warningMessage,
145
- style = StaticTypeScale .Default .body7,
146
- color = WeSpotThemeManager .colors.dangerColor,
147
- )
177
+ layout(constraints.maxWidth, constraints.maxHeight) {
178
+ contentPlaceable.placeRelative(0 , 0 )
148
179
149
- LetterCountIndicator (currentCount = state.messageInput.length, maxCount = 200 )
180
+ buttonPlaceable.placeRelative( 0 , contentMaxHeight )
150
181
}
151
182
}
152
183
}
153
184
154
- Box (modifier = Modifier .fillMaxSize(), contentAlignment = Alignment .BottomCenter ) {
155
- WSButton (
156
- onClick = {
157
- if (state.isReservedMessage) {
158
- navigator.navigateUp()
159
- } else {
160
- navigator.navigateMessageEditScreen(EditMessageScreenArgs ())
161
- }
162
- },
163
- enabled = state.messageInput.length in 1 .. MESSAGE_MAX_LENGTH && state.hasProfanity.not (),
164
- text = stringResource(
165
- if (navArgs.isEditing) R .string.edit_done else R .string.write_done,
166
- ),
167
- ) {
168
- it()
169
- }
170
- }
171
-
172
185
if (dialogState) {
173
186
SendExitDialog (
174
187
isReservedMessage = state.isReservedMessage,
0 commit comments