diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ca3c69e..c10652e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("com.android.application") id("org.jetbrains.kotlin.android") + id("com.google.devtools.ksp") version "1.8.10-1.0.9" id("org.jlleitschuh.gradle.ktlint") version "11.4.1" } @@ -31,11 +32,11 @@ android { } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "1.8" + jvmTarget = "17" } buildFeatures { compose = true @@ -68,6 +69,9 @@ dependencies { implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.compose.material3:material3") implementation("com.louiscad.splitties:splitties-systemservices:3.0.0") + implementation("com.github.alorma:compose-settings-ui-m3:0.27.0") + implementation("io.github.raamcosta.compose-destinations:core:1.8.42-beta") + ksp("io.github.raamcosta.compose-destinations:ksp:1.8.42-beta") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") diff --git a/app/src/main/java/com/rickyhu/hushkeyboard/MainActivity.kt b/app/src/main/java/com/rickyhu/hushkeyboard/MainActivity.kt index 3944e6d..88ec723 100644 --- a/app/src/main/java/com/rickyhu/hushkeyboard/MainActivity.kt +++ b/app/src/main/java/com/rickyhu/hushkeyboard/MainActivity.kt @@ -7,7 +7,8 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.ui.Modifier -import com.rickyhu.hushkeyboard.ui.home.HomeScreen +import com.ramcosta.composedestinations.DestinationsNavHost +import com.rickyhu.hushkeyboard.ui.NavGraphs import com.rickyhu.hushkeyboard.ui.theme.HushKeyboardTheme class MainActivity : ComponentActivity() { @@ -19,7 +20,7 @@ class MainActivity : ComponentActivity() { modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { - HomeScreen() + DestinationsNavHost(navGraph = NavGraphs.root) } } } diff --git a/app/src/main/java/com/rickyhu/hushkeyboard/ui/home/HomeScreen.kt b/app/src/main/java/com/rickyhu/hushkeyboard/ui/home/HomeScreen.kt index a0a0b78..595db8b 100644 --- a/app/src/main/java/com/rickyhu/hushkeyboard/ui/home/HomeScreen.kt +++ b/app/src/main/java/com/rickyhu/hushkeyboard/ui/home/HomeScreen.kt @@ -43,21 +43,30 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.ramcosta.composedestinations.annotation.Destination +import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.rickyhu.hushkeyboard.R +import com.rickyhu.hushkeyboard.ui.destinations.SettingsScreenDestination import com.rickyhu.hushkeyboard.ui.theme.HushKeyboardTheme import splitties.systemservices.inputMethodManager +@Destination(start = true) +@Composable +fun HomeScreen(navigator: DestinationsNavigator) { + HomeContent(onSettingsClick = { navigator.navigate(SettingsScreenDestination()) }) +} + @OptIn(ExperimentalMaterial3Api::class) @Composable -fun HomeScreen() { +private fun HomeContent( + onSettingsClick: () -> Unit = {} +) { val context = LocalContext.current var text by remember { mutableStateOf("") } Scaffold( floatingActionButton = { - FloatingActionButton( - onClick = {} - ) { + FloatingActionButton(onClick = onSettingsClick) { Icon(Icons.Default.Settings, contentDescription = "Settings") } }, @@ -129,6 +138,6 @@ fun HomeScreen() { @Composable fun HomeScreenPreview() { HushKeyboardTheme { - HomeScreen() + HomeContent() } } diff --git a/app/src/main/java/com/rickyhu/hushkeyboard/ui/settings/SettingsScreen.kt b/app/src/main/java/com/rickyhu/hushkeyboard/ui/settings/SettingsScreen.kt new file mode 100644 index 0000000..b87b79a --- /dev/null +++ b/app/src/main/java/com/rickyhu/hushkeyboard/ui/settings/SettingsScreen.kt @@ -0,0 +1,58 @@ +package com.rickyhu.hushkeyboard.ui.settings + +import android.content.Intent +import android.net.Uri +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.padding +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Info +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.tooling.preview.Preview +import com.alorma.compose.settings.ui.SettingsMenuLink +import com.ramcosta.composedestinations.annotation.Destination +import com.rickyhu.hushkeyboard.ui.theme.HushKeyboardTheme + +@Destination +@Composable +fun SettingsScreen() = SettingsContent() + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +private fun SettingsContent() { + val context = LocalContext.current + + Scaffold( + topBar = { + TopAppBar(title = { Text("Settings") }) + }, + content = { padding -> + Column(modifier = Modifier.padding(padding)) { + SettingsMenuLink( + icon = { Icon(imageVector = Icons.Default.Info, contentDescription = "Info") }, + title = { Text("Version") }, + subtitle = { Text("v0.1.0") }, + onClick = { + val url = "https://github.com/ricky9667/HushKeyboard" + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + context.startActivity(intent) + } + ) + } + } + ) +} + +@Preview +@Composable +fun SettingsScreenPreview() { + HushKeyboardTheme { + SettingsContent() + } +}