Skip to content

Commit a9cd2fa

Browse files
committed
fix: Update compose resource implementation
1 parent cbf6ffb commit a9cd2fa

File tree

12 files changed

+29
-10
lines changed

12 files changed

+29
-10
lines changed

composeApp/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,9 @@ sqldelight {
187187
}
188188
}
189189
}
190+
191+
compose.resources {
192+
publicResClass = true
193+
packageOfResClass = "dev.ishubhamsingh.splashy.resources"
194+
generateResClass = always
195+
}

composeApp/src/commonMain/kotlin/dev/ishubhamsingh/splashy/core/navigation/TopLevelScreen.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ import dev.ishubhamsingh.splashy.features.categories.ui.CategoriesTab
6464
import dev.ishubhamsingh.splashy.features.favourites.ui.FavouritesTab
6565
import dev.ishubhamsingh.splashy.features.home.ui.HomeTab
6666
import dev.ishubhamsingh.splashy.features.settings.ui.SettingsScreen
67+
import dev.ishubhamsingh.splashy.resources.Res
68+
import dev.ishubhamsingh.splashy.resources.hat
6769
import dev.ishubhamsingh.splashy.ui.components.SnowFallComponent
6870
import dev.ishubhamsingh.splashy.ui.components.getKamelConfig
6971
import dev.ishubhamsingh.splashy.ui.theme.getLatoRegular
7072
import dev.ishubhamsingh.splashy.ui.theme.getLobsterRegular
7173
import io.kamel.image.config.LocalKamelConfig
72-
import org.jetbrains.compose.resources.DrawableResource
7374
import org.jetbrains.compose.resources.ExperimentalResourceApi
7475
import org.jetbrains.compose.resources.painterResource
7576

@@ -179,7 +180,7 @@ class TopLevelScreen : Screen {
179180
)
180181
if (isChristmasNewYearWeek()) {
181182
Icon(
182-
painterResource(DrawableResource("hat.png")),
183+
painterResource(Res.drawable.hat),
183184
contentDescription = "cap",
184185
tint = Color.Unspecified,
185186
modifier =

composeApp/src/commonMain/kotlin/dev/ishubhamsingh/splashy/ui/theme/Typography.kt

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,36 @@ import androidx.compose.ui.text.font.FontFamily
2222
import androidx.compose.ui.text.font.FontStyle
2323
import androidx.compose.ui.text.font.FontWeight
2424
import androidx.compose.ui.unit.sp
25-
import dev.ishubhamsingh.splashy.core.utils.font
25+
import dev.ishubhamsingh.splashy.resources.Res
26+
import dev.ishubhamsingh.splashy.resources.lato_black
27+
import dev.ishubhamsingh.splashy.resources.lato_bold
28+
import dev.ishubhamsingh.splashy.resources.lato_light
29+
import dev.ishubhamsingh.splashy.resources.lato_regular
30+
import dev.ishubhamsingh.splashy.resources.lato_thin
31+
import dev.ishubhamsingh.splashy.resources.lobster_regular
32+
import org.jetbrains.compose.resources.Font
2633

2734
@Composable
28-
fun getLatoRegular() = FontFamily(font("Lato", "lato_regular", FontWeight.Normal, FontStyle.Normal))
35+
fun getLatoRegular() =
36+
FontFamily(
37+
Font(resource = Res.font.lato_regular, weight = FontWeight.Normal, style = FontStyle.Normal)
38+
)
2939

3040
@Composable
31-
fun getLatoBold() = FontFamily(font("Lato", "lato_bold", FontWeight.Bold, FontStyle.Normal))
41+
fun getLatoBold() = FontFamily(Font(Res.font.lato_bold, FontWeight.Bold, FontStyle.Normal))
3242

3343
@Composable
34-
fun getLatoBlack() = FontFamily(font("Lato", "lato_black", FontWeight.Black, FontStyle.Normal))
44+
fun getLatoBlack() = FontFamily(Font(Res.font.lato_black, FontWeight.Black, FontStyle.Normal))
3545

3646
@Composable
37-
fun getLatoThin() = FontFamily(font("Lato", "lato_thin", FontWeight.Thin, FontStyle.Normal))
47+
fun getLatoThin() = FontFamily(Font(Res.font.lato_thin, FontWeight.Thin, FontStyle.Normal))
3848

3949
@Composable
40-
fun getLatoLight() = FontFamily(font("Lato", "lato_light", FontWeight.Light, FontStyle.Normal))
50+
fun getLatoLight() = FontFamily(Font(Res.font.lato_light, FontWeight.Light, FontStyle.Normal))
4151

4252
@Composable
4353
fun getLobsterRegular() =
44-
FontFamily(font("Lobster", "lobster_regular", FontWeight.Normal, FontStyle.Normal))
54+
FontFamily(Font(Res.font.lobster_regular, FontWeight.Normal, FontStyle.Normal))
4555

4656
@Composable
4757
fun getTypography(): Typography {

0 commit comments

Comments
 (0)