diff --git a/composeApp/src/androidMain/kotlin/tools/mo3ta/githubactivity/App.android.kt b/composeApp/src/androidMain/kotlin/tools/mo3ta/githubactivity/App.android.kt index b220801..2fa3fc3 100644 --- a/composeApp/src/androidMain/kotlin/tools/mo3ta/githubactivity/App.android.kt +++ b/composeApp/src/androidMain/kotlin/tools/mo3ta/githubactivity/App.android.kt @@ -6,7 +6,7 @@ import android.net.Uri import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.runtime.ExperimentalComposeApi +import androidx.compose.material3.ExperimentalMaterial3Api import tools.mo3ta.githubactivity.theme.MobileTheme class AndroidApp : Application() { @@ -20,7 +20,7 @@ class AndroidApp : Application() { } } -@ExperimentalComposeApi +@ExperimentalMaterial3Api class AppActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { diff --git a/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/App.kt b/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/App.kt index a0597b2..b0ddf77 100644 --- a/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/App.kt +++ b/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/App.kt @@ -1,17 +1,4 @@ package tools.mo3ta.githubactivity -import androidx.compose.runtime.Composable -import cafe.adriel.voyager.navigator.Navigator -import tools.mo3ta.githubactivity.screens.config.ConfigScreen -import tools.mo3ta.githubactivity.theme.CommonTheme - -@Composable -internal fun AppWithCommonTheme() = CommonTheme { - AppContent() -} - -@Composable -internal fun AppContent() = Navigator(ConfigScreen) - internal expect fun openUrl(url: String?) diff --git a/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/AppFiles.kt b/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/AppFiles.kt new file mode 100644 index 0000000..47446b9 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/AppFiles.kt @@ -0,0 +1,14 @@ +package tools.mo3ta.githubactivity + +import androidx.compose.runtime.Composable +import cafe.adriel.voyager.navigator.Navigator +import tools.mo3ta.githubactivity.screens.config.ConfigScreen +import tools.mo3ta.githubactivity.theme.CommonTheme + +@Composable +internal fun AppWithCommonTheme() = CommonTheme { + AppContent() +} + +@Composable +internal fun AppContent() = Navigator(ConfigScreen) diff --git a/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/screens/userDetails/UserDetailsScreen.kt b/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/screens/userDetails/UserDetailsScreen.kt index 1e166c2..6d2b5c7 100644 --- a/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/screens/userDetails/UserDetailsScreen.kt +++ b/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/screens/userDetails/UserDetailsScreen.kt @@ -48,10 +48,7 @@ data class UserDetailsScreen( .verticalScroll(rememberScrollState()) ) { if (uiState.isLoading) { - Loading( - Modifier.fillMaxSize(), - "User Data for ${data.userName}" - ) + Loading(Modifier.fillMaxSize(), "User Data for ${data.userName}") } else { BasicUserData( uiState.userData, diff --git a/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/theme/AppThem.kt b/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/theme/AppThem.kt new file mode 100644 index 0000000..87512b5 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/theme/AppThem.kt @@ -0,0 +1,22 @@ +package tools.mo3ta.githubactivity.theme + +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +internal fun MobileTheme( + content: @Composable() () -> Unit + ) { + AppTheme( + content = content, + appBar = { TopAppBar(title = { Text("Github Activity") }) }) +} + + +@Composable +fun CommonTheme(content: @Composable() () -> Unit) { + AppTheme(content) +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/theme/Theme.kt b/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/theme/Theme.kt index e99af32..3db5ffb 100644 --- a/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/theme/Theme.kt +++ b/composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/theme/Theme.kt @@ -3,16 +3,13 @@ package tools.mo3ta.githubactivity.theme import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.lightColorScheme -import androidx.compose.material3.darkColorScheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Shapes import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar import androidx.compose.material3.Typography +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.compositionLocalOf @@ -56,7 +53,7 @@ private val LightColorScheme = lightColorScheme( surfaceTint = md_theme_light_surfaceTint, outlineVariant = md_theme_light_outlineVariant, scrim = md_theme_light_scrim, -) + ) private val DarkColorScheme = darkColorScheme( primary = md_theme_dark_primary, @@ -88,7 +85,7 @@ private val DarkColorScheme = darkColorScheme( surfaceTint = md_theme_dark_surfaceTint, outlineVariant = md_theme_dark_outlineVariant, scrim = md_theme_dark_scrim, -) + ) private val AppShapes = Shapes( extraSmall = RoundedCornerShape(2.dp), @@ -96,41 +93,30 @@ private val AppShapes = Shapes( medium = RoundedCornerShape(8.dp), large = RoundedCornerShape(16.dp), extraLarge = RoundedCornerShape(32.dp) -) + ) private val AppTypography = Typography( bodyMedium = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Medium, fontSize = 16.sp - ) -) - -internal val LocalThemeIsDark = compositionLocalOf { mutableStateOf(true) } - -@OptIn(ExperimentalMaterial3Api::class) -@Composable -internal fun MobileTheme( - content: @Composable() () -> Unit -) { - AppTheme (content = content , appBar = { TopAppBar(title = { Text("Github Activity") }) }) -} + ) + ) +internal val LocalThemeIsDark = + compositionLocalOf { mutableStateOf(true) } -@Composable -fun CommonTheme( content: @Composable() () -> Unit) { - AppTheme(content) -} @Composable internal fun AppTheme( content: @Composable () -> Unit, - appBar : @Composable () -> Unit = {} -) { + appBar: @Composable () -> Unit = {} + ) { val systemIsDark = isSystemInDarkTheme() - val isDarkState = remember { mutableStateOf(systemIsDark) } + val isDarkState = + remember { mutableStateOf(systemIsDark) } CompositionLocalProvider( LocalThemeIsDark provides isDarkState - ) { + ) { val isDark by isDarkState SystemAppearance(!isDark) MaterialTheme( @@ -138,14 +124,14 @@ internal fun AppTheme( typography = AppTypography, shapes = AppShapes, content = { - Scaffold (topBar = appBar){ + Scaffold(topBar = appBar) { Surface(Modifier.padding(it)) { content() } } }, - ) + ) } }