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 @@ -48,4 +48,6 @@ sealed interface RemoteDestination : Parcelable {
val url: String
) : RemoteDestination

@Parcelize
data object Logs: RemoteDestination
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ import androidx.compose.ui.platform.LocalClipboard
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewModelScope
import io.github.wiiznokes.gitnote.BuildConfig
import io.github.wiiznokes.gitnote.R
import io.github.wiiznokes.gitnote.ui.component.AppPage
import io.github.wiiznokes.gitnote.ui.component.CustomDropDown
import io.github.wiiznokes.gitnote.ui.component.CustomDropDownModel
import io.github.wiiznokes.gitnote.ui.component.SimpleIcon
import io.github.wiiznokes.gitnote.ui.viewmodel.SettingsViewModel
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -71,15 +69,16 @@ private fun getTextStyleFromInt(id: Int): TextStyle {
@Composable
fun LogsScreen(
onBackClick: () -> Unit,
vm: SettingsViewModel
) {

val logLevel = remember {
mutableStateOf(LogLevel.ERROR)
}

val initTextValue = stringResource(R.string.loading)

val logState: MutableState<String> = remember {
mutableStateOf(vm.uiHelper.getString(R.string.loading))
mutableStateOf(initTextValue)
}


Expand Down Expand Up @@ -141,7 +140,7 @@ fun LogsScreen(
ClipData.Item(logState.value)
)

vm.viewModelScope.launch {
CoroutineScope(Dispatchers.IO).launch {
clipboardManager.setClipEntry(ClipEntry(data))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ fun SettingsNav(
onBackClick = {
navController.pop()
},
vm = vm
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.github.wiiznokes.gitnote.R
import io.github.wiiznokes.gitnote.ui.component.AppPage
import io.github.wiiznokes.gitnote.ui.viewmodel.InitState

Expand All @@ -20,6 +22,7 @@ private const val TAG = "CloningScreen"
fun CloningScreen(
cloneState: InitState,
onCancel: () -> Unit,
onShowLogs: () -> Unit,
) {
AppPage(
title = "Clone",
Expand All @@ -31,11 +34,24 @@ fun CloningScreen(

Spacer(Modifier.height(20.dp))

if (cloneState is InitState.Error) {
Button(
onClick = onShowLogs
) {
Text(stringResource(R.string.show_logs))
}
}

Button(
onClick = onCancel,
enabled = cloneState !is InitState.CalculatingTimestamps && cloneState !is InitState.GeneratingDatabase
) {
Text("Cancel")
Text(
if (cloneState is InitState.Error) {
stringResource(R.string.go_back)

} else stringResource(R.string.cancel)
)
}
}
}
Expand All @@ -45,7 +61,8 @@ fun CloningScreen(
private fun PickRepoScreenPreview() {

CloningScreen(
cloneState = InitState.Cloning(50),
cloneState = InitState.Error("Can't clone repo"),
onCancel = {},
onShowLogs = {}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import io.github.wiiznokes.gitnote.ui.destination.RemoteDestination.PickRepo
import io.github.wiiznokes.gitnote.ui.destination.RemoteDestination.SelectGenerateNewSshKeys
import io.github.wiiznokes.gitnote.ui.destination.RemoteDestination.SelectProvider
import io.github.wiiznokes.gitnote.ui.destination.RemoteDestination.SelectSetupAutomatically
import io.github.wiiznokes.gitnote.ui.destination.SettingsDestination
import io.github.wiiznokes.gitnote.ui.model.StorageConfiguration
import io.github.wiiznokes.gitnote.ui.screen.settings.LogsScreen
import io.github.wiiznokes.gitnote.ui.utils.slide
import io.github.wiiznokes.gitnote.ui.viewmodel.SetupViewModel

Expand Down Expand Up @@ -177,8 +179,20 @@ fun RemoteScreen(
onCancel = {
if (vm.cancelClone())
navController.pop()
},
onShowLogs = {
navController.navigate(RemoteDestination.Logs)
}

)

RemoteDestination.Logs -> {
LogsScreen(
onBackClick = {
navController.pop()
},
)
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,7 @@
<string name="load_from_file">Load from file</string>
<string name="private_key">Private key</string>
<string name="private_key_password">Private key password</string>
<string name="cancel">Cancel</string>
<string name="go_back">Go back</string>

</resources>