Skip to content

Commit 12cc707

Browse files
committed
allow for more compact design
1 parent 9cdcc1f commit 12cc707

File tree

17 files changed

+219
-101
lines changed

17 files changed

+219
-101
lines changed

app/src/main/java/com/raival/compose/file/explorer/screen/main/MainActivity.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ class MainActivity : BaseActivity() {
129129
}
130130

131131
Column(Modifier.fillMaxSize()) {
132-
Toolbar(
133-
title = mainActivityState.title,
134-
subtitle = mainActivityState.subtitle,
135-
hasNewUpdate = mainActivityState.hasNewUpdate,
136-
onToggleAppInfoDialog = { mainActivityManager.toggleAppInfoDialog(it) }
137-
)
132+
if (!globalClass.preferencesManager.hideToolbar) {
133+
Toolbar(
134+
title = mainActivityState.title,
135+
subtitle = mainActivityState.subtitle,
136+
hasNewUpdate = mainActivityState.hasNewUpdate,
137+
onToggleAppInfoDialog = { mainActivityManager.toggleAppInfoDialog(it) }
138+
)
139+
}
138140
TabLayout(
139141
tabLayoutState = mainActivityState.tabLayoutState,
140142
tabs = mainActivityState.tabs,
@@ -179,9 +181,7 @@ class MainActivity : BaseActivity() {
179181
if (page isNot state.selectedTabIndex) {
180182
manager.selectTabAt(page, true)
181183
}
182-
state.tabLayoutState.animateScrollToItem(
183-
state.selectedTabIndex
184-
)
184+
state.tabLayoutState.animateScrollToItem(page)
185185
}
186186
}
187187

app/src/main/java/com/raival/compose/file/explorer/screen/main/tab/files/FilesTab.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class FilesTab(
193193
}
194194
}
195195

196-
if (filesCount > 0 && foldersCount > 0) append(" | ")
196+
if (filesCount > 0 && foldersCount > 0) append(", ")
197197

198198
if (filesCount > 0) {
199199
append(activeFolder.getFormattedFileCount(filesCount, 0))

app/src/main/java/com/raival/compose/file/explorer/screen/main/tab/files/holder/VirtualFileHolder.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@ class VirtualFileHolder(val type: Int) : ContentHolder() {
6565
clear()
6666
addAll(it)
6767
}
68-
fileCount = it.size
69-
7068
if (type != BOOKMARKS) fetchCategories()
7169
}
7270
} else contentList).filter {
7371
if (selectedCategory == null) return@filter true
7472
it.uniquePath == (selectedCategory!!.data as File).path + File.separator + it.displayName
75-
}.toCollection(arrayListOf())
73+
}.toCollection(arrayListOf()).also { fileCount = it.size }
7674

7775
private fun fetchCategories() {
7876
categories.clear()

app/src/main/java/com/raival/compose/file/explorer/screen/main/tab/files/ui/FilesTabContentView.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import com.raival.compose.file.explorer.screen.main.tab.files.ui.dialog.TaskRunn
2828
fun ColumnScope.FilesTabContentView(tab: FilesTab) {
2929
Dialogs(tab)
3030
PathHistoryRow(tab)
31+
InfoRow()
3132
HorizontalDivider(modifier = Modifier, thickness = 1.dp)
3233
FilesList(tab)
3334
BottomOptionsBar(tab)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.raival.compose.file.explorer.screen.main.tab.files.ui
2+
3+
import androidx.compose.foundation.layout.Row
4+
import androidx.compose.foundation.layout.fillMaxWidth
5+
import androidx.compose.foundation.layout.padding
6+
import androidx.compose.material3.HorizontalDivider
7+
import androidx.compose.material3.Text
8+
import androidx.compose.runtime.Composable
9+
import androidx.compose.runtime.collectAsState
10+
import androidx.compose.runtime.getValue
11+
import androidx.compose.ui.Modifier
12+
import androidx.compose.ui.draw.alpha
13+
import androidx.compose.ui.unit.dp
14+
import androidx.compose.ui.unit.sp
15+
import com.raival.compose.file.explorer.App.Companion.globalClass
16+
17+
@Composable
18+
fun InfoRow() {
19+
if (globalClass.preferencesManager.hideToolbar) {
20+
val state by globalClass.mainActivityManager.state.collectAsState()
21+
HorizontalDivider(modifier = Modifier, thickness = 1.dp)
22+
Row(modifier = Modifier
23+
.fillMaxWidth()
24+
.padding(horizontal = 16.dp, vertical = 2.dp)) {
25+
Text(
26+
text = state.subtitle,
27+
modifier = Modifier
28+
.weight(1f)
29+
.alpha(0.9f),
30+
maxLines = 1,
31+
fontSize = 12.sp
32+
)
33+
}
34+
}
35+
}

app/src/main/java/com/raival/compose/file/explorer/screen/main/ui/TabLayout.kt

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import androidx.compose.foundation.layout.Arrangement
99
import androidx.compose.foundation.layout.Row
1010
import androidx.compose.foundation.layout.defaultMinSize
1111
import androidx.compose.foundation.layout.fillMaxHeight
12-
import androidx.compose.foundation.layout.fillMaxSize
1312
import androidx.compose.foundation.layout.fillMaxWidth
1413
import androidx.compose.foundation.layout.height
14+
import androidx.compose.foundation.layout.heightIn
1515
import androidx.compose.foundation.layout.padding
1616
import androidx.compose.foundation.lazy.LazyListState
1717
import androidx.compose.foundation.lazy.LazyRow
@@ -48,6 +48,7 @@ import com.raival.compose.file.explorer.common.fromJson
4848
import com.raival.compose.file.explorer.common.isNot
4949
import com.raival.compose.file.explorer.common.showMsg
5050
import com.raival.compose.file.explorer.common.toJson
51+
import com.raival.compose.file.explorer.common.ui.Space
5152
import com.raival.compose.file.explorer.screen.main.startup.StartupTab
5253
import com.raival.compose.file.explorer.screen.main.startup.StartupTabType
5354
import com.raival.compose.file.explorer.screen.main.startup.StartupTabs
@@ -68,9 +69,11 @@ fun TabLayout(
6869
onAddNewTab: () -> Unit
6970
) {
7071
val selectedTabBackgroundColor = MaterialTheme.colorScheme.surfaceContainerLowest
71-
val unselectedTabBackgroundColor = MaterialTheme.colorScheme.surfaceContainerLow
72+
val unselectedTabBackgroundColor =
73+
MaterialTheme.colorScheme.surfaceContainerLowest.copy(alpha = 0.5f)
7274
val draggedTabBackgroundColor = MaterialTheme.colorScheme.primary
7375
val draggedTabTextColor = MaterialTheme.colorScheme.surfaceContainerLowest
76+
val hideToolbar = globalClass.preferencesManager.hideToolbar
7477

7578
val mainActivityManager = globalClass.mainActivityManager
7679

@@ -104,20 +107,29 @@ fun TabLayout(
104107
Row(
105108
Modifier
106109
.fillMaxWidth()
107-
.height(42.dp)
108-
.background(color = MaterialTheme.colorScheme.surfaceContainer)
110+
.height(if (hideToolbar) 50.dp else 42.dp)
111+
.background(color = MaterialTheme.colorScheme.surfaceContainer),
112+
verticalAlignment = Alignment.Bottom
109113
) {
110-
IconButton(
111-
onClick = onAddNewTab
112-
) {
113-
Icon(imageVector = Icons.Rounded.Add, contentDescription = null)
114+
if (!hideToolbar) {
115+
IconButton(
116+
onClick = onAddNewTab
117+
) {
118+
Icon(imageVector = Icons.Rounded.Add, contentDescription = null)
119+
}
114120
}
115-
116121
LazyRow(
117-
modifier = Modifier.fillMaxSize(),
122+
modifier = Modifier
123+
.weight(1f)
124+
.heightIn(max = 42.dp),
118125
state = tabLayoutState,
119126
verticalAlignment = Alignment.CenterVertically
120127
) {
128+
if (hideToolbar) {
129+
item {
130+
Space(8.dp)
131+
}
132+
}
121133
itemsIndexed(list, key = { _, item -> item }) { index, id ->
122134
tabs.find { it.id == id }?.let { tab ->
123135
ReorderableItem(reorderableLazyListState, key = tab.id) { isDragged ->
@@ -201,6 +213,14 @@ fun TabLayout(
201213
}
202214
}
203215
}
216+
if (globalClass.preferencesManager.hideToolbar) {
217+
IconButton(
218+
onClick = onAddNewTab
219+
) {
220+
Icon(imageVector = Icons.Rounded.Add, contentDescription = null)
221+
}
222+
MoreOptionsButton()
223+
}
204224
}
205225
}
206226

0 commit comments

Comments
 (0)