Skip to content

Commit b6997fb

Browse files
authored
Merge pull request #434 from code-payments/chore/move-theme-out-of-app
chore: move theme out of app and into :common:theme
2 parents c29fb3a + fb5d541 commit b6997fb

File tree

21 files changed

+78
-30
lines changed

21 files changed

+78
-30
lines changed

api/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ android {
6969
}
7070

7171
dependencies {
72-
implementation(project(":common"))
72+
implementation(project(":common:resources"))
7373

7474
implementation(Libs.rxjava)
7575
implementation(Libs.kotlinx_coroutines_core)

app/build.gradle.kts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import com.android.SdkConstants.FN_LOCAL_PROPERTIES
2-
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
31
import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension
42
import org.jetbrains.kotlin.cli.common.toBooleanLenient
5-
import java.io.FileInputStream
6-
import java.io.InputStreamReader
7-
import java.util.Properties
83

94
plugins {
105
id(Plugins.android_application)
@@ -55,8 +50,6 @@ android {
5550

5651
buildFeatures {
5752
buildConfig = true
58-
viewBinding = true
59-
dataBinding = true
6053
compose = true
6154
}
6255

@@ -121,7 +114,8 @@ dependencies {
121114
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
122115

123116
implementation(project(":api"))
124-
implementation(project(":common"))
117+
implementation(project(":common:resources"))
118+
implementation(project(":common:theme"))
125119

126120
//standard libraries
127121
implementation(Libs.kotlinx_collections_immutable)
@@ -144,7 +138,7 @@ dependencies {
144138
testImplementation(Libs.hilt_android_test)
145139
kaptTest(Libs.hilt_android_compiler)
146140

147-
androidTestImplementation("io.mockk:mockk:1.13.5")
141+
androidTestImplementation("io.mockk:mockk:1.13.11")
148142

149143
//Jetpack compose
150144
implementation(platform(Libs.compose_bom))

app/src/main/java/com/getcode/view/login/BaseAccessKeyViewModel.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.getcode.manager.SessionManager
1717
import com.getcode.manager.TopBarManager
1818
import com.getcode.network.repository.TransactionRepository
1919
import com.getcode.network.repository.decodeBase64
20+
import com.getcode.theme.R as themeR
2021
import com.getcode.theme.Brand
2122
import com.getcode.theme.Transparent
2223
import com.getcode.theme.White
@@ -242,7 +243,7 @@ abstract class BaseAccessKeyViewModel(
242243
textPaint.color = color
243244
textPaint.textSize = sizePx.toFloat()
244245
textPaint.typeface = Typeface.create(
245-
resources.getFont(R.font.avenir_next_demi),
246+
resources.getFont(themeR.font.avenir_next_demi),
246247
Typeface.BOLD
247248
)
248249

@@ -308,4 +309,4 @@ abstract class BaseAccessKeyViewModel(
308309
else -> getSomethingWentWrongError()
309310
}.let { m -> TopBarManager.showMessage(m) }
310311
}
311-
}
312+
}

app/src/main/java/com/getcode/view/main/account/AccountFaq.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.getcode.view.main.account
33
import androidx.compose.foundation.layout.Arrangement
44
import androidx.compose.foundation.layout.Column
55
import androidx.compose.foundation.layout.PaddingValues
6-
import androidx.compose.foundation.layout.padding
76
import androidx.compose.foundation.lazy.LazyColumn
87
import androidx.compose.foundation.lazy.items
98
import androidx.compose.material.Text
@@ -14,7 +13,7 @@ import androidx.compose.ui.text.font.FontWeight
1413
import androidx.compose.ui.tooling.preview.Preview
1514
import androidx.compose.ui.unit.sp
1615
import androidx.lifecycle.viewmodel.compose.viewModel
17-
import com.getcode.R
16+
import com.getcode.theme.R as themeR
1817
import com.getcode.theme.CodeTheme
1918
import com.getcode.theme.White
2019
import com.getcode.ui.components.MarkdownText
@@ -43,7 +42,7 @@ fun AccountFaq(
4342
)
4443
MarkdownText(
4544
markdown = faqResponse.answer,
46-
fontResource = R.font.avenir_next_demi,
45+
fontResource = themeR.font.avenir_next_demi,
4746
style = CodeTheme.typography.body1.copy(
4847
lineHeight = 20.sp,
4948
),
File renamed without changes.
File renamed without changes.

common/theme/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

common/theme/build.gradle.kts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
plugins {
2+
id(Plugins.android_library)
3+
id(Plugins.kotlin_android)
4+
}
5+
6+
android {
7+
namespace = "com.getcode.theme"
8+
compileSdk = Android.compileSdkVersion
9+
defaultConfig {
10+
minSdk = Android.minSdkVersion
11+
targetSdk = Android.targetSdkVersion
12+
buildToolsVersion = Android.buildToolsVersion
13+
testInstrumentationRunner = Android.testInstrumentationRunner
14+
}
15+
16+
kotlinOptions {
17+
jvmTarget = Versions.java
18+
freeCompilerArgs += listOf(
19+
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
20+
"-Xuse-experimental=kotlinx.coroutines.FlowPreview",
21+
"-opt-in=kotlin.ExperimentalUnsignedTypes",
22+
"-opt-in=kotlin.RequiresOptIn"
23+
)
24+
}
25+
26+
java {
27+
toolchain {
28+
languageVersion.set(JavaLanguageVersion.of(Versions.java))
29+
}
30+
}
31+
32+
compileOptions {
33+
sourceCompatibility = JavaVersion.VERSION_17
34+
targetCompatibility = JavaVersion.VERSION_17
35+
}
36+
37+
kotlin {
38+
jvmToolchain(17)
39+
}
40+
41+
buildFeatures {
42+
buildConfig = true
43+
compose = true
44+
}
45+
46+
composeOptions {
47+
kotlinCompilerExtensionVersion = Versions.compose_compiler
48+
}
49+
}
50+
51+
dependencies {
52+
implementation(platform(Libs.compose_bom))
53+
implementation(Libs.compose_ui)
54+
debugImplementation(Libs.compose_ui_tools)
55+
implementation(Libs.compose_ui_tools_preview)
56+
implementation(Libs.compose_material)
57+
implementation(Libs.compose_accompanist)
58+
implementation(Libs.timber)
59+
}

app/src/main/java/com/getcode/theme/Color.kt renamed to common/theme/src/main/kotlin/com/getcode/theme/Color.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ val topNotification = Color(0xFF4f49ce)
3535
val topNeutral = Color(0xFF747474)
3636
val topSuccess = Brand
3737

38-
39-
40-
4138
val textSelectionColors = TextSelectionColors(
4239
handleColor = White,
4340
backgroundColor = BrandLight.copy(alpha = 0.4f)
44-
)
41+
)

app/src/main/java/com/getcode/theme/Dimens.kt renamed to common/theme/src/main/kotlin/com/getcode/theme/Dimens.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import androidx.compose.runtime.staticCompositionLocalOf
77
import androidx.compose.ui.platform.LocalConfiguration
88
import androidx.compose.ui.unit.Dp
99
import androidx.compose.ui.unit.dp
10-
import com.getcode.BuildConfig
10+
import com.getcode.theme.BuildConfig
1111

1212
val topBarHeight = 56.dp
1313

@@ -206,4 +206,4 @@ data class GridDimensionSet(
206206
val x15: Dp,
207207
val x16: Dp,
208208
val x17: Dp,
209-
)
209+
)

app/src/main/java/com/getcode/theme/Type.kt renamed to common/theme/src/main/kotlin/com/getcode/theme/Type.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ package com.getcode.theme
22

33
import androidx.compose.material.Typography
44
import androidx.compose.runtime.Composable
5-
import androidx.compose.ui.text.ExperimentalTextApi
6-
import androidx.compose.ui.text.PlatformTextStyle
75
import androidx.compose.ui.text.TextStyle
86
import androidx.compose.ui.text.font.Font
97
import androidx.compose.ui.text.font.FontFamily
10-
import androidx.compose.ui.text.font.FontVariation
118
import androidx.compose.ui.text.font.FontWeight
129
import androidx.compose.ui.text.style.TextAlign
1310
import androidx.compose.ui.unit.sp
14-
import com.getcode.R
1511

1612
private val Avenir = FontFamily(
1713
Font(R.font.avenir_next_regular, FontWeight.Thin),
@@ -120,4 +116,4 @@ val Typography.displayLarge: TextStyle
120116
@Composable get() = h1.copy(fontSize = 55.sp)
121117

122118
fun TextStyle.withRobotoMono(weight: FontWeight? = this.fontWeight) = with(RobotoMono, weight)
123-
fun TextStyle.with(fontFamily: FontFamily, weight: FontWeight? = this.fontWeight): TextStyle = copy(fontFamily = fontFamily, fontWeight = weight)
119+
fun TextStyle.with(fontFamily: FontFamily, weight: FontWeight? = this.fontWeight): TextStyle = copy(fontFamily = fontFamily, fontWeight = weight)

app/src/main/java/com/getcode/theme/WindowSizeClass.kt renamed to common/theme/src/main/kotlin/com/getcode/theme/WindowSizeClass.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.content.res.Configuration
44
import androidx.compose.runtime.Composable
55
import androidx.compose.runtime.remember
66
import androidx.compose.ui.platform.LocalConfiguration
7-
import com.getcode.BuildConfig
7+
import com.getcode.theme.BuildConfig
88
import timber.log.Timber
99

1010
data class DeviceWindowSizeClass internal constructor(
@@ -40,4 +40,4 @@ fun rememberWindowSizeClass(
4040
Timber.d("dimens:: width = { dp: $screenWidthDp, class: ${it.widthSizeClass.name} }, height = { dp:$screenHeightDp, class: ${it.heightSizeClass.name} }")
4141
}
4242
}
43-
}
43+
}

settings.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ include ':model'
22
include ':api'
33
include ':app'
44
include ':ed25519'
5-
include ':common'
6-
rootProject.name = "Code"
5+
include ':common:resources'
6+
include ':common:theme'
7+
rootProject.name = "Code"

0 commit comments

Comments
 (0)