From b980784b1f9673882c1d4bc71e5a45cb00895d9d Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Mon, 4 Apr 2022 02:58:51 +0200 Subject: [PATCH] Changed secondary color & reorganized welcome/home screen --- src/main/kotlin/app/theme/Color.kt | 4 +- src/main/kotlin/app/ui/WelcomePage.kt | 248 ++++++++++++++------------ 2 files changed, 140 insertions(+), 112 deletions(-) diff --git a/src/main/kotlin/app/theme/Color.kt b/src/main/kotlin/app/theme/Color.kt index 51fef48..086fb13 100644 --- a/src/main/kotlin/app/theme/Color.kt +++ b/src/main/kotlin/app/theme/Color.kt @@ -6,7 +6,7 @@ val primaryLight = Color(0xFF9FD1FF) val primary = Color(0xFF0070D8) val primaryDark = Color(0xFF014F97) val onPrimary = Color(0xFFFFFFFFF) -val secondary = Color(0xFFAB02E9) +val secondary = Color(0xFFe9c754) val mainText = Color(0xFF212934) val mainTextDark = Color(0xFFFFFFFF) val secondaryText = Color(0xFF595858) @@ -33,4 +33,4 @@ val dialogBackgroundColor = Color(0xAA000000) val unhoverScrollbarColorLight = Color.LightGray val unhoverScrollbarColorDark = Color.Gray val hoverScrollbarColorLight = primary -val hoverScrollbarColorDark = Color.LightGray +val hoverScrollbarColorDark = Color.LightGray \ No newline at end of file diff --git a/src/main/kotlin/app/ui/WelcomePage.kt b/src/main/kotlin/app/ui/WelcomePage.kt index 133ca74..45644af 100644 --- a/src/main/kotlin/app/ui/WelcomePage.kt +++ b/src/main/kotlin/app/ui/WelcomePage.kt @@ -20,6 +20,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import app.AppConstants +import app.AppStateManager import app.extensions.dirName import app.extensions.dirPath import app.theme.primaryTextColor @@ -60,118 +61,15 @@ fun WelcomePage( verticalAlignment = Alignment.Top, modifier = Modifier.align(BiasAlignment(0f, -0.5f)) ) { - Column( - modifier = Modifier.padding(end = 32.dp), - ) { - Text( - text = "Gitnuro", - fontSize = 32.sp, - color = MaterialTheme.colors.primaryTextColor, - modifier = Modifier.padding(bottom = 16.dp), - ) - - ButtonTile( - modifier = Modifier.padding(bottom = 8.dp), - title = "Open a repository", - painter = painterResource("open.svg"), - onClick = { openRepositoryDialog(tabViewModel) }) - - ButtonTile( - modifier = Modifier.padding(bottom = 8.dp), - title = "Clone a repository", - painter = painterResource("download.svg"), - onClick = { - showCloneView = true - } - ) - - ButtonTile( - modifier = Modifier.padding(bottom = 8.dp), - title = "Start a local repository", - painter = painterResource("open.svg"), - onClick = { - val dir = openDirectoryDialog() - if (dir != null) tabViewModel.initLocalRepository(dir) - } - ) - - Text( - text = "About Gitnuro", - fontSize = 18.sp, - color = MaterialTheme.colors.primaryTextColor, - modifier = Modifier.padding(top = 16.dp, bottom = 8.dp), - ) - - IconTextButton( - title = "Source code", - painter = painterResource("code.svg"), - onClick = { - Desktop.getDesktop().browse(URI("https://github.com/JetpackDuba/Gitnuro")) - } - ) - - IconTextButton( - title = "Report a bug", - painter = painterResource("bug.svg"), - onClick = { - Desktop.getDesktop().browse(URI("https://github.com/JetpackDuba/Gitnuro/issues")) - } - ) - - if(newUpdate != null) { - IconTextButton( - title = "New update ${newUpdate?.appVersion} available ", - painter = painterResource("grade.svg"), - iconColor = MaterialTheme.colors.secondary, - onClick = { - newUpdate?.downloadUrl?.let { - Desktop.getDesktop().browse(URI(it)) - } - } - ) + HomeButtons( + newUpdate = newUpdate, + tabViewModel = tabViewModel, + onShowCloneView = { + showCloneView = true } - } + ) - Column( - modifier = Modifier - .padding(start = 32.dp), - ) { - Text( - text = "Recent", - fontSize = 18.sp, - modifier = Modifier.padding(top = 48.dp, bottom = 8.dp), - color = MaterialTheme.colors.primaryTextColor, - ) - LazyColumn { - items(items = appStateManager.latestOpenedRepositoriesPaths) { repo -> - val repoDirName = repo.dirName - val repoDirPath = repo.dirPath - - Row( - verticalAlignment = Alignment.CenterVertically, - ) { - TextButton( - onClick = { - tabViewModel.openRepository(repo) - } - ) { - Text( - text = repoDirName, - fontSize = 14.sp, - color = MaterialTheme.colors.primary, - ) - } - - Text( - text = repoDirPath, - fontSize = 14.sp, - modifier = Modifier.padding(start = 4.dp), - color = MaterialTheme.colors.secondaryTextColor - ) - } - } - } - } + RecentRepositories(appStateManager, tabViewModel) } Text( @@ -201,6 +99,136 @@ fun WelcomePage( ) } +@Composable +fun HomeButtons( + newUpdate: Update?, + tabViewModel: TabViewModel, + onShowCloneView: () -> Unit, +) { + Column( + modifier = Modifier.padding(end = 32.dp), + ) { + Text( + text = "Gitnuro", + fontSize = 32.sp, + color = MaterialTheme.colors.primaryTextColor, + modifier = Modifier.padding(bottom = 16.dp), + ) + + ButtonTile( + modifier = Modifier.padding(bottom = 8.dp), + title = "Open a repository", + painter = painterResource("open.svg"), + onClick = { openRepositoryDialog(tabViewModel) }) + + ButtonTile( + modifier = Modifier.padding(bottom = 8.dp), + title = "Clone a repository", + painter = painterResource("download.svg"), + onClick = onShowCloneView + ) + + ButtonTile( + modifier = Modifier.padding(bottom = 8.dp), + title = "Start a local repository", + painter = painterResource("open.svg"), + onClick = { + val dir = openDirectoryDialog() + if (dir != null) tabViewModel.initLocalRepository(dir) + } + ) + + Text( + text = "About Gitnuro", + fontSize = 18.sp, + color = MaterialTheme.colors.primaryTextColor, + modifier = Modifier.padding(top = 16.dp, bottom = 8.dp), + ) + + IconTextButton( + title = "Source code", + painter = painterResource("code.svg"), + onClick = { + Desktop.getDesktop().browse(URI("https://github.com/JetpackDuba/Gitnuro")) + } + ) + + IconTextButton( + title = "Report a bug", + painter = painterResource("bug.svg"), + onClick = { + Desktop.getDesktop().browse(URI("https://github.com/JetpackDuba/Gitnuro/issues")) + } + ) + + if(newUpdate != null) { + IconTextButton( + title = "New update ${newUpdate.appVersion} available ", + painter = painterResource("grade.svg"), + iconColor = MaterialTheme.colors.secondary, + onClick = { + Desktop.getDesktop().browse(URI(newUpdate.downloadUrl)) + } + ) + } + } +} + +@Composable +fun RecentRepositories(appStateManager: AppStateManager, tabViewModel: TabViewModel) { + Column( + modifier = Modifier + .padding(start = 32.dp), + ) { + val latestOpenedRepositoriesPaths = appStateManager.latestOpenedRepositoriesPaths + Text( + text = "Recent", + fontSize = 18.sp, + modifier = Modifier.padding(top = 48.dp, bottom = 8.dp), + color = MaterialTheme.colors.primaryTextColor, + ) + + if(latestOpenedRepositoriesPaths.isEmpty()) { + Text( + "Nothing to see here, open a repository first!", + color = MaterialTheme.colors.secondaryTextColor, + fontSize = 14.sp, + modifier = Modifier.padding(top = 16.dp) + ) + } else { + LazyColumn { + items(items = latestOpenedRepositoriesPaths) { repo -> + val repoDirName = repo.dirName + val repoDirPath = repo.dirPath + + Row( + verticalAlignment = Alignment.CenterVertically, + ) { + TextButton( + onClick = { + tabViewModel.openRepository(repo) + } + ) { + Text( + text = repoDirName, + fontSize = 14.sp, + color = MaterialTheme.colors.primary, + ) + } + + Text( + text = repoDirPath, + fontSize = 14.sp, + modifier = Modifier.padding(start = 4.dp), + color = MaterialTheme.colors.secondaryTextColor + ) + } + } + } + } + } +} + @Composable fun ButtonTile( modifier: Modifier = Modifier,