Skip to content

Commit

Permalink
fix (*) android target (#6)
Browse files Browse the repository at this point in the history
* fix (*) issues with icons
  • Loading branch information
kotlitecture committed Jun 1, 2024
1 parent d450f4b commit c6542b9
Show file tree
Hide file tree
Showing 36 changed files with 228 additions and 93 deletions.
2 changes: 1 addition & 1 deletion processor/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply from: "${project.rootDir}/gradle/kotlin/processor.gradle"

group = 'com.kotlitecture.kotli'
version = '0.1.1'
version = '0.1.2'
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ object MultiplatformComposeTemplateProcessor : BaseTemplateProcessor() {
)
)
state.onApplyRules(
Rules.AppIconsKt,
Rules.AppIconsProviderKt,
ReplaceMarkedText(
text = "import template.",
marker = "import template.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ object Rules {
const val CommonAppSrcDir = "composeApp/src"
const val SharedDesignSrcDir = "shared/design/src"
const val CommonAppMainDir = "${CommonAppSrcDir}/commonMain"
const val CommonAppMainDrawableDir = "${CommonAppMainDir}/composeResources/drawable"
const val AppIconsKt = "${SharedDesignSrcDir}/commonMain/kotlin/shared/design/AppIcons.kt"
const val AppIconsProviderKt = "${SharedDesignSrcDir}/commonMain/kotlin/shared/design/icon/AppIconsProvider.kt"
const val AppKt = "${CommonAppMainDir}/kotlin/kotli/app/App.kt"
const val AppDIKt = "${CommonAppMainDir}/kotlin/kotli/app/di/DI.kt"
const val AppScreenKt = "${CommonAppMainDir}/kotlin/kotli/app/AppScreen.kt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ object ShowcasesProcessor : BaseFeatureProcessor() {
RemoveMarkedLine("ic_nav_showcases"),
RemoveMarkedLine("ShowcasesDestination"),
)
state.onApplyRules(
"${Rules.CommonAppMainDrawableDir}/ic_nav_showcases.svg",
RemoveFile()
)
state.onApplyRules(
Rules.AppNavigationRouterKt,
ReplaceMarkedText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,6 @@ object NavigationBarProcessor : BaseFeatureProcessor() {
RemoveMarkedLine("NavigationCViewModel"),
RemoveMarkedLine("NavigationBarViewModel")
)
state.onApplyRules(
"${Rules.CommonAppMainDrawableDir}/ic_nav_a.svg",
RemoveFile()
)
state.onApplyRules(
"${Rules.CommonAppMainDrawableDir}/ic_nav_b.svg",
RemoveFile()
)
state.onApplyRules(
"${Rules.CommonAppMainDrawableDir}/ic_nav_c.svg",
RemoveFile()
)
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ import org.koin.dsl.module
import shared.core.navigation.NavigationDestination
import shared.core.navigation.NavigationState
import shared.core.navigation.NavigationStrategy
import template.composeapp.generated.resources.Res
import template.composeapp.generated.resources.ic_nav_a
import template.composeapp.generated.resources.ic_nav_b
import template.composeapp.generated.resources.ic_nav_c
import template.composeapp.generated.resources.ic_nav_showcases
import shared.design.icon.AppIconModel
import shared.design.icon.AppIcons

val ProvidesNavigationBarState = module {
single {
Expand All @@ -25,30 +22,30 @@ val ProvidesNavigationBarState = module {
createPage(
navigationState = get(),
destination = ShowcasesDestination,
getActiveIcon = { Res.drawable.ic_nav_showcases },
getInactiveIcon = { Res.drawable.ic_nav_showcases },
getActiveIcon = { AppIcons.school },
getInactiveIcon = { AppIcons.school },
getLabel = { "Showcases" }
),
// end {showcases}
createPage(
navigationState = get(),
destination = NavigationADestination,
getActiveIcon = { Res.drawable.ic_nav_a },
getInactiveIcon = { Res.drawable.ic_nav_a },
getActiveIcon = { AppIcons.wineBar },
getInactiveIcon = { AppIcons.wineBar },
getLabel = { "Page 1" }
),
createPage(
navigationState = get(),
destination = NavigationBDestination,
getActiveIcon = { Res.drawable.ic_nav_b },
getInactiveIcon = { Res.drawable.ic_nav_b },
getActiveIcon = { AppIcons.localDrink },
getInactiveIcon = { AppIcons.localDrink },
getLabel = { "Page 2" }
),
createPage(
navigationState = get(),
destination = NavigationCDestination,
getActiveIcon = { Res.drawable.ic_nav_c },
getInactiveIcon = { Res.drawable.ic_nav_c },
getActiveIcon = { AppIcons.coffee },
getInactiveIcon = { AppIcons.coffee },
getLabel = { "Page 3" }
)
),
Expand All @@ -63,8 +60,8 @@ val ProvidesNavigationBarState = module {
private fun <D> createPage(
navigationState: NavigationState,
destination: NavigationDestination<D>,
getInactiveIcon: () -> Any,
getActiveIcon: () -> Any,
getInactiveIcon: () -> AppIconModel,
getActiveIcon: () -> AppIconModel,
getLabel: @Composable () -> String?,
): NavigationBarPage {
return NavigationBarPage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package kotli.app.feature.theme.toggle

import androidx.compose.runtime.Immutable
import androidx.compose.runtime.Stable
import org.jetbrains.compose.resources.DrawableResource
import shared.core.theme.ThemeData
import shared.design.AppIcons
import shared.design.icon.AppIconModel
import shared.design.icon.AppIcons

/**
* Data class representing theme toggle data.
Expand All @@ -20,10 +20,10 @@ data class ToggleThemeData(
}

@Stable
fun getIcon(): DrawableResource {
fun getIcon(): AppIconModel {
return when {
data.context.dark -> AppIcons.LightMode
else -> AppIcons.DarkMode
data.context.dark -> AppIcons.lightMode
else -> AppIcons.darkMode
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import shared.core.provideViewModel
import shared.core.state.StoreObject
import shared.design.AppIcons
import shared.design.component.AppActionButton
import shared.design.component.AppAlertDialog
import shared.design.component.AppIcon
Expand All @@ -21,6 +20,7 @@ import shared.design.component.AppSpacer16
import shared.design.component.AppText
import shared.design.component.AppTextPrimaryHeader
import shared.design.container.AppFixedTopBarLazyColumn
import shared.design.icon.AppIcons

/**
* Composable function for displaying the showcases screen.
Expand All @@ -36,7 +36,7 @@ fun ShowcasesScreen() {
AppActionButton(
modifier = Modifier
.padding(horizontal = 8.dp),
icon = AppIcons.Info,
icon = AppIcons.info,
onClick = viewModel::onShowHint,
)
},
Expand Down Expand Up @@ -109,7 +109,7 @@ private fun LazyListScope.showcaseItem(
horizontalArrangement = Arrangement.SpaceBetween
) {
AppText(text = showcase.label)
AppIcon(model = AppIcons.ChevronRight)
AppIcon(model = AppIcons.chevronRight)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package shared.design.icon

import androidx.compose.ui.res.painterResource
import shared.design.R

actual fun appIconsProvider() = object : AppIconsProvider {

override val info: AppIconModel
get() = PainterIcon { painterResource(R.drawable.ic_info) }
override val cancel: AppIconModel
get() = PainterIcon { painterResource(R.drawable.ic_cancel) }
override val arrowBack: AppIconModel
get() = PainterIcon { painterResource(R.drawable.ic_arrow_back) }
override val chevronRight: AppIconModel
get() = PainterIcon { painterResource(R.drawable.ic_chevron_right) }
override val lightMode: AppIconModel
get() = PainterIcon { painterResource(R.drawable.ic_light_mode) }
override val darkMode: AppIconModel
get() = PainterIcon { painterResource(R.drawable.ic_dark_mode) }
override val school: AppIconModel
get() = PainterIcon { painterResource(R.drawable.ic_school) }
override val coffee: AppIconModel
get() = PainterIcon { painterResource(R.drawable.ic_coffee) }
override val wineBar: AppIconModel
get() = PainterIcon { painterResource(R.drawable.ic_wine_bar) }
override val localDrink: AppIconModel
get() = PainterIcon { painterResource(R.drawable.ic_local_drink) }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="#e8eaed" android:pathData="M400,880 L0,480l400,-400 71,71 -329,329 329,329 -71,71Z"/>

</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="#e8eaed" android:pathData="m336,680 l144,-144 144,144 56,-56 -144,-144 144,-144 -56,-56 -144,144 -144,-144 -56,56 144,144 -144,144 56,56ZM480,880q-83,0 -156,-31.5T197,763q-54,-54 -85.5,-127T80,480q0,-83 31.5,-156T197,197q54,-54 127,-85.5T480,80q83,0 156,31.5T763,197q54,54 85.5,127T880,480q0,83 -31.5,156T763,763q-54,54 -127,85.5T480,880ZM480,800q134,0 227,-93t93,-227q0,-134 -93,-227t-227,-93q-134,0 -227,93t-93,227q0,134 93,227t227,93ZM480,480Z"/>

</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="#e8eaed" android:pathData="M504,480 L320,296l56,-56 240,240 -240,240 -56,-56 184,-184Z"/>

</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="#e8eaed" android:pathData="M440,720q-117,0 -198.5,-81.5T160,440v-240q0,-33 23.5,-56.5T240,120h500q58,0 99,41t41,99q0,58 -41,99t-99,41h-20v40q0,117 -81.5,198.5T440,720ZM240,320h400v-120L240,200v120ZM440,640q83,0 141.5,-58.5T640,440v-40L240,400v40q0,83 58.5,141.5T440,640ZM720,320h20q25,0 42.5,-17.5T800,260q0,-25 -17.5,-42.5T740,200h-20v120ZM160,840v-80h640v80L160,840ZM440,400Z"/>

</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="#e8eaed" android:pathData="M480,840q-150,0 -255,-105T120,480q0,-150 105,-255t255,-105q14,0 27.5,1t26.5,3q-41,29 -65.5,75.5T444,300q0,90 63,153t153,63q55,0 101,-24.5t75,-65.5q2,13 3,26.5t1,27.5q0,150 -105,255T480,840ZM480,760q88,0 158,-48.5T740,585q-20,5 -40,8t-40,3q-123,0 -209.5,-86.5T364,300q0,-20 3,-40t8,-40q-78,32 -126.5,102T200,480q0,116 82,198t198,82ZM470,490Z"/>

</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="#e8eaed" android:pathData="M440,680h80v-240h-80v240ZM480,360q17,0 28.5,-11.5T520,320q0,-17 -11.5,-28.5T480,280q-17,0 -28.5,11.5T440,320q0,17 11.5,28.5T480,360ZM480,880q-83,0 -156,-31.5T197,763q-54,-54 -85.5,-127T80,480q0,-83 31.5,-156T197,197q54,-54 127,-85.5T480,80q83,0 156,31.5T763,197q54,54 85.5,127T880,480q0,83 -31.5,156T763,763q-54,54 -127,85.5T480,880ZM480,800q134,0 227,-93t93,-227q0,-134 -93,-227t-227,-93q-134,0 -227,93t-93,227q0,134 93,227t227,93ZM480,480Z"/>

</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="#e8eaed" android:pathData="M480,600q50,0 85,-35t35,-85q0,-50 -35,-85t-85,-35q-50,0 -85,35t-35,85q0,50 35,85t85,35ZM480,680q-83,0 -141.5,-58.5T280,480q0,-83 58.5,-141.5T480,280q83,0 141.5,58.5T680,480q0,83 -58.5,141.5T480,680ZM200,520L40,520v-80h160v80ZM920,520L760,520v-80h160v80ZM440,200v-160h80v160h-80ZM440,920v-160h80v160h-80ZM256,310l-101,-97 57,-59 96,100 -52,56ZM748,806 L651,705 704,650 805,747 748,806ZM650,256 L747,155 806,212 706,308 650,256ZM154,748l101,-97 55,53 -97,101 -59,-57ZM480,480Z"/>

</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="#e8eaed" android:pathData="M279,880q-31,0 -53.5,-20.5T200,809l-80,-729h720l-80,729q-3,30 -25.5,50.5T681,880L279,880ZM236,400 L280,800h400l44,-400L236,400ZM226,320h508l16,-160L210,160l16,160ZM480,680q-14,0 -24,-10t-10,-24q0,-15 8.5,-34.5T480,567q17,25 25.5,44.5T514,646q0,14 -10,24t-24,10ZM480,760q48,0 81,-33t33,-81q0,-41 -26.5,-89T480,440q-61,69 -87.5,117T366,646q0,48 33,81t81,33ZM236,800h488,-488Z"/>

</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="#e8eaed" android:pathData="M480,840 L200,688v-240L40,360l440,-240 440,240v320h-80v-276l-80,44v240L480,840ZM480,508 L754,360 480,212 206,360 480,508ZM480,749 L680,641v-151L480,600 280,490v151l200,108ZM480,508ZM480,598ZM480,598Z"/>

</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="#e8eaed" android:pathData="M320,840v-80h120v-164q-86,-14 -143,-80t-57,-156v-240h480v240q0,90 -57,156t-143,80v164h120v80L320,840ZM480,520q56,0 98,-34t56,-86L326,400q14,52 56,86t98,34ZM320,320h320v-120L320,200v120ZM480,520Z"/>

</vector>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import shared.design.icon.AppIconModel

/**
* Button commonly used in the app bars.
Expand All @@ -20,7 +21,7 @@ import androidx.compose.ui.graphics.Color
fun AppActionButton(
modifier: Modifier = Modifier,
onClick: () -> Unit,
icon: Any?,
icon: AppIconModel?,
tint: Color = LocalContentColor.current
) {
IconButton(
Expand Down
Loading

0 comments on commit c6542b9

Please sign in to comment.