Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Add actual code
Browse files Browse the repository at this point in the history
  • Loading branch information
Omico committed Mar 30, 2024
1 parent f6aa93e commit ce10cc7
Show file tree
Hide file tree
Showing 17 changed files with 234 additions and 0 deletions.
17 changes: 17 additions & 0 deletions build-logic/gradm/gradm.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
versions:
androidx:
activity: "1.9.0-beta01"
compose.multiplatform: "1.6.1"
consensus: "0.9.0"
gradle: "8.7"
kotlin: "1.9.23"
plugins:
android: "8.2.2"
gradle.enterprise: "3.16.2"
spotless: "6.25.0"

repositories:
jetbrainsCompose:
url: "https://maven.pkg.jetbrains.space/public/p/compose/dev"
omico:
google:
mavenCentral:
gradlePluginPortal:

plugins:
gradlePluginPortal:
com.diffplug.spotless: ${versions.plugins.spotless}
com.gradle.enterprise: ${versions.plugins.gradle.enterprise}
org.jetbrains.compose: ${versions.compose.multiplatform}
omico:
me.omico.consensus.api: ${versions.consensus}
me.omico.consensus.git: ${versions.consensus}
me.omico.consensus.spotless: ${versions.consensus}

dependencies:
google:
androidx.activity:
activity-compose:
alias: androidx.activity.compose
version: ${versions.androidx.activity}
com.android.tools.build:
gradle:
alias: androidGradlePlugin
version: ${versions.plugins.android}
mavenCentral:
org.jetbrains.kotlin:
kotlin-gradle-plugin:
Expand Down
2 changes: 2 additions & 0 deletions build-logic/project/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ plugins {
}

dependencies {
implementation(androidGradlePlugin)
implementation(com.diffplug.spotless)
implementation(gradmGeneratedJar)
implementation(kotlinGradlePlugin)
implementation(me.omico.consensus.api)
implementation(me.omico.consensus.dsl)
implementation(me.omico.consensus.git)
implementation(me.omico.consensus.spotless)
implementation(org.jetbrains.compose)
}
1 change: 1 addition & 0 deletions gpi/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
31 changes: 31 additions & 0 deletions gpi/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
plugins {
kotlin("android")
id("com.android.application")
}

kotlin {
jvmToolchain(11)
}

android {
namespace = "me.omico.gpi.android"
defaultConfig {
compileSdk = 34
targetSdk = 34
minSdk = 21
}
buildFeatures {
compose = true
}
kotlinOptions {
jvmTarget = "11"
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.11"
}
}

dependencies {
implementation(project(":gpi-shared"))
implementation(androidx.activity.compose)
}
24 changes: 24 additions & 0 deletions gpi/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:enableOnBackInvokedCallback="true"
tools:targetApi="tiramisu">
<profileable android:shell="true" />
<activity
android:name=".MainActivity"
android:configChanges="colorMode|density|fontScale|fontWeightAdjustment|grammaticalGender|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
android:exported="true"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
15 changes: 15 additions & 0 deletions gpi/android/src/main/kotlin/me/omico/gpi/android/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package me.omico.gpi.android

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import me.omico.gpi.shared.App

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
App()
}
}
}
1 change: 1 addition & 0 deletions gpi/desktop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
17 changes: 17 additions & 0 deletions gpi/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
kotlin("jvm")
id("org.jetbrains.compose")
}

compose {
desktop {
application {
mainClass = "me.omico.gpi.desktop.DesktopKt"
}
}
}

dependencies {
implementation(project(":gpi-shared"))
implementation(compose.desktop.currentOs)
}
10 changes: 10 additions & 0 deletions gpi/desktop/src/main/kotlin/me/omico/gpi/desktop/Desktop.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package me.omico.gpi.desktop

import androidx.compose.ui.window.singleWindowApplication
import me.omico.gpi.shared.App

fun main() {
singleWindowApplication {
App()
}
}
1 change: 1 addition & 0 deletions gpi/shared/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
29 changes: 29 additions & 0 deletions gpi/shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
id("com.android.library")
}

kotlin {
androidTarget {
jvmToolchain(11)
}

jvm("desktop")

sourceSets {
commonMain {
dependencies {
implementation(compose.material3)
}
}
}
}

android {
namespace = "me.omico.gpi.shared"
defaultConfig {
compileSdk = 34
minSdk = 21
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package me.omico.gpi.shared

import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily

actual val FontFamily_IndieFlower: FontFamily =
FontFamily(
Font(resId = R.font.indie_flower_regular),
)
Binary file not shown.
66 changes: 66 additions & 0 deletions gpi/shared/src/commonMain/kotlin/me/omico/gpi/shared/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package me.omico.gpi.shared

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.width
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp

@Composable
fun App() {
val defaultTypography = MaterialTheme.typography
val indieFlowerTypography = remember {
defaultTypography.copy(
displayLarge = defaultTypography.displayLarge.copy(fontFamily = FontFamily_IndieFlower),
displayMedium = defaultTypography.displayMedium.copy(fontFamily = FontFamily_IndieFlower),
displaySmall = defaultTypography.displaySmall.copy(fontFamily = FontFamily_IndieFlower),
headlineLarge = defaultTypography.headlineLarge.copy(fontFamily = FontFamily_IndieFlower),
headlineMedium = defaultTypography.headlineMedium.copy(fontFamily = FontFamily_IndieFlower),
headlineSmall = defaultTypography.headlineSmall.copy(fontFamily = FontFamily_IndieFlower),
titleLarge = defaultTypography.titleLarge.copy(fontFamily = FontFamily_IndieFlower),
titleMedium = defaultTypography.titleMedium.copy(fontFamily = FontFamily_IndieFlower),
titleSmall = defaultTypography.titleSmall.copy(fontFamily = FontFamily_IndieFlower),
bodyLarge = defaultTypography.bodyLarge.copy(fontFamily = FontFamily_IndieFlower),
bodyMedium = defaultTypography.bodyMedium.copy(fontFamily = FontFamily_IndieFlower),
bodySmall = defaultTypography.bodySmall.copy(fontFamily = FontFamily_IndieFlower),
labelLarge = defaultTypography.labelLarge.copy(fontFamily = FontFamily_IndieFlower),
labelMedium = defaultTypography.labelMedium.copy(fontFamily = FontFamily_IndieFlower),
labelSmall = defaultTypography.labelSmall.copy(fontFamily = FontFamily_IndieFlower),
)
}

var currentTypography by remember { mutableStateOf(defaultTypography) }
MaterialTheme(typography = currentTypography) {
AlertDialog(
onDismissRequest = { },
title = { Text("Select Typography") },
text = {
Row {
Button(
onClick = { currentTypography = defaultTypography },
content = { Text("Default") },
)
Spacer(modifier = Modifier.width(8.dp))
Button(
onClick = { currentTypography = indieFlowerTypography },
content = { Text("Indie Flower") },
)
}
},
confirmButton = { },
dismissButton = { },
)
}
}

expect val FontFamily_IndieFlower: FontFamily
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package me.omico.gpi.shared

import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.platform.Font

actual val FontFamily_IndieFlower: FontFamily =
FontFamily(
Font(resource = "font/indie_flower_regular.ttf"),
)
Binary file not shown.
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
android.useAndroidX=true

org.gradle.caching=true
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -XX:+UseParallelGC
org.gradle.kotlin.dsl.allWarningsAsErrors=true
Expand Down

0 comments on commit ce10cc7

Please sign in to comment.