Explorar el Código

仓库初始化

#Suyghur hace 3 años
padre
commit
ad3b7152e0

+ 30 - 2
app/build.gradle

@@ -24,6 +24,11 @@ android {
         }
     }
 
+    buildFeatures {
+        viewBinding true
+        compose true
+        buildConfig false
+    }
     signingConfigs {
         config {
             keyAlias keystoreProperties['keyAlias']
@@ -32,7 +37,6 @@ android {
             storePassword keystoreProperties['storePassword']
         }
     }
-
     buildTypes {
         debug {
             minifyEnabled false
@@ -50,18 +54,42 @@ android {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
+    composeOptions {
+        kotlinCompilerExtensionVersion compose_version
+        kotlinCompilerVersion kotlin_version
+    }
     kotlinOptions {
         jvmTarget = '1.8'
+        useIR = true
+    }
+    packagingOptions {
+        resources {
+            excludes += '/META-INF/{AL2.0,LGPL2.1}'
+        }
     }
 }
 
 dependencies {
+    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
+
+    implementation project(':flutter')
+
     // ktx
     api rootProject.ext.ktxLibs
     // jetpack
     api rootProject.ext.jetpackLibs
     // ui
     api rootProject.ext.uiLibs
+
+    implementation "androidx.compose.material:material:$compose_version"
+    implementation 'androidx.activity:activity-compose:1.4.0'
+    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
+    implementation "androidx.compose.ui:ui:$compose_version"
+    implementation "androidx.compose.ui:ui-tooling:$compose_version"
+    implementation "androidx.compose.runtime:runtime:$compose_version"
+    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
+    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0"
+
+    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
     debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
-    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
 }

+ 29 - 3
app/src/main/java/com/yyxx/lab/DemoActivity.kt

@@ -1,9 +1,14 @@
 package com.yyxx.lab
 
-import android.graphics.Color
-import android.graphics.drawable.ColorDrawable
 import android.os.Bundle
+import androidx.activity.compose.setContent
 import androidx.appcompat.app.AppCompatActivity
+import androidx.compose.material.MaterialTheme
+import androidx.compose.material.Surface
+import androidx.compose.material.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.tooling.preview.Preview
+import com.yyxx.lab.ui.theme.Lab4AndroidTheme
 
 /**
  * @author #Suyghur.
@@ -13,6 +18,27 @@ class DemoActivity : AppCompatActivity() {
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
-        window.setBackgroundDrawable(ColorDrawable(Color.WHITE))
+        setContent {
+            Lab4AndroidTheme {
+                Surface(color = MaterialTheme.colors.background) {
+                    DemoPage()
+                }
+            }
+        }