Reestructured project directories

This commit is contained in:
Abdelilah El Aissaoui 2021-10-03 05:03:38 +02:00
parent 0d7c42b1bf
commit 1433c0f601
13 changed files with 83 additions and 51 deletions

View File

@ -1,3 +1,5 @@
package git
import org.eclipse.jgit.diff.DiffEntry import org.eclipse.jgit.diff.DiffEntry
sealed class DiffEntryType(val diffEntry: DiffEntry) { sealed class DiffEntryType(val diffEntry: DiffEntry) {

View File

@ -1,6 +1,5 @@
package git package git
import DiffEntryType
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.eclipse.jgit.api.Git import org.eclipse.jgit.api.Git
@ -15,7 +14,6 @@ import org.eclipse.jgit.treewalk.AbstractTreeIterator
import org.eclipse.jgit.treewalk.CanonicalTreeParser import org.eclipse.jgit.treewalk.CanonicalTreeParser
import org.eclipse.jgit.treewalk.FileTreeIterator import org.eclipse.jgit.treewalk.FileTreeIterator
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.IOException
class DiffManager { class DiffManager {
suspend fun diffFormat(git: Git, diffEntryType: DiffEntryType): List<String> = withContext(Dispatchers.IO) { suspend fun diffFormat(git: Git, diffEntryType: DiffEntryType): List<String> = withContext(Dispatchers.IO) {

View File

@ -1,7 +1,7 @@
package git
import credentials.CredentialsState import credentials.CredentialsState
import credentials.CredentialsStateManager import credentials.CredentialsStateManager import kotlinx.coroutines.*
import git.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import org.eclipse.jgit.api.Git import org.eclipse.jgit.api.Git
@ -10,6 +10,7 @@ import org.eclipse.jgit.lib.Ref
import org.eclipse.jgit.lib.Repository import org.eclipse.jgit.lib.Repository
import org.eclipse.jgit.revwalk.RevCommit import org.eclipse.jgit.revwalk.RevCommit
import org.eclipse.jgit.storage.file.FileRepositoryBuilder import org.eclipse.jgit.storage.file.FileRepositoryBuilder
import GPreferences
import java.io.File import java.io.File

View File

@ -15,7 +15,11 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.* import androidx.compose.ui.window.*
import git.GitManager
import git.RepositorySelectionStatus
import theme.* import theme.*
import ui.RepositoryOpenPage
import ui.WelcomePage
import javax.swing.JFileChooser import javax.swing.JFileChooser
@ -72,13 +76,13 @@ fun Gitnuro(gitManager: GitManager) {
@Suppress("UnnecessaryVariable") // Don't inline it because smart cast won't work @Suppress("UnnecessaryVariable") // Don't inline it because smart cast won't work
when (repositorySelectionStatus) { when (repositorySelectionStatus) {
RepositorySelectionStatus.None -> { RepositorySelectionStatus.None -> {
NoneRepository() WelcomePage()
} }
RepositorySelectionStatus.Loading -> { RepositorySelectionStatus.Loading -> {
LoadingRepository() LoadingRepository()
} }
is RepositorySelectionStatus.Open -> { is RepositorySelectionStatus.Open -> {
RepositorySelected(gitManager = gitManager) RepositoryOpenPage(gitManager = gitManager)
} }
} }
} }
@ -93,14 +97,6 @@ fun LoadingRepository() {
} }
@Composable
fun NoneRepository() {
Box(
contentAlignment = Alignment.Center
) {
Text("Open a repository to start using Gitnuro")
}
}
@Composable @Composable
fun GMenu( fun GMenu(

View File

@ -1,7 +1,8 @@
package ui
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material.* import androidx.compose.material.*
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
@ -17,8 +18,9 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import components.ScrollableLazyColumn import ui.components.ScrollableLazyColumn
import extensions.simpleName import extensions.simpleName
import git.GitManager
import org.eclipse.jgit.lib.Ref import org.eclipse.jgit.lib.Ref
import theme.headerBackground import theme.headerBackground

View File

@ -1,6 +1,7 @@
package ui
import androidx.compose.foundation.* import androidx.compose.foundation.*
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.* import androidx.compose.material.*
@ -28,7 +29,8 @@ import java.net.HttpURLConnection
import java.net.URL import java.net.URL
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import components.ScrollableLazyColumn import ui.components.ScrollableLazyColumn
import git.GitManager
@Composable @Composable
fun CommitChanges( fun CommitChanges(

View File

@ -1,9 +1,10 @@
package ui
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
@ -19,7 +20,9 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import components.ScrollableLazyColumn import ui.components.ScrollableLazyColumn
import git.DiffEntryType
import git.GitManager
import theme.primaryTextColor import theme.primaryTextColor
@Composable @Composable

View File

@ -1,11 +1,9 @@
import androidx.compose.foundation.VerticalScrollbar package ui
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollbarAdapter
import androidx.compose.material.Card import androidx.compose.material.Card
import androidx.compose.material.Divider import androidx.compose.material.Divider
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
@ -17,8 +15,9 @@ import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import components.ScrollableLazyColumn import ui.components.ScrollableLazyColumn
import extensions.toSmartSystemString import extensions.toSmartSystemString
import git.GitManager
import git.LogStatus import git.LogStatus
import org.eclipse.jgit.revwalk.RevCommit import org.eclipse.jgit.revwalk.RevCommit
import theme.primaryTextColor import theme.primaryTextColor

View File

@ -0,0 +1,39 @@
package ui
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
@Composable
fun WelcomePage() {
Row(
modifier = Modifier
.fillMaxSize(),
horizontalArrangement = Arrangement.Center,
) {
Column(
modifier = Modifier
.fillMaxHeight(),
verticalArrangement = Arrangement.Center,
) {
Button(onClick = {}) {
Image(
painter = painterResource("open.svg"),
contentDescription = null,
colorFilter = ColorFilter.tint(contentColorFor(MaterialTheme.colors.primary))
)
Text("Open repository")
}
}
}
}

View File

@ -1,3 +1,5 @@
package ui
import androidx.compose.animation.Crossfade import androidx.compose.animation.Crossfade
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.material.* import androidx.compose.material.*
@ -6,24 +8,17 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.Dialog
import credentials.CredentialsState import credentials.CredentialsState
import org.eclipse.jgit.api.Git import git.DiffEntryType
import org.eclipse.jgit.diff.DiffEntry import git.GitManager
import org.eclipse.jgit.lib.Repository
import org.eclipse.jgit.revwalk.RevCommit import org.eclipse.jgit.revwalk.RevCommit
import org.eclipse.jgit.revwalk.RevTree
import org.eclipse.jgit.revwalk.RevWalk
import org.eclipse.jgit.treewalk.AbstractTreeIterator
import org.eclipse.jgit.treewalk.CanonicalTreeParser
import java.io.IOException
@Composable @Composable
fun RepositorySelected(gitManager: GitManager) { fun RepositoryOpenPage(gitManager: GitManager) {
var selectedRevCommit by remember { var selectedRevCommit by remember {
mutableStateOf<RevCommit?>(null) mutableStateOf<RevCommit?>(null)
} }

View File

@ -1,11 +1,10 @@
package ui
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material.* import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
@ -16,7 +15,8 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import components.ScrollableLazyColumn import ui.components.ScrollableLazyColumn
import git.GitManager
import git.StashStatus import git.StashStatus
import org.eclipse.jgit.revwalk.RevCommit import org.eclipse.jgit.revwalk.RevCommit
import theme.headerBackground import theme.headerBackground
@ -43,7 +43,7 @@ fun Stashes(gitManager: GitManager) {
.background(MaterialTheme.colors.headerBackground) .background(MaterialTheme.colors.headerBackground)
.padding(vertical = 8.dp) .padding(vertical = 8.dp)
.fillMaxWidth(), .fillMaxWidth(),
text = "Stashes", text = "ui.Stashes",
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
color = MaterialTheme.colors.primary, color = MaterialTheme.colors.primary,

View File

@ -1,39 +1,34 @@
@file:Suppress("UNUSED_PARAMETER") @file:Suppress("UNUSED_PARAMETER")
package ui
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut import androidx.compose.animation.fadeOut
import androidx.compose.foundation.* import androidx.compose.foundation.*
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.* import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Close
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.pointerMoveFilter import androidx.compose.ui.input.pointer.pointerMoveFilter
import androidx.compose.ui.platform.ContextMenuItem import androidx.compose.ui.platform.ContextMenuItem
import androidx.compose.ui.platform.ContextMenuState
import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import components.ScrollableLazyColumn import ui.components.ScrollableLazyColumn
import extensions.filePath import extensions.filePath
import extensions.icon import extensions.icon
import extensions.iconColor import extensions.iconColor
import git.GitManager
import git.StageStatus import git.StageStatus
import org.eclipse.jgit.diff.DiffEntry import org.eclipse.jgit.diff.DiffEntry
import theme.headerBackground import theme.headerBackground

View File

@ -1,4 +1,4 @@
package components package ui.components
import androidx.compose.foundation.VerticalScrollbar import androidx.compose.foundation.VerticalScrollbar
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box