Skip to content

Commit 5de22d2

Browse files
authored
Add Simple Compose theme in common-ui module (simpledotorg#4714)
* Add common module * Bump Compose version * Bump Material library version * Add compose theme adapter dependency * Add compose dependencies in common module * Add common module as dependency in app module * Move theme related XML files to common module * Add `SimpleThemeAdapter` to fetch theme information from app theme.xml * Add Simple theme variants * Rename private `SimpleTheme` function to `BaseSimpleTheme` * Add lint.xml to `common` module * Add manifest in `common` module to get the theme for Compose preview tooling * Add platform text style and line height style to parsed typography in Simple theme * Rename `common` module to `common-ui` * Update CHANGELOG
1 parent 43a720b commit 5de22d2

40 files changed

+517
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Update Questionnaire form radio button styling
99
- Remove firebase remote config `questionnaires_enabled` logic for loading questionnaire's api.
1010
- Remove DPH/TamilNadu build variant
11+
- Add Simple Compose theme in `common-ui` module
1112

1213
### Fixes
1314

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ dependencies {
420420
implementation(projects.mobiusBase)
421421
implementation(projects.simplePlatform)
422422
implementation(projects.simpleVisuals)
423+
implementation(projects.commonUi)
423424

424425
val composeBom = platform(libs.androidx.compose.bom)
425426
implementation(composeBom)

app/src/main/res/values/theme_attr.xml

Lines changed: 0 additions & 23 deletions
This file was deleted.

common-ui/.gitignore

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

common-ui/build.gradle.kts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
2+
plugins {
3+
id("com.android.library")
4+
id("org.jetbrains.kotlin.android")
5+
}
6+
7+
android {
8+
val compileSdkVersion: Int by rootProject.extra
9+
val minSdkVersion: Int by rootProject.extra
10+
11+
namespace = "org.simple.clinic.common"
12+
compileSdk = compileSdkVersion
13+
14+
defaultConfig {
15+
minSdk = minSdkVersion
16+
17+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18+
consumerProguardFiles("consumer-rules.pro")
19+
}
20+
21+
buildTypes {
22+
release {
23+
isMinifyEnabled = false
24+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
25+
}
26+
}
27+
compileOptions {
28+
sourceCompatibility = JavaVersion.VERSION_17
29+
targetCompatibility = JavaVersion.VERSION_17
30+
}
31+
kotlinOptions {
32+
jvmTarget = JavaVersion.VERSION_17.toString()
33+
}
34+
35+
buildFeatures {
36+
compose = true
37+
}
38+
39+
composeOptions {
40+
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
41+
}
42+
}
43+
44+
dependencies {
45+
implementation(libs.androidx.core.ktx)
46+
implementation(libs.androidx.appcompat)
47+
implementation(libs.material)
48+
implementation(libs.edittext.pinentry)
49+
50+
val composeBom = platform(libs.androidx.compose.bom)
51+
implementation(composeBom)
52+
implementation(libs.androidx.compose.material)
53+
implementation(libs.androidx.compose.material.iconsExtended)
54+
implementation(libs.composeThemeAdapter)
55+
implementation(libs.composeThemeAdapterCore)
56+
implementation(libs.androidx.compose.ui.tooling.preview)
57+
debugImplementation(libs.androidx.compose.ui.tooling)
58+
}

common-ui/consumer-rules.pro

Whitespace-only changes.

common-ui/lint.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<lint>
3+
<issue id="UnusedResources">
4+
<ignore regexp="thanks_green_500" />
5+
<ignore regexp="thanks_green_600" />
6+
<ignore regexp="thanks_teal_500" />
7+
</issue>
8+
</lint>

common-ui/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<application android:theme="@style/Theme.Simple" />
5+
</manifest>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.simple.clinic.common.ui.theme
2+
3+
import androidx.compose.material.Colors
4+
import androidx.compose.material.lightColors
5+
import androidx.compose.runtime.Immutable
6+
import androidx.compose.runtime.staticCompositionLocalOf
7+
import androidx.compose.ui.graphics.Color
8+
9+
@Immutable
10+
data class SimpleColors(
11+
val toolbarPrimary: Color = Color.Unspecified,
12+
val toolbarPrimaryVariant: Color = Color.Unspecified,
13+
val onToolbarPrimary: Color = Color.Unspecified,
14+
val material: Colors = lightColors()
15+
)
16+
17+
internal val LocalSimpleColors = staticCompositionLocalOf { SimpleColors() }

0 commit comments

Comments
 (0)