Skip to content

Commit 3a2ea1b

Browse files
committed
Updated landscape screen for manage group stuff
1 parent 0f0d655 commit 3a2ea1b

File tree

5 files changed

+339
-188
lines changed

5 files changed

+339
-188
lines changed

app/src/main/java/org/thoughtcrime/securesms/groups/compose/Components.kt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import androidx.compose.foundation.layout.Arrangement
66
import androidx.compose.foundation.layout.Column
77
import androidx.compose.foundation.layout.Row
88
import androidx.compose.foundation.layout.RowScope
9+
import androidx.compose.foundation.layout.Spacer
910
import androidx.compose.foundation.layout.fillMaxWidth
11+
import androidx.compose.foundation.layout.height
1012
import androidx.compose.foundation.layout.padding
1113
import androidx.compose.foundation.lazy.LazyColumn
1214
import androidx.compose.foundation.lazy.LazyListScope
@@ -33,6 +35,7 @@ import org.thoughtcrime.securesms.ui.DialogButtonData
3335
import org.thoughtcrime.securesms.ui.GetString
3436
import org.thoughtcrime.securesms.ui.ProBadgeText
3537
import org.thoughtcrime.securesms.ui.RadioOption
38+
import org.thoughtcrime.securesms.ui.SearchBarWithClose
3639
import org.thoughtcrime.securesms.ui.components.Avatar
3740
import org.thoughtcrime.securesms.ui.components.DialogTitledRadioButton
3841
import org.thoughtcrime.securesms.ui.components.RadioButtonIndicator
@@ -268,6 +271,37 @@ fun ManageMemberItem(
268271
)
269272
}
270273

274+
@Composable
275+
fun MembersSearchHeader(
276+
searchFocused: Boolean,
277+
searchQuery: String,
278+
onQueryChange: (String) -> Unit,
279+
onClear: () -> Unit,
280+
onFocusChanged: (Boolean) -> Unit,
281+
modifier: Modifier = Modifier,
282+
enabled: Boolean = true,
283+
placeholder: String = LocalResources.current.getString(R.string.search)
284+
) {
285+
Column(
286+
modifier = modifier
287+
.fillMaxWidth()
288+
// important for stickyHeader so rows don't show through
289+
.background(LocalColors.current.background)
290+
.padding(vertical = LocalDimensions.current.smallSpacing)
291+
) {
292+
SearchBarWithClose(
293+
query = searchQuery,
294+
onValueChanged = onQueryChange,
295+
onClear = onClear,
296+
placeholder = if (searchFocused) "" else placeholder,
297+
enabled = enabled,
298+
isFocused = searchFocused,
299+
modifier = Modifier.padding(horizontal = LocalDimensions.current.smallSpacing),
300+
onFocusChanged = onFocusChanged
301+
)
302+
}
303+
}
304+
271305
@Preview
272306
@Composable
273307
fun PreviewMemberList() {

app/src/main/java/org/thoughtcrime/securesms/groups/compose/InviteContactsScreen.kt

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.consumeWindowInsets
1111
import androidx.compose.foundation.layout.fillMaxWidth
1212
import androidx.compose.foundation.layout.height
1313
import androidx.compose.foundation.layout.imePadding
14+
import androidx.compose.foundation.layout.navigationBars
1415
import androidx.compose.foundation.layout.only
1516
import androidx.compose.foundation.layout.padding
1617
import androidx.compose.foundation.layout.safeDrawing
@@ -20,10 +21,13 @@ import androidx.compose.foundation.lazy.rememberLazyListState
2021
import androidx.compose.material3.ExperimentalMaterial3Api
2122
import androidx.compose.material3.Scaffold
2223
import androidx.compose.material3.Text
24+
import androidx.compose.material3.TopAppBarDefaults
2325
import androidx.compose.runtime.Composable
26+
import androidx.compose.runtime.LaunchedEffect
2427
import androidx.compose.runtime.collectAsState
2528
import androidx.compose.ui.Alignment
2629
import androidx.compose.ui.Modifier
30+
import androidx.compose.ui.input.nestedscroll.nestedScroll
2731
import androidx.compose.ui.platform.LocalResources
2832
import androidx.compose.ui.res.stringResource
2933
import androidx.compose.ui.text.style.TextAlign
@@ -44,6 +48,7 @@ import org.thoughtcrime.securesms.ui.CollapsibleFooterActionData
4448
import org.thoughtcrime.securesms.ui.CollapsibleFooterItemData
4549
import org.thoughtcrime.securesms.ui.GetString
4650
import org.thoughtcrime.securesms.ui.SearchBarWithClose
51+
import org.thoughtcrime.securesms.ui.adaptive.getAdaptiveInfo
4752
import org.thoughtcrime.securesms.ui.components.BackAppBar
4853
import org.thoughtcrime.securesms.ui.qaTag
4954
import org.thoughtcrime.securesms.ui.theme.LocalColors
@@ -87,6 +92,10 @@ fun InviteContacts(
8792
forCommunity: Boolean = false
8893
) {
8994

95+
val searchFocused = uiState.isSearchFocused
96+
val isLandscape = getAdaptiveInfo().isLandscape
97+
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
98+
9099
val trayItems = listOf(
91100
CollapsibleFooterItemData(
92101
label = GetString(LocalResources.current.getString(R.string.membersInvite)),
@@ -101,27 +110,51 @@ fun InviteContacts(
101110

102111
val handleBack: () -> Unit = {
103112
when {
104-
uiState.isSearchFocused -> sendCommand(RemoveSearchState(false))
113+
searchFocused -> sendCommand(RemoveSearchState(false))
105114
else -> onBack()
106115
}
107116
}
108117

118+
val header: @Composable (Modifier) -> Unit = { modifier ->
119+
MembersSearchHeader(
120+
searchFocused = searchFocused,
121+
searchQuery = searchQuery,
122+
onQueryChange = { sendCommand(SearchQueryChange(it)) },
123+
onClear = { sendCommand(SearchQueryChange("")) },
124+
onFocusChanged = { sendCommand(SearchFocusChange(it)) },
125+
modifier = modifier
126+
)
127+
}
128+
129+
109130
// Intercept system back
110131
BackHandler(enabled = true) { handleBack() }
111132

133+
LaunchedEffect(isLandscape, searchFocused) {
134+
if (isLandscape && searchFocused) {
135+
scrollBehavior.state.heightOffset = scrollBehavior.state.heightOffsetLimit
136+
}
137+
}
138+
112139
Scaffold(
113-
contentWindowInsets = WindowInsets.safeDrawing,
140+
modifier = if (isLandscape) {
141+
Modifier.nestedScroll(scrollBehavior.nestedScrollConnection)
142+
} else {
143+
Modifier
144+
},
114145
topBar = {
115146
BackAppBar(
116147
title = stringResource(id = R.string.membersInvite),
117148
onBack = handleBack,
149+
scrollBehavior = if (isLandscape) scrollBehavior else null
118150
)
119151
},
120152
bottomBar = {
121153
Box(
122154
modifier = Modifier
123155
.fillMaxWidth()
124-
.windowInsetsPadding(WindowInsets.safeDrawing)
156+
.windowInsetsPadding(WindowInsets.navigationBars.only(WindowInsetsSides.Bottom))
157+
.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal))
125158
.imePadding()
126159
) {
127160
CollapsibleFooterAction(
@@ -135,33 +168,21 @@ fun InviteContacts(
135168
onClosedClicked = { sendCommand(CloseFooter) }
136169
)
137170
}
138-
}
171+
},
172+
contentWindowInsets = WindowInsets.safeDrawing,
139173
) { paddings ->
140174
Column(
141175
modifier = Modifier
142176
.padding(paddings)
143177
.consumeWindowInsets(paddings),
144178
) {
145-
Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing))
146179

147-
SearchBarWithClose(
148-
query = searchQuery,
149-
onValueChanged = { query -> sendCommand(SearchQueryChange(query)) },
150-
onClear = { sendCommand(SearchQueryChange("")) },
151-
placeholder = stringResource(R.string.searchContacts),
152-
modifier = Modifier
153-
.padding(horizontal = LocalDimensions.current.smallSpacing)
154-
.qaTag(R.string.AccessibilityId_groupNameSearch),
155-
backgroundColor = LocalColors.current.backgroundSecondary,
156-
isFocused = uiState.isSearchFocused,
157-
onFocusChanged = { isFocused -> sendCommand(SearchFocusChange(isFocused)) },
158-
enabled = true,
159-
)
180+
if (!isLandscape) {
181+
header(Modifier)
182+
}
160183

161184
val scrollState = rememberLazyListState()
162185

163-
Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing))
164-
165186
Box(
166187
modifier = Modifier
167188
.weight(1f)
@@ -179,7 +200,13 @@ fun InviteContacts(
179200
LazyColumn(
180201
state = scrollState,
181202
contentPadding = PaddingValues(bottom = LocalDimensions.current.spacing),
203+
modifier = Modifier
204+
.then(if (isLandscape) Modifier.nestedScroll(scrollBehavior.nestedScrollConnection) else Modifier)
182205
) {
206+
if (isLandscape) {
207+
stickyHeader { header(Modifier) }
208+
}
209+
183210
multiSelectMemberList(
184211
contacts = contacts,
185212
onContactItemClicked = { address -> sendCommand(ContactItemClick(address)) },

0 commit comments

Comments
 (0)