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
12 changes: 0 additions & 12 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.about.libraries)
// for room
alias(libs.plugins.ksp)
// for compose navigation
Expand Down Expand Up @@ -167,9 +166,6 @@ dependencies {
implementation(libs.runtime.compose)
implementation(libs.compose.activity)
implementation(libs.datastore.preferences)
//implementation(libs.work.runtime.ktx)
//implementation(libs.splash.screen)


val composeBom = platform(libs.compose.bom)

Expand All @@ -179,16 +175,11 @@ dependencies {
implementation(libs.compose.material)
implementation(libs.compose.material3)
implementation(libs.compose.material.icons.extended)
//implementation(libs.compose.constraintlayout)

// Compose Debug
implementation(libs.compose.ui.preview)
debugImplementation(libs.androidx.ui.tooling)

// Accompanist
//implementation(libs.accompanist.permissions)


// Room
implementation(libs.room.runtime)
implementation(libs.room.ktx)
Expand All @@ -198,9 +189,6 @@ dependencies {
// Compose Navigation
implementation(libs.reimagined.navigation)

// Licenses
implementation(libs.about.libraries)

// Markdown to HTML
implementation(libs.richtext.commonmark)
implementation(libs.richtext.ui.material3)
Expand Down
14 changes: 3 additions & 11 deletions app/src/main/java/io/github/wiiznokes/gitnote/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ import io.github.wiiznokes.gitnote.ui.destination.Destination
import io.github.wiiznokes.gitnote.ui.destination.EditParams
import io.github.wiiznokes.gitnote.ui.destination.InitDestination
import io.github.wiiznokes.gitnote.ui.screen.app.AppScreen
import io.github.wiiznokes.gitnote.ui.screen.init.InitScreen
import io.github.wiiznokes.gitnote.ui.screen.init.InitNav
import io.github.wiiznokes.gitnote.ui.theme.GitNoteTheme
import io.github.wiiznokes.gitnote.ui.theme.Theme
import io.github.wiiznokes.gitnote.ui.viewmodel.MainViewModel
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking

Expand All @@ -48,7 +47,6 @@ class MainActivity : ComponentActivity() {

setContent {


val vm: MainViewModel = viewModel()

val theme by vm.prefs.theme.getAsState()
Expand Down Expand Up @@ -79,15 +77,9 @@ class MainActivity : ComponentActivity() {
)
}

} else {
Destination.App(
AppDestination.Grid
//AppDestination.Settings(SettingsDestination.Main)
)
}
} else Destination.App(AppDestination.Grid)
}
else Destination.Init(InitDestination.Main)
// else Destination.Init(InitDestination.Remote(StorageConfiguration.App))
}


Expand All @@ -101,7 +93,7 @@ class MainActivity : ComponentActivity() {
) { destination ->
when (destination) {
is Destination.Init -> {
InitScreen(
InitNav(
startDestination = destination.initDestination,
mainVm = vm,
authFlow = authFlow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeContent
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
Expand All @@ -17,6 +17,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.ScaffoldDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
Expand All @@ -39,7 +40,7 @@ fun AppPage(
verticalArrangement: Arrangement.Vertical = Arrangement.Top,
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
disableVerticalScroll: Boolean = false,
contentWindowInsets: WindowInsets = WindowInsets.safeContent,
contentWindowInsets: WindowInsets = WindowInsets.safeDrawing,
actions: @Composable RowScope.() -> Unit = {},
bottomBar: @Composable () -> Unit = {},
content: @Composable ColumnScope.() -> Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ sealed interface InitDestination : Parcelable {
data class FileExplorer(
val title: String,
val path: String?,
val newRepoSource: NewRepoSource,
val newRepoMethod: NewRepoMethod,
) : InitDestination

@Parcelize
data class Remote(val storageConfig: StorageConfiguration) : InitDestination

}

enum class NewRepoSource {
enum class NewRepoMethod {
Create,
Open,
Clone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ sealed interface SettingsDestination : Parcelable {
@Parcelize
data object Logs : SettingsDestination

@Parcelize
data object Libraries : SettingsDestination


@Parcelize
data object FolderFilters : SettingsDestination

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import io.github.wiiznokes.gitnote.ui.destination.EditParams
import io.github.wiiznokes.gitnote.ui.destination.SettingsDestination
import io.github.wiiznokes.gitnote.ui.screen.app.edit.EditScreen
import io.github.wiiznokes.gitnote.ui.screen.app.grid.GridScreen
import io.github.wiiznokes.gitnote.ui.screen.settings.SettingsScreen
import io.github.wiiznokes.gitnote.ui.screen.settings.SettingsNav
import io.github.wiiznokes.gitnote.ui.util.crossFade
import io.github.wiiznokes.gitnote.ui.util.slide

Expand Down Expand Up @@ -66,7 +66,7 @@ fun AppScreen(
}
)

is AppDestination.Settings -> SettingsScreen(
is AppDestination.Settings -> SettingsNav(
onBackClick = { navController.pop() },
destination = it.settingsDestination,
onStorageFailure = onStorageFailure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package io.github.wiiznokes.gitnote.ui.screen.init

import androidx.compose.animation.ContentTransform
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewmodel.compose.viewModel
import dev.olshevski.navigation.reimagined.AnimatedNavHost
import dev.olshevski.navigation.reimagined.NavAction
Expand All @@ -15,30 +13,35 @@ import dev.olshevski.navigation.reimagined.pop
import dev.olshevski.navigation.reimagined.popUpTo
import dev.olshevski.navigation.reimagined.rememberNavController
import io.github.wiiznokes.gitnote.ui.destination.InitDestination
import io.github.wiiznokes.gitnote.ui.destination.NewRepoSource
import io.github.wiiznokes.gitnote.ui.destination.NewRepoMethod
import io.github.wiiznokes.gitnote.ui.model.StorageConfiguration
import io.github.wiiznokes.gitnote.ui.screen.init.remote.RemoteScreen
import io.github.wiiznokes.gitnote.ui.util.crossFade
import io.github.wiiznokes.gitnote.ui.util.slide
import io.github.wiiznokes.gitnote.ui.viewmodel.InitViewModel
import io.github.wiiznokes.gitnote.ui.viewmodel.InitViewModelFactory
import io.github.wiiznokes.gitnote.ui.viewmodel.MainViewModel
import io.github.wiiznokes.gitnote.ui.viewmodel.viewModelFactory
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow

private const val TAG = "InitScreen"

@Composable
fun InitScreen(
fun InitNav(
mainVm: MainViewModel,
startDestination: InitDestination,
onInitSuccess: () -> Unit,
authFlow: SharedFlow<String>
) {


val factory = remember { InitViewModelFactory(authFlow) }
val vm: InitViewModel = viewModel(factory = factory)
val vm: InitViewModel = viewModel(
factory = viewModelFactory {
InitViewModel(
authFlow = authFlow
)
},

)

val navController =
rememberNavController(startDestination = startDestination)
Expand All @@ -52,7 +55,7 @@ fun InitScreen(
) { initDestination ->
when (initDestination) {

InitDestination.Main -> MainScreen(
InitDestination.Main -> NewRepoMethodScreen(
vm = vm,
mainVm = mainVm,
navController = navController,
Expand All @@ -73,17 +76,17 @@ fun InitScreen(
InitDestination.FileExplorer(
title = initDestination.title,
path = it,
newRepoSource = initDestination.newRepoSource
newRepoMethod = initDestination.newRepoMethod
)
)
},
onFinish = { path ->
val repoState = StorageConfiguration.Device(path)

when (initDestination.newRepoSource) {
NewRepoSource.Create -> vm.createLocalRepo(repoState, onInitSuccess)
NewRepoSource.Open -> mainVm.openRepo(repoState, onInitSuccess)
NewRepoSource.Clone -> {
when (initDestination.newRepoMethod) {
NewRepoMethod.Create -> vm.createLocalRepo(repoState, onInitSuccess)
NewRepoMethod.Open -> mainVm.openRepo(repoState, onInitSuccess)
NewRepoMethod.Clone -> {
vm.checkPathForClone(repoState.repoPath()).onSuccess {
navController.navigate(
InitDestination.Remote(repoState)
Expand Down
Loading
Loading