diff options
author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-04-22 13:55:25 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-04-22 14:55:46 +0100 |
commit | 9c4d01ad6cb1f54511d68a77634343c4c601c1b6 (patch) | |
tree | 4436601eebac47ebf0ded32c5f54967d68841025 /src | |
parent | 4d2c9b6a04cd0b72313a39c3b3a059b28efbbc20 (diff) | |
download | paste-android-9c4d01ad6cb1f54511d68a77634343c4c601c1b6.tar.gz paste-android-9c4d01ad6cb1f54511d68a77634343c4c601c1b6.tar.xz paste-android-9c4d01ad6cb1f54511d68a77634343c4c601c1b6.zip |
Basic minimal hello world application with gradle
Diffstat (limited to 'src')
-rw-r--r-- | src/main/AndroidManifest.xml | 19 | ||||
-rw-r--r-- | src/main/java/MainActivity.kt | 43 | ||||
-rw-r--r-- | src/main/java/ui/theme/Color.kt | 8 | ||||
-rw-r--r-- | src/main/java/ui/theme/Shape.kt | 11 | ||||
-rw-r--r-- | src/main/java/ui/theme/Theme.kt | 38 | ||||
-rw-r--r-- | src/main/java/ui/theme/Type.kt | 15 | ||||
-rw-r--r-- | src/main/res/values/colors.xml | 10 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 3 | ||||
-rw-r--r-- | src/main/res/values/themes.xml | 7 |
9 files changed, 154 insertions, 0 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml new file mode 100644 index 0000000..852d51d --- /dev/null +++ b/src/main/AndroidManifest.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + + <application + android:label="@string/app_name" + android:supportsRtl="true" + android:theme="@style/Theme.Paste"> + <activity + android:name=".MainActivity" + android:exported="true" + android:theme="@style/Theme.Paste"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest> diff --git a/src/main/java/MainActivity.kt b/src/main/java/MainActivity.kt new file mode 100644 index 0000000..3e2b32f --- /dev/null +++ b/src/main/java/MainActivity.kt @@ -0,0 +1,43 @@ +package ski.kramkow.paste + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Surface +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import ski.kramkow.paste.ui.theme.PasteTheme + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + PasteTheme { + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colors.background + ) { + Greeting("World") + } + } + } + } +} + +@Composable +fun Greeting(name: String) { + Text(text = "Hello $name!") +} + +@Preview(showBackground = true) +@Composable +fun DefaultPreview() { + PasteTheme { + Greeting("Android") + } +} + diff --git a/src/main/java/ui/theme/Color.kt b/src/main/java/ui/theme/Color.kt new file mode 100644 index 0000000..e32a30d --- /dev/null +++ b/src/main/java/ui/theme/Color.kt @@ -0,0 +1,8 @@ +package ski.kramkow.paste.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple200 = Color(0xFFBB86FC) +val Purple500 = Color(0xFF6200EE) +val Purple700 = Color(0xFF3700B3) +val Teal200 = Color(0xFF03DAC5) diff --git a/src/main/java/ui/theme/Shape.kt b/src/main/java/ui/theme/Shape.kt new file mode 100644 index 0000000..d3f1ec9 --- /dev/null +++ b/src/main/java/ui/theme/Shape.kt @@ -0,0 +1,11 @@ +package ski.kramkow.paste.ui.theme + +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Shapes +import androidx.compose.ui.unit.dp + +val Shapes = Shapes( + small = RoundedCornerShape(4.dp), + medium = RoundedCornerShape(4.dp), + large = RoundedCornerShape(0.dp) +) diff --git a/src/main/java/ui/theme/Theme.kt b/src/main/java/ui/theme/Theme.kt new file mode 100644 index 0000000..7740e34 --- /dev/null +++ b/src/main/java/ui/theme/Theme.kt @@ -0,0 +1,38 @@ +package ski.kramkow.paste.ui.theme + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material.MaterialTheme +import androidx.compose.material.darkColors +import androidx.compose.material.lightColors +import androidx.compose.runtime.Composable + +private val DarkColorPalette = darkColors( + primary = Purple200, + primaryVariant = Purple700, + secondary = Teal200 +) + +private val LightColorPalette = lightColors( + primary = Purple500, + primaryVariant = Purple700, + secondary = Teal200 +) + +@Composable +fun PasteTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + content: @Composable () -> Unit +) { + val colors = if (darkTheme) { + DarkColorPalette + } else { + LightColorPalette + } + + MaterialTheme( + colors = colors, + typography = Typography, + shapes = Shapes, + content = content + ) +} diff --git a/src/main/java/ui/theme/Type.kt b/src/main/java/ui/theme/Type.kt new file mode 100644 index 0000000..ffebac3 --- /dev/null +++ b/src/main/java/ui/theme/Type.kt @@ -0,0 +1,15 @@ +package ski.kramkow.paste.ui.theme + +import androidx.compose.material.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +val Typography = Typography( + body1 = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp + ) +) diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="purple_200">#FFBB86FC</color> + <color name="purple_500">#FF6200EE</color> + <color name="purple_700">#FF3700B3</color> + <color name="teal_200">#FF03DAC5</color> + <color name="teal_700">#FF018786</color> + <color name="black">#FF000000</color> + <color name="white">#FFFFFFFF</color> +</resources>
\ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml new file mode 100644 index 0000000..8d319d5 --- /dev/null +++ b/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ +<resources> + <string name="app_name">Paste</string> +</resources> diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml new file mode 100644 index 0000000..739ede3 --- /dev/null +++ b/src/main/res/values/themes.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <style name="Theme.Paste" parent="android:Theme.Material.Light.NoActionBar"> + <item name="android:statusBarColor">@color/purple_700</item> + </style> +</resources> |