-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aab0b51
commit 3ab8e55
Showing
18 changed files
with
476 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
app/src/main/java/com/nasahacker/steelmind/compose/ui/component/AppBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.nasahacker.steelmind.compose.ui.component | ||
|
||
import androidx.compose.foundation.layout.RowScope | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.filled.ArrowBack | ||
import androidx.compose.material.icons.filled.Delete | ||
import androidx.compose.material3.* | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.tooling.preview.Preview | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun AppBar( | ||
title: String, | ||
onNavigationClick: () -> Unit, | ||
actions: @Composable RowScope.() -> Unit = {} | ||
) { | ||
TopAppBar( | ||
title = { Text(text = title, style = MaterialTheme.typography.titleLarge) }, | ||
navigationIcon = { | ||
IconButton(onClick = onNavigationClick) { | ||
Icon( | ||
imageVector = Icons.AutoMirrored.Filled.ArrowBack, | ||
contentDescription = "Back" | ||
) | ||
} | ||
}, | ||
actions = actions, | ||
colors = TopAppBarDefaults.topAppBarColors() | ||
) | ||
} | ||
|
||
@Preview(showBackground = true, showSystemUi = true) | ||
@Composable | ||
fun PreviewAppBar() { | ||
AppBar( | ||
title = "Sample App Bar", | ||
onNavigationClick = {}, | ||
actions = { | ||
IconButton(onClick = {}) { | ||
Icon( | ||
imageVector = Icons.Filled.Delete, | ||
contentDescription = "Action" | ||
) | ||
} | ||
} | ||
) | ||
} |
74 changes: 74 additions & 0 deletions
74
app/src/main/java/com/nasahacker/steelmind/compose/ui/component/DeleteDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.nasahacker.steelmind.compose.ui.component | ||
|
||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Delete | ||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun DeleteDialog( | ||
onDismissRequest: () -> Unit, | ||
onConfirmation: () -> Unit, | ||
dialogTitle: String, | ||
dialogText: String, | ||
icon: ImageVector, | ||
) { | ||
AlertDialog( | ||
icon = { | ||
Icon(icon, contentDescription = null) | ||
}, | ||
title = { | ||
Text(text = dialogTitle) | ||
}, | ||
text = { | ||
Text( | ||
text = dialogText, | ||
textAlign = TextAlign.Center, | ||
modifier = Modifier.fillMaxWidth() | ||
) | ||
}, | ||
onDismissRequest = { | ||
onDismissRequest() | ||
}, | ||
confirmButton = { | ||
TextButton( | ||
onClick = { | ||
onConfirmation() | ||
} | ||
) { | ||
Text("Confirm") | ||
} | ||
}, | ||
dismissButton = { | ||
TextButton( | ||
onClick = { | ||
onDismissRequest() | ||
} | ||
) { | ||
Text("Dismiss") | ||
} | ||
} | ||
) | ||
} | ||
|
||
@Preview(showBackground = true, showSystemUi = true) | ||
@Composable | ||
fun PreviewDeleteDialog(modifier: Modifier = Modifier) { | ||
DeleteDialog( | ||
onDismissRequest = {}, | ||
onConfirmation = { }, | ||
dialogTitle = "Delete All?", | ||
dialogText = "This action will delete all the history data, confirm to go ahead.", | ||
icon = Icons.Filled.Delete | ||
) | ||
} |
83 changes: 83 additions & 0 deletions
83
app/src/main/java/com/nasahacker/steelmind/compose/ui/component/HistoryItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.nasahacker.steelmind.compose.ui.component | ||
|
||
import androidx.compose.foundation.ExperimentalFoundationApi | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.combinedClickable | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material3.* | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
|
||
@OptIn(ExperimentalFoundationApi::class) | ||
@Composable | ||
fun HistoryItem( | ||
action: String, | ||
remarks: String = "No Remarks", | ||
time: String, | ||
onClick: () -> Unit, | ||
onLongPress: () -> Unit, | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.background(MaterialTheme.colorScheme.surfaceVariant) | ||
.padding(4.dp) | ||
.combinedClickable( | ||
onClick = { onClick() }, | ||
onLongClick = { onLongPress() } | ||
), | ||
verticalArrangement = Arrangement.spacedBy(4.dp) | ||
) { | ||
Text( | ||
text = action, | ||
style = MaterialTheme.typography.titleMedium.copy( | ||
color = MaterialTheme.colorScheme.primary, | ||
fontWeight = FontWeight.Bold | ||
), | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis | ||
) | ||
Text( | ||
text = remarks, | ||
style = MaterialTheme.typography.bodyMedium.copy( | ||
color = MaterialTheme.colorScheme.onSurfaceVariant | ||
), | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis | ||
) | ||
Text( | ||
text = time, | ||
style = MaterialTheme.typography.bodySmall.copy( | ||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.7f) | ||
), | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis | ||
) | ||
HorizontalDivider( | ||
modifier = Modifier.padding(top = 8.dp), | ||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.12f), | ||
thickness = 1.dp | ||
) | ||
} | ||
|
||
} | ||
|
||
@Preview(showBackground = true, showSystemUi = true) | ||
@Composable | ||
fun PreviewHistoryItem() { | ||
MaterialTheme { | ||
HistoryItem( | ||
action = "Started Workout", | ||
remarks = "Completed first set of exercises", | ||
time = "12/10/2025 10:00 PM", | ||
onClick = {}, | ||
onLongPress = {} | ||
) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/nasahacker/steelmind/compose/ui/screen/AboutScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.nasahacker.steelmind.compose.ui.screen | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
|
||
@Composable | ||
fun AboutScreen(modifier: Modifier = Modifier) { | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/nasahacker/steelmind/compose/ui/screen/DebugLogsScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.nasahacker.steelmind.compose.ui.screen | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
|
||
|
||
@Composable | ||
fun DebugLogsScreen(modifier: Modifier = Modifier) { | ||
|
||
} |
105 changes: 105 additions & 0 deletions
105
app/src/main/java/com/nasahacker/steelmind/compose/ui/screen/HistoryScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package com.nasahacker.steelmind.compose.ui.screen | ||
|
||
import android.widget.Toast | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Delete | ||
import androidx.compose.material.icons.outlined.Delete | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.nasahacker.steelmind.compose.ui.component.AppBar | ||
import com.nasahacker.steelmind.compose.ui.component.DeleteDialog | ||
import com.nasahacker.steelmind.compose.ui.component.HistoryItem | ||
import com.nasahacker.steelmind.dto.History | ||
import com.nasahacker.steelmind.util.MmkvManager | ||
|
||
@Composable | ||
fun HistoryScreen(onNavigationClick: () -> Unit) { | ||
// States | ||
var historyList by remember { mutableStateOf(MmkvManager.getHistory()) } | ||
var isDeleteAllDialogVisible by remember { mutableStateOf(false) } | ||
var isDeleteItemDialogVisible by remember { mutableStateOf(false) } | ||
var selectedHistory: History? by remember { mutableStateOf(null) } | ||
val context = LocalContext.current | ||
|
||
Column(modifier = Modifier.fillMaxSize()) { | ||
// Top AppBar | ||
AppBar( | ||
title = "History", | ||
onNavigationClick = onNavigationClick, | ||
actions = { | ||
IconButton(onClick = { isDeleteAllDialogVisible = true }) { | ||
Icon( | ||
imageVector = Icons.Outlined.Delete, | ||
contentDescription = "Delete All History" | ||
) | ||
} | ||
} | ||
) | ||
|
||
// History List | ||
LazyColumn { | ||
items(historyList) { history -> | ||
HistoryItem( | ||
action = history.action, | ||
remarks = history.remarks, | ||
time = history.time, | ||
onClick = { | ||
// Handle click event if needed | ||
}, | ||
onLongPress = { | ||
selectedHistory = history | ||
isDeleteItemDialogVisible = true | ||
} | ||
) | ||
} | ||
} | ||
|
||
// Delete All Dialog | ||
if (isDeleteAllDialogVisible) { | ||
DeleteDialog( | ||
onDismissRequest = { isDeleteAllDialogVisible = false }, | ||
onConfirmation = { | ||
MmkvManager.clearAllHistory() | ||
historyList = MmkvManager.getHistory() | ||
isDeleteAllDialogVisible = false | ||
Toast.makeText(context, "All history deleted successfully.", Toast.LENGTH_SHORT).show() | ||
}, | ||
dialogTitle = "Delete All?", | ||
dialogText = "This action will delete all the history data. Confirm to proceed.", | ||
icon = Icons.Filled.Delete | ||
) | ||
} | ||
|
||
// Delete Item Dialog | ||
if (isDeleteItemDialogVisible) { | ||
selectedHistory?.let { history -> | ||
DeleteDialog( | ||
onDismissRequest = { isDeleteItemDialogVisible = false }, | ||
onConfirmation = { | ||
MmkvManager.deleteHistory(history) | ||
historyList = MmkvManager.getHistory() | ||
isDeleteItemDialogVisible = false | ||
Toast.makeText(context, "Item deleted successfully.", Toast.LENGTH_SHORT).show() | ||
}, | ||
dialogTitle = "Delete Item?", | ||
dialogText = "This action will delete the selected item. Confirm to proceed.", | ||
icon = Icons.Filled.Delete | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview(showSystemUi = true, showBackground = true) | ||
@Composable | ||
fun PreviewHistoryScreen() { | ||
HistoryScreen(onNavigationClick = {}) | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/nasahacker/steelmind/compose/ui/screen/MainScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.nasahacker.steelmind.compose.ui.screen | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
|
||
@Composable | ||
fun MainScreen(modifier: Modifier = Modifier) { | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/nasahacker/steelmind/compose/ui/theme/Color.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.nasahacker.steelmind.compose.ui.theme | ||
|
||
import androidx.compose.ui.graphics.Color | ||
|
||
val Purple80 = Color(0xFFD0BCFF) | ||
val PurpleGrey80 = Color(0xFFCCC2DC) | ||
val Pink80 = Color(0xFFEFB8C8) | ||
|
||
val Purple40 = Color(0xFF6650a4) | ||
val PurpleGrey40 = Color(0xFF625b71) | ||
val Pink40 = Color(0xFF7D5260) |
Oops, something went wrong.