Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ fun DesktopApp(
documentsGraphInjection = documentsGraphInjection,
editorInjector = editorInjector,
selectColorTheme = selectColorTheme,
navigationBar = {},
isMobile = false,
navController = navigationController
) {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.writeopia.mobile

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationBarItemDefaults
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -48,66 +46,64 @@ fun AppMobile(
val colorTheme by uiConfigViewModel.listenForColorTheme { "disconnected_user" }.collectAsState()

WrieopiaTheme(darkTheme = colorTheme.isDarkTheme()) {
Scaffold(
bottomBar = {
NavigationBar(
containerColor = MaterialTheme.colorScheme.primary,
modifier = Modifier
) {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
val navigationItems by navigationViewModel.selectedNavigation.collectAsState()
Box(modifier = Modifier) {
Navigation(
isDarkTheme = colorTheme.isDarkTheme(),
isMobile = true,
startDestination = startDestination,
notesMenuInjection = notesMenuInjection,
navController = navController,
editorInjector = editorInjector,
selectColorTheme = uiConfigViewModel::changeColorTheme,
searchInjection = searchInjector,
navigationBar = {
NavigationBar(
containerColor = MaterialTheme.colorScheme.primary,
modifier = Modifier
) {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
val navigationItems by navigationViewModel.selectedNavigation.collectAsState()

navigationItems.forEach { item ->
val isSelected =
currentDestination?.hierarchy?.any { destination ->
destination.route?.let {
NavItemName.selectRoute(it)
}?.value == item.navItemName.value
} ?: false
navigationItems.forEach { item ->
val isSelected =
currentDestination?.hierarchy?.any { destination ->
destination.route?.let {
NavItemName.selectRoute(it)
}?.value == item.navItemName.value
} ?: false

NavigationBarItem(
selected = isSelected,
icon = {
Icon(
imageVector = item.navItemName.iconForNavItem(),
contentDescription = item.navItemName.value
)
},
onClick = {
navController.navigateToItem(item.navItemName) {
if (!isSelected) {
popUpTo(navController.graph.findStartDestination().route!!) {
saveState = true
NavigationBarItem(
selected = isSelected,
icon = {
Icon(
imageVector = item.navItemName.iconForNavItem(),
contentDescription = item.navItemName.value
)
},
onClick = {
navController.navigateToItem(item.navItemName) {
if (!isSelected) {
popUpTo(navController.graph.findStartDestination().route!!) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
launchSingleTop = true
restoreState = true
}
}
},
colors = NavigationBarItemDefaults.colors()
.copy(
selectedIconColor = MaterialTheme.colorScheme.onSecondary,
unselectedIconColor = MaterialTheme.colorScheme.onPrimary,
selectedIndicatorColor = MaterialTheme.colorScheme.secondary,
)
)
},
colors = NavigationBarItemDefaults.colors()
.copy(
selectedIconColor = MaterialTheme.colorScheme.onSecondary,
unselectedIconColor = MaterialTheme.colorScheme.onPrimary,
selectedIndicatorColor = MaterialTheme.colorScheme.secondary,
)
)
}
}
}
}
) { padding ->
Box(modifier = Modifier.padding(padding)) {
Navigation(
isDarkTheme = colorTheme.isDarkTheme(),
startDestination = startDestination,
notesMenuInjection = notesMenuInjection,
navController = navController,
editorInjector = editorInjector,
selectColorTheme = uiConfigViewModel::changeColorTheme,
searchInjection = searchInjector,
builder = builder
)
}
},
builder = builder
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import io.writeopia.notemenu.navigation.notesMenuNavigation
@Composable
fun Navigation(
isDarkTheme: Boolean,
isMobile: Boolean,
startDestination: String,
navController: NavHostController = rememberNavController(),
notesMenuInjection: NotesMenuInjection,
Expand All @@ -39,6 +40,7 @@ fun Navigation(
editorInjector: TextEditorInjector,
searchInjection: SearchInjection? = null,
selectColorTheme: (ColorThemeOption) -> Unit,
navigationBar: @Composable () -> Unit,
builder: NavGraphBuilder.() -> Unit
) {
SharedTransitionLayout {
Expand All @@ -54,7 +56,8 @@ fun Navigation(
navigateToAccount = navController::navigateToAccount,
navigateToNewNote = navController::navigateToNewNote,
navigateToFolders = navController::navigateToFolder,
navigateToForceGraph = navController::navigateToForceGraph
navigateToForceGraph = navController::navigateToForceGraph,
navigationBar = navigationBar
)

if (documentsGraphInjection != null) {
Expand Down Expand Up @@ -85,6 +88,7 @@ fun Navigation(

if (searchInjection != null) {
searchNavigation(
isMobile = isMobile,
searchInjection,
navController::navigateToNote,
navController::navigateToFolder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package io.writeopia.account.navigation

import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.ui.Modifier
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import io.writeopia.account.di.AccountMenuKmpInjector
Expand All @@ -28,12 +31,15 @@ fun NavGraphBuilder.accountMenuNavigation(
) {
val accountMenuViewModel = AccountMenuKmpInjector.singleton().provideAccountMenuViewModel()

AccountMenuScreen(
accountMenuViewModel = accountMenuViewModel,
isLoggedInState = accountMenuViewModel.isLoggedIn,
onLogout = navigateToAuthMenu,
goToRegister = navigateToAuthMenu,
selectColorTheme = selectColorTheme
)
Scaffold { paddingValues ->
AccountMenuScreen(
modifier = Modifier.padding(paddingValues),
accountMenuViewModel = accountMenuViewModel,
isLoggedInState = accountMenuViewModel.isLoggedIn,
onLogout = navigateToAuthMenu,
goToRegister = navigateToAuthMenu,
selectColorTheme = selectColorTheme
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ fun AccountMenuScreen(
onLogout: () -> Unit,
goToRegister: () -> Unit,
selectColorTheme: (ColorThemeOption) -> Unit,
modifier: Modifier = Modifier,
) {
Column(modifier = Modifier.fillMaxSize().padding(16.dp)) {
Column(modifier = modifier.fillMaxSize().padding(16.dp)) {
Connect(accountMenuViewModel, isLoggedInState, onLogout, goToRegister)

Spacer(modifier = Modifier.height(16.dp))
Expand Down
1 change: 0 additions & 1 deletion application/features/editor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ kotlin {
val androidMain by getting {
dependencies {
// implementation("androidx.activity:activity-compose")
implementation(libs.accompanist.systemuicontroller)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
Expand All @@ -54,7 +53,6 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import io.writeopia.common.utils.colors.ColorUtils
import io.writeopia.common.utils.icons.WrIcons
import io.writeopia.editor.configuration.ui.HeaderEdition
Expand Down Expand Up @@ -83,18 +81,8 @@ internal fun NoteEditorScreen(
onDocumentLinkClick: (String) -> Unit,
modifier: Modifier = Modifier,
) {
val systemUiController = rememberSystemUiController()
val systemBarColor = MaterialTheme.colorScheme.background
val systemBarDefaultColor = MaterialTheme.colorScheme.primary

DisposableEffect(systemUiController) {
systemUiController.setStatusBarColor(color = systemBarColor)
onDispose {}
}

BackHandler {
noteEditorViewModel.handleBackAction(navigateBack = {
systemUiController.setStatusBarColor(color = systemBarDefaultColor)
navigateBack()
})
}
Expand Down Expand Up @@ -125,7 +113,6 @@ internal fun NoteEditorScreen(
titleState = noteEditorViewModel.currentTitle,
editableState = noteEditorViewModel.isEditable,
navigationClick = {
systemUiController.setStatusBarColor(color = systemBarDefaultColor)
noteEditorViewModel.handleBackAction(navigateBack = navigateBack)
},
shareDocument = noteEditorViewModel::onMoreOptionsClick
Expand Down
2 changes: 1 addition & 1 deletion application/features/global_shell/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ kotlin {
val androidMain by getting {
dependencies {
// implementation("androidx.activity:activity-compose")
implementation(libs.accompanist.systemuicontroller)
// implementation(libs.accompanist.systemuicontroller)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal fun ChooseNoteScreen(
newNote: () -> Unit,
navigateToAccount: () -> Unit,
navigateToNotes: (NotesNavigation) -> Unit,
navigationBar: @Composable () -> Unit,
modifier: Modifier = Modifier,
) {
val hasSelectedNotes by chooseNoteViewModel.hasSelectedNotes.collectAsState()
Expand All @@ -48,6 +49,7 @@ internal fun ChooseNoteScreen(
newNote = newNote,
navigateToAccount = navigateToAccount,
navigateToNotes = navigateToNotes,
navigationBar = navigationBar,
modifier = modifier,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ actual fun NotesMenuScreen(
navigateToFolders: (NotesNavigation) -> Unit,
addFolder: () -> Unit,
editFolder: (MenuItemUi.FolderUi) -> Unit,
navigationBar: @Composable () -> Unit,
modifier: Modifier
) {
ChooseNoteScreen(
Expand All @@ -41,6 +42,7 @@ actual fun NotesMenuScreen(
newNote = onNewNoteClick,
navigateToAccount = onAccountClick,
navigateToNotes = navigateToFolders,
navigationBar = navigationBar,
modifier = modifier,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.animation.SharedTransitionScope
import androidx.compose.foundation.background
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
Expand Down Expand Up @@ -39,6 +40,7 @@ fun NavGraphBuilder.notesMenuNavigation(
navigateToAccount: () -> Unit,
navigateToForceGraph: () -> Unit,
navigateToFolders: (NotesNavigation) -> Unit,
navigationBar: @Composable () -> Unit,
) {
composable(
route = NoteMenuDestiny.noteMenu(),
Expand Down Expand Up @@ -84,6 +86,7 @@ fun NavGraphBuilder.notesMenuNavigation(
addFolder = chooseNoteViewModel::addFolder,
editFolder = chooseNoteViewModel::editFolder,
onForceGraphSelected = navigateToForceGraph,
navigationBar = navigationBar,
modifier = Modifier.background(MaterialTheme.colorScheme.background)
)
}
Expand Down Expand Up @@ -111,6 +114,7 @@ fun NavGraphBuilder.notesMenuNavigation(
addFolder = chooseNoteViewModel::addFolder,
editFolder = chooseNoteViewModel::editFolder,
onForceGraphSelected = navigateToForceGraph,
navigationBar = navigationBar,
modifier = Modifier.background(MaterialTheme.colorScheme.background)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ internal fun MobileChooseNoteScreen(
newNote: () -> Unit,
navigateToAccount: () -> Unit,
navigateToNotes: (NotesNavigation) -> Unit,
navigationBar: @Composable () -> Unit,
modifier: Modifier = Modifier,
) {
LaunchedEffect(key1 = "refresh", block = {
Expand All @@ -80,7 +81,8 @@ internal fun MobileChooseNoteScreen(
},
floatingActionButton = {
FloatingActionButton(onClick = chooseNoteViewModel::showAddMenu)
}
},
bottomBar = navigationBar
) { paddingValues ->
DraggableScreen {
Content(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ expect fun NotesMenuScreen(
navigateToFolders: (NotesNavigation) -> Unit,
addFolder: () -> Unit,
editFolder: (MenuItemUi.FolderUi) -> Unit,
navigationBar: @Composable () -> Unit,
modifier: Modifier = Modifier,
)
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ actual fun NotesMenuScreen(
navigateToFolders: (NotesNavigation) -> Unit,
addFolder: () -> Unit,
editFolder: (MenuItemUi.FolderUi) -> Unit,
navigationBar: @Composable () -> Unit,
modifier: Modifier
) {
DesktopNotesMenu(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ actual fun NotesMenuScreen(
navigateToFolders: (NotesNavigation) -> Unit,
addFolder: () -> Unit,
editFolder: (MenuItemUi.FolderUi) -> Unit,
navigationBar: @Composable () -> Unit,
modifier: Modifier
) {
var onDropEvent by remember {
Expand Down
Loading