@@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.consumeWindowInsets
1111import androidx.compose.foundation.layout.fillMaxWidth
1212import androidx.compose.foundation.layout.height
1313import androidx.compose.foundation.layout.imePadding
14+ import androidx.compose.foundation.layout.navigationBars
1415import androidx.compose.foundation.layout.only
1516import androidx.compose.foundation.layout.padding
1617import androidx.compose.foundation.layout.safeDrawing
@@ -20,10 +21,13 @@ import androidx.compose.foundation.lazy.rememberLazyListState
2021import androidx.compose.material3.ExperimentalMaterial3Api
2122import androidx.compose.material3.Scaffold
2223import androidx.compose.material3.Text
24+ import androidx.compose.material3.TopAppBarDefaults
2325import androidx.compose.runtime.Composable
26+ import androidx.compose.runtime.LaunchedEffect
2427import androidx.compose.runtime.collectAsState
2528import androidx.compose.ui.Alignment
2629import androidx.compose.ui.Modifier
30+ import androidx.compose.ui.input.nestedscroll.nestedScroll
2731import androidx.compose.ui.platform.LocalResources
2832import androidx.compose.ui.res.stringResource
2933import androidx.compose.ui.text.style.TextAlign
@@ -44,6 +48,7 @@ import org.thoughtcrime.securesms.ui.CollapsibleFooterActionData
4448import org.thoughtcrime.securesms.ui.CollapsibleFooterItemData
4549import org.thoughtcrime.securesms.ui.GetString
4650import org.thoughtcrime.securesms.ui.SearchBarWithClose
51+ import org.thoughtcrime.securesms.ui.adaptive.getAdaptiveInfo
4752import org.thoughtcrime.securesms.ui.components.BackAppBar
4853import org.thoughtcrime.securesms.ui.qaTag
4954import 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