Skip to content

Commit 57df335

Browse files
committed
More cleanups
1 parent 165f491 commit 57df335

File tree

5 files changed

+18
-41
lines changed

5 files changed

+18
-41
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import androidx.compose.material3.Text
2828
import androidx.compose.material3.TopAppBarDefaults
2929
import androidx.compose.material3.TopAppBarScrollBehavior
3030
import androidx.compose.runtime.Composable
31+
import androidx.compose.runtime.LaunchedEffect
3132
import androidx.compose.runtime.getValue
3233
import androidx.compose.runtime.mutableStateOf
3334
import androidx.compose.runtime.remember
@@ -350,8 +351,9 @@ fun BaseManageGroupScreen(
350351
title: String,
351352
onBack: () -> Unit,
352353
enableCollapsingTopBarInLandscape: Boolean,
354+
collapseTopBar : Boolean = false,
353355
bottomBar: @Composable () -> Unit,
354-
content: @Composable (paddingValues: PaddingValues, scrollBehavior: TopAppBarScrollBehavior?) -> Unit,
356+
content: @Composable (paddingValues: PaddingValues) -> Unit,
355357
) {
356358
val isLandscape = getAdaptiveInfo().isLandscape
357359
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
@@ -362,6 +364,12 @@ fun BaseManageGroupScreen(
362364
else
363365
Modifier
364366

367+
LaunchedEffect(isLandscape, collapseTopBar) {
368+
if (isLandscape && collapseTopBar) {
369+
scrollBehavior.state.heightOffset = scrollBehavior.state.heightOffsetLimit
370+
}
371+
}
372+
365373
Scaffold(
366374
modifier = scaffoldModifier,
367375
topBar = {
@@ -374,7 +382,7 @@ fun BaseManageGroupScreen(
374382
bottomBar = bottomBar,
375383
contentWindowInsets = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal),
376384
) { paddingValues ->
377-
content(paddingValues, if (enableCollapsingTopBarInLandscape && isLandscape) scrollBehavior else null)
385+
content(paddingValues)
378386
}
379387
}
380388

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import androidx.compose.foundation.lazy.rememberLazyListState
1212
import androidx.compose.material3.ExperimentalMaterial3Api
1313
import androidx.compose.material3.Text
1414
import androidx.compose.runtime.Composable
15-
import androidx.compose.runtime.LaunchedEffect
1615
import androidx.compose.runtime.collectAsState
1716
import androidx.compose.ui.Alignment
1817
import androidx.compose.ui.Modifier
@@ -117,6 +116,7 @@ fun InviteContacts(
117116
title = stringResource(id = R.string.membersInvite),
118117
onBack = handleBack,
119118
enableCollapsingTopBarInLandscape = true,
119+
collapseTopBar = searchFocused,
120120
bottomBar = {
121121
CollapsibleFooterBottomBar(
122122
footer = CollapsibleFooterActionData(
@@ -129,13 +129,7 @@ fun InviteContacts(
129129
onClose = { sendCommand(CloseFooter) }
130130
)
131131
}
132-
) { paddingValues, scrollBehavior ->
133-
134-
LaunchedEffect(isLandscape, searchFocused) {
135-
if (isLandscape && searchFocused && scrollBehavior != null) {
136-
scrollBehavior.state.heightOffset = scrollBehavior.state.heightOffsetLimit
137-
}
138-
}
132+
) { paddingValues ->
139133

140134
Column(
141135
modifier = Modifier

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ import androidx.compose.foundation.lazy.LazyColumn
1717
import androidx.compose.foundation.lazy.items
1818
import androidx.compose.material3.ExperimentalMaterial3Api
1919
import androidx.compose.material3.Text
20-
import androidx.compose.material3.TopAppBarDefaults
2120
import androidx.compose.runtime.Composable
22-
import androidx.compose.runtime.LaunchedEffect
2321
import androidx.compose.runtime.collectAsState
2422
import androidx.compose.ui.Alignment
2523
import androidx.compose.ui.Modifier
2624
import androidx.compose.ui.graphics.RectangleShape
27-
import androidx.compose.ui.input.nestedscroll.nestedScroll
2825
import androidx.compose.ui.platform.LocalResources
2926
import androidx.compose.ui.res.stringResource
3027
import androidx.compose.ui.text.style.TextAlign
@@ -126,6 +123,7 @@ fun ManageAdmins(
126123
title = stringResource(id = R.string.manageAdmins),
127124
onBack = handleBack,
128125
enableCollapsingTopBarInLandscape = true,
126+
collapseTopBar = searchFocused,
129127
bottomBar = {
130128
CollapsibleFooterBottomBar(
131129
footer = CollapsibleFooterActionData(
@@ -138,13 +136,7 @@ fun ManageAdmins(
138136
onClose = { sendCommand(CloseFooter) }
139137
)
140138
}
141-
) { paddingValues, scrollBehavior ->
142-
143-
LaunchedEffect(isLandscape, searchFocused) {
144-
if (isLandscape && searchFocused && scrollBehavior != null) {
145-
scrollBehavior.state.heightOffset = scrollBehavior.state.heightOffsetLimit
146-
}
147-
}
139+
) { paddingValues ->
148140

149141
Column(
150142
modifier = Modifier

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import androidx.compose.foundation.lazy.LazyColumn
1616
import androidx.compose.foundation.lazy.items
1717
import androidx.compose.material3.ExperimentalMaterial3Api
1818
import androidx.compose.material3.Text
19-
import androidx.compose.material3.TopAppBarDefaults
2019
import androidx.compose.runtime.Composable
21-
import androidx.compose.runtime.LaunchedEffect
2220
import androidx.compose.runtime.collectAsState
2321
import androidx.compose.runtime.getValue
2422
import androidx.compose.runtime.mutableStateOf
@@ -27,7 +25,6 @@ import androidx.compose.runtime.setValue
2725
import androidx.compose.ui.Alignment
2826
import androidx.compose.ui.Modifier
2927
import androidx.compose.ui.graphics.RectangleShape
30-
import androidx.compose.ui.input.nestedscroll.nestedScroll
3128
import androidx.compose.ui.platform.LocalResources
3229
import androidx.compose.ui.res.stringResource
3330
import androidx.compose.ui.text.style.TextAlign
@@ -145,6 +142,7 @@ fun ManageMembers(
145142
title = stringResource(id = R.string.manageMembers),
146143
onBack = handleBack,
147144
enableCollapsingTopBarInLandscape = true,
145+
collapseTopBar = searchFocused,
148146
bottomBar = {
149147
CollapsibleFooterBottomBar(
150148
footer = CollapsibleFooterActionData(
@@ -157,14 +155,7 @@ fun ManageMembers(
157155
onClose = { sendCommand(CloseFooter) }
158156
)
159157
}
160-
) { paddingValues, scrollBehavior ->
161-
162-
LaunchedEffect(isLandscape, searchFocused) {
163-
if (isLandscape && searchFocused && scrollBehavior != null) {
164-
scrollBehavior.state.heightOffset = scrollBehavior.state.heightOffsetLimit
165-
}
166-
}
167-
158+
) { paddingValues ->
168159
Column(
169160
modifier = Modifier
170161
.padding(paddingValues)

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ import androidx.compose.foundation.lazy.LazyColumn
1515
import androidx.compose.foundation.lazy.items
1616
import androidx.compose.material3.ExperimentalMaterial3Api
1717
import androidx.compose.material3.Text
18-
import androidx.compose.material3.TopAppBarDefaults
1918
import androidx.compose.runtime.Composable
20-
import androidx.compose.runtime.LaunchedEffect
2119
import androidx.compose.runtime.collectAsState
2220
import androidx.compose.ui.Alignment
2321
import androidx.compose.ui.Modifier
24-
import androidx.compose.ui.input.nestedscroll.nestedScroll
2522
import androidx.compose.ui.platform.LocalResources
2623
import androidx.compose.ui.res.pluralStringResource
2724
import androidx.compose.ui.res.stringResource
@@ -115,6 +112,7 @@ fun PromoteMembers(
115112
title = pluralStringResource(id = R.plurals.promoteMember, 2),
116113
onBack = handleBack,
117114
enableCollapsingTopBarInLandscape = true,
115+
collapseTopBar = searchFocused,
118116
bottomBar = {
119117
CollapsibleFooterBottomBar(
120118
footer = CollapsibleFooterActionData(
@@ -134,13 +132,7 @@ fun PromoteMembers(
134132
onClose = { sendCommand(CloseFooter) }
135133
)
136134
}
137-
) { paddingValues, scrollBehavior ->
138-
139-
LaunchedEffect(isLandscape, searchFocused) {
140-
if (isLandscape && searchFocused && scrollBehavior != null) {
141-
scrollBehavior.state.heightOffset = scrollBehavior.state.heightOffsetLimit
142-
}
143-
}
135+
) { paddingValues ->
144136

145137
Column(
146138
modifier = Modifier

0 commit comments

Comments
 (0)