mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-21 08:19:33 +00:00
add placeholder button
This commit is contained in:
1 file changed
+30
-3
@@ -2,14 +2,17 @@ package com.geode.geodelauncher
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedDispatcher
|
import androidx.activity.OnBackPressedDispatcher
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.selection.toggleable
|
import androidx.compose.foundation.selection.toggleable
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.ArrowBack
|
import androidx.compose.material.icons.filled.ArrowBack
|
||||||
|
import androidx.compose.material.icons.filled.List
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@@ -43,6 +46,14 @@ class SettingsActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onExportSaveData(context: Context) {
|
||||||
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
"This function is not implemented yet!",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingsScreen(onBackPressedDispatcher: OnBackPressedDispatcher?) {
|
fun SettingsScreen(onBackPressedDispatcher: OnBackPressedDispatcher?) {
|
||||||
@@ -81,6 +92,11 @@ fun SettingsScreen(onBackPressedDispatcher: OnBackPressedDispatcher?) {
|
|||||||
preferenceId = R.string.preference_load_testing
|
preferenceId = R.string.preference_load_testing
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
OptionsGroup("Data") {
|
||||||
|
OptionsButton(onClick = { onExportSaveData(context) }) {
|
||||||
|
Text("Export save data")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -122,6 +138,15 @@ fun OptionsGroup(title: String, content: @Composable () -> Unit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun OptionsButton(onClick: () -> Unit, content: @Composable () -> Unit) {
|
||||||
|
OptionsCard(
|
||||||
|
title = content,
|
||||||
|
modifier = Modifier
|
||||||
|
.clickable(onClick = onClick, role = Role.Button)
|
||||||
|
) { }
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingsCard(title: String, @StringRes preferenceId: Int) {
|
fun SettingsCard(title: String, @StringRes preferenceId: Int) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
@@ -129,7 +154,9 @@ fun SettingsCard(title: String, @StringRes preferenceId: Int) {
|
|||||||
mutableStateOf(getSetting(context, preferenceId)) }
|
mutableStateOf(getSetting(context, preferenceId)) }
|
||||||
|
|
||||||
OptionsCard(
|
OptionsCard(
|
||||||
title = title,
|
title = {
|
||||||
|
Text(title)
|
||||||
|
},
|
||||||
modifier = Modifier.toggleable(
|
modifier = Modifier.toggleable(
|
||||||
value = settingEnabled.value,
|
value = settingEnabled.value,
|
||||||
onValueChange = { settingEnabled.value = toggleSetting(context, preferenceId) },
|
onValueChange = { settingEnabled.value = toggleSetting(context, preferenceId) },
|
||||||
@@ -141,7 +168,7 @@ fun SettingsCard(title: String, @StringRes preferenceId: Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun OptionsCard(title: String, modifier: Modifier = Modifier, content: @Composable () -> Unit) {
|
fun OptionsCard(modifier: Modifier = Modifier, title: @Composable () -> Unit, content: @Composable () -> Unit) {
|
||||||
Row(
|
Row(
|
||||||
modifier
|
modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@@ -150,7 +177,7 @@ fun OptionsCard(title: String, modifier: Modifier = Modifier, content: @Composab
|
|||||||
Arrangement.SpaceBetween,
|
Arrangement.SpaceBetween,
|
||||||
Alignment.CenterVertically,
|
Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
Text(title)
|
title()
|
||||||
content()
|
content()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user