From 3e48b293b067483a93a33d56d6cf1b6f96e6a30f Mon Sep 17 00:00:00 2001 From: greenart7c3 <115044884+greenart7c3@users.noreply.github.com> Date: Mon, 10 Jul 2023 16:04:06 -0300 Subject: [PATCH] create ThemeViewModel using viewModel contructor --- .../main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt index abeb8dd52..7a5b04b8f 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt @@ -58,10 +58,9 @@ class MainActivity : AppCompatActivity() { val appLocale: LocaleListCompat = LocaleListCompat.forLanguageTags(language) AppCompatDelegate.setApplicationLocales(appLocale) } - val themeViewModel = ThemeViewModel() - themeViewModel.onChange(LocalPreferences.getTheme()) - setContent { + val themeViewModel: ThemeViewModel = viewModel() + themeViewModel.onChange(LocalPreferences.getTheme()) AmethystTheme(themeViewModel) { // A surface container using the 'background' color from the theme Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background) {