├── design-system-frontend ├── app │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── themes.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── xml │ │ │ │ └── network_security_config.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── java │ │ │ └── dev │ │ │ │ └── adambennett │ │ │ │ └── design │ │ │ │ └── system │ │ │ │ └── frontend │ │ │ │ ├── ui │ │ │ │ ├── Color.kt │ │ │ │ ├── Shape.kt │ │ │ │ ├── Type.kt │ │ │ │ └── Theme.kt │ │ │ │ ├── network │ │ │ │ ├── ThemeModel.kt │ │ │ │ └── LocalApi.kt │ │ │ │ ├── MainViewModel.kt │ │ │ │ └── MainActivity.kt │ │ │ └── AndroidManifest.xml │ ├── proguard-rules.pro │ └── build.gradle ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── misc.xml │ ├── gradle.xml │ └── jarRepositories.xml ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle.kts ├── build.gradle ├── gradle.properties ├── gradlew.bat └── gradlew ├── design-system-backend ├── settings.gradle ├── .gitignore ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── resources │ ├── application.conf │ └── logback.xml ├── build.gradle ├── src │ └── Application.kt ├── gradlew.bat └── gradlew ├── README.md └── LICENSE /design-system-frontend/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /design-system-backend/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "dynamic-design-system-backend" 2 | -------------------------------------------------------------------------------- /design-system-frontend/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /design-system-backend/.gitignore: -------------------------------------------------------------------------------- 1 | /.gradle 2 | /.idea 3 | /out 4 | /build 5 | *.iml 6 | *.ipr 7 | *.iws 8 | -------------------------------------------------------------------------------- /design-system-backend/gradle.properties: -------------------------------------------------------------------------------- 1 | ktor_version=1.4.1 2 | kotlin.code.style=official 3 | kotlin_version=1.4.10 4 | logback_version=1.2.1 5 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | design-system-ui 3 | 4 | -------------------------------------------------------------------------------- /design-system-backend/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-backend/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /design-system-frontend/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-frontend/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-frontend/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-frontend/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-frontend/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-frontend/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-frontend/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-frontend/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-frontend/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-frontend/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-frontend/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ditn/dynamic-design-system/HEAD/design-system-frontend/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /design-system-frontend/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /design-system-backend/resources/application.conf: -------------------------------------------------------------------------------- 1 | ktor { 2 | deployment { 3 | port = 8080 4 | port = ${?PORT} 5 | } 6 | application { 7 | modules = [ dev.adambennett.design.system.backend.ApplicationKt.module ] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /design-system-backend/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dynamic Design System 2 | A small demo of providing a Theme for a design system dynamically using a Ktor backend. Article [here](https://adambennett.dev/2020/11/server-driven-theming-in-jetpack-compose/). 3 | 4 | ![Hideous? Yes. Interesting? Also yes.](https://adambennett.dev/img/design-system.gif) 5 | -------------------------------------------------------------------------------- /design-system-frontend/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Nov 11 07:00:35 GMT 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /design-system-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/java/dev/adambennett/design/system/frontend/ui/Color.kt: -------------------------------------------------------------------------------- 1 | package dev.adambennett.design.system.frontend.ui 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | val purple200 = Color(0xFFBB86FC) 6 | val purple500 = Color(0xFF6200EE) 7 | val purple700 = Color(0xFF3700B3) 8 | val teal200 = Color(0xFF03DAC5) 9 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /design-system-frontend/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/java/dev/adambennett/design/system/frontend/ui/Shape.kt: -------------------------------------------------------------------------------- 1 | package dev.adambennett.design.system.frontend.ui 2 | 3 | import androidx.compose.foundation.shape.RoundedCornerShape 4 | import androidx.compose.material.Shapes 5 | import androidx.compose.ui.unit.dp 6 | 7 | val shapes = Shapes( 8 | small = RoundedCornerShape(4.dp), 9 | medium = RoundedCornerShape(4.dp), 10 | large = RoundedCornerShape(0.dp) 11 | ) 12 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | 11 | -------------------------------------------------------------------------------- /design-system-backend/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /design-system-frontend/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "design-system-frontend" 2 | include(":app") 3 | 4 | pluginManagement { 5 | resolutionStrategy { 6 | eachPlugin { 7 | when (requested.id.id) { 8 | "symbol-processing" -> 9 | useModule("com.google.devtools.ksp:symbol-processing:${requested.version}") 10 | } 11 | } 12 | } 13 | 14 | repositories { 15 | gradlePluginPortal() 16 | google() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/java/dev/adambennett/design/system/frontend/network/ThemeModel.kt: -------------------------------------------------------------------------------- 1 | package dev.adambennett.design.system.frontend.network 2 | 3 | import com.squareup.moshi.JsonClass 4 | 5 | @JsonClass(generateAdapter = true) 6 | data class ThemeModel( 7 | val primary: ColorModel, 8 | val primaryVariant: ColorModel, 9 | val onPrimary: ColorModel, 10 | val secondary: ColorModel, 11 | val onSecondary: ColorModel, 12 | val surface: ColorModel, 13 | val onSurface: ColorModel, 14 | val onBackground: ColorModel, 15 | val error: ColorModel, 16 | val onError: ColorModel, 17 | ) 18 | 19 | @JsonClass(generateAdapter = true) 20 | data class ColorModel(val value: Int) 21 | -------------------------------------------------------------------------------- /design-system-frontend/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext { 4 | compose_version = '1.0.0-alpha07' 5 | } 6 | ext.kotlin_version = "1.4.10" 7 | repositories { 8 | google() 9 | jcenter() 10 | } 11 | dependencies { 12 | classpath "com.android.tools.build:gradle:4.2.0-alpha16" 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | 15 | // NOTE: Do not place your application dependencies here; they belong 16 | // in the individual module build.gradle files 17 | } 18 | } 19 | 20 | allprojects { 21 | repositories { 22 | google() 23 | jcenter() 24 | } 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /design-system-frontend/app/proguard-rules.pro: -------------------------------------------------------------------------------- 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 22 | -------------------------------------------------------------------------------- /design-system-frontend/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 20 | 21 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/java/dev/adambennett/design/system/frontend/ui/Type.kt: -------------------------------------------------------------------------------- 1 | package dev.adambennett.design.system.frontend.ui 2 | 3 | import androidx.compose.material.Typography 4 | import androidx.compose.ui.text.TextStyle 5 | import androidx.compose.ui.text.font.FontFamily 6 | import androidx.compose.ui.text.font.FontWeight 7 | import androidx.compose.ui.unit.sp 8 | 9 | // Set of Material typography styles to start with 10 | val typography = Typography( 11 | body1 = TextStyle( 12 | fontFamily = FontFamily.Default, 13 | fontWeight = FontWeight.Normal, 14 | fontSize = 16.sp 15 | ) 16 | /* Other default text styles to override 17 | button = TextStyle( 18 | fontFamily = FontFamily.Default, 19 | fontWeight = FontWeight.W500, 20 | fontSize = 14.sp 21 | ), 22 | caption = TextStyle( 23 | fontFamily = FontFamily.Default, 24 | fontWeight = FontWeight.Normal, 25 | fontSize = 12.sp 26 | ) 27 | */ 28 | ) 29 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/java/dev/adambennett/design/system/frontend/network/LocalApi.kt: -------------------------------------------------------------------------------- 1 | package dev.adambennett.design.system.frontend.network 2 | 3 | import retrofit2.Retrofit 4 | import retrofit2.converter.moshi.MoshiConverterFactory 5 | import retrofit2.http.GET 6 | 7 | /** 8 | * When accessing a local server through an emulator, the URL is different. If you want to test 9 | * this on a real device, switch out the base URL here. 10 | */ 11 | private const val BASE_URL_EMULATOR = "http://10.0.2.2:8080/" 12 | private const val BASE_URL_DEVICE = "http://0.0.0.0:8080/" 13 | 14 | interface LocalApi { 15 | 16 | @GET("/theme") 17 | suspend fun getTheme(): ThemeModel 18 | } 19 | 20 | object ThemeProvider { 21 | 22 | private val retrofit = Retrofit.Builder() 23 | .baseUrl(BASE_URL_EMULATOR) 24 | .addConverterFactory(MoshiConverterFactory.create()) 25 | .build() 26 | 27 | private val api: LocalApi = retrofit.create(LocalApi::class.java) 28 | 29 | suspend fun getTheme(): ThemeModel = api.getTheme() 30 | } 31 | -------------------------------------------------------------------------------- /design-system-frontend/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /design-system-frontend/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /design-system-frontend/app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 21 | 22 |