Skip to content

Commit

Permalink
feat: install abort warning dialog
Browse files Browse the repository at this point in the history
Based on Wing's version in Vendetta Manager
  • Loading branch information
rushiiMachine committed Jan 24, 2024
1 parent a38a28b commit 5d54bde
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.aliucord.manager.ui.components.dialogs

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Warning
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import com.aliucord.manager.R

@Composable
fun InstallerAbortDialog(
onConfirm: () -> Unit,
onDismiss: () -> Unit,
) {
AlertDialog(
onDismissRequest = onDismiss,
confirmButton = {
FilledTonalButton(
onClick = onConfirm,
colors = ButtonDefaults.filledTonalButtonColors(
containerColor = MaterialTheme.colorScheme.error,
contentColor = MaterialTheme.colorScheme.onError,
),
) {
Text(stringResource(R.string.action_exit_anyways))
}
},
dismissButton = {
TextButton(
onClick = onDismiss,
colors = ButtonDefaults.textButtonColors(
contentColor = MaterialTheme.colorScheme.onErrorContainer
),
) {
Text(stringResource(R.string.action_cancel))
}
},
title = {
Text(stringResource(R.string.installer_abort_title))
},
text = {
Text(stringResource(R.string.installer_abort_body))
},
icon = {
Icon(Icons.Filled.Warning, contentDescription = null)
},
containerColor = MaterialTheme.colorScheme.errorContainer,
iconContentColor = MaterialTheme.colorScheme.onErrorContainer,
titleContentColor = MaterialTheme.colorScheme.onErrorContainer,
textContentColor = MaterialTheme.colorScheme.onErrorContainer
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private fun MainContributors(modifier: Modifier = Modifier) {
) {
UserEntry("Vendicated", "the ven")
UserEntry("Juby210", "Fox")
UserEntry("rushii", "explod", "DiamondMiner88")
UserEntry("rushii", "explod", "rushiiMachine")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.aliucord.manager.ui.screens.install

import android.os.Parcelable
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
Expand All @@ -15,6 +16,7 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
Expand All @@ -26,6 +28,7 @@ import com.aliucord.manager.R
import com.aliucord.manager.ui.components.BackButton
import com.aliucord.manager.ui.components.back
import com.aliucord.manager.ui.components.dialogs.DownloadMethod
import com.aliucord.manager.ui.components.dialogs.InstallerAbortDialog
import com.aliucord.manager.ui.components.installer.InstallGroup
import com.aliucord.manager.ui.components.installer.InstallStatus
import com.aliucord.manager.ui.screens.install.InstallModel.InstallStepGroup
Expand Down Expand Up @@ -58,13 +61,35 @@ class InstallScreen(val data: InstallData) : Screen {
expandedGroup = model.currentStep?.group
}

// Exit warning dialog
var showAbortWarning by remember { mutableStateOf(false) }
if (showAbortWarning) {
InstallerAbortDialog(
onDismiss = { showAbortWarning = false },
onConfirm = {
navigator.back(currentActivity = null)
model.clearCache()
},
)
} else {
BackHandler {
showAbortWarning = true
}
}

Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(R.string.installer)) },
navigationIcon = {
// TODO: add confirm to exit dialog to button as well as BackHandler
BackButton()
IconButton(
onClick = { showAbortWarning = true },
) {
Icon(
painter = painterResource(R.drawable.ic_back),
contentDescription = stringResource(R.string.navigation_back),
)
}
}
)
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<string name="website">Website</string>
<string name="installer">Installer</string>

<string name="action_cancel">Cancel</string>
<string name="action_retry">Retry</string>
<string name="action_apply">Apply</string>
<string name="action_confirm">Confirm</string>
Expand All @@ -27,6 +28,7 @@
<string name="action_expand">Expand</string>
<string name="action_copied">Copied!</string>
<string name="action_cleared_cache">Cleared cache!</string>
<string name="action_exit_anyways">Exit anyways</string>

<string name="permissions_grant_title">Grant Permissions</string>
<string name="permissions_grant_body">In order for Aliucord Manager to function, file permissions are required. Since shared data is stored in ~/Aliucord, permissions are required in order to access it.</string>
Expand Down Expand Up @@ -125,6 +127,9 @@
<string name="status_failed">Failed</string>
<string name="status_queued">Queued</string>

<string name="installer_abort_title">Really exit?</string>
<string name="installer_abort_body">Are you sure you really want to abort an in-progress installation? Cached files will be cleared to avoid corruption.</string>

<string name="updater_body">A new update has been released for Aliucord Manager! It may be required in order to function properly. Would you like to update?</string>
<string name="updater_title">Update to %1$s</string>

Expand Down

0 comments on commit 5d54bde

Please sign in to comment.