Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use navigation-compose, instead of activity #18

Merged
merged 4 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ captures
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/deploymentTargetDropDown.xml
.idea/deploymentTargetSelector.xml
.idea/misc.xml
.idea/androidTestResultsUserPreferences.xml
.idea/appInsightsSettings.xml
Expand Down
1 change: 1 addition & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ dependencyResolutionManagement {
}
}

rootProject.name = "build-logic"
include(":convention")
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ coroutines = "1.6.4"

coil = "1.3.2"

androidx-core = "1.13.1"
androidx-activity = "1.9.0"
androidx-navigation = "2.7.7"

androidx-test-core = "1.5.0"
androidx-test-runner = "1.5.2"
Expand All @@ -40,12 +40,12 @@ compose-material-iconsext = { module = "androidx.compose.material:material-icons
compose-material3-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" }

kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlin-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }

coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }

androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "androidx-navigation" }

androidx-test-core = { module = "androidx.test:core-ktx", version.ref="androidx-test-core" }
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test-runner" }
Expand Down
4 changes: 2 additions & 2 deletions sample/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies {
implementation(projects.material3)

implementation(libs.kotlin.stdlib)
implementation(libs.kotlin.coroutines.android)
implementation(libs.kotlinx.coroutines.android)

implementation(libs.compose.material.material)
implementation(libs.compose.material.iconsext)
Expand All @@ -38,7 +38,7 @@ dependencies {
implementation(libs.compose.ui.util)

implementation(libs.androidx.activity.compose)
implementation(libs.androidx.core)
implementation(libs.androidx.navigation.compose)

implementation(libs.coil.compose)
}
Expand Down
10 changes: 8 additions & 2 deletions sample/android/dependencies/releaseRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ androidx.compose.ui:ui-util-android:1.6.7
androidx.compose.ui:ui-util:1.6.7
androidx.compose.ui:ui:1.6.7
androidx.concurrent:concurrent-futures:1.1.0
androidx.core:core-ktx:1.13.1
androidx.core:core:1.13.1
androidx.core:core-ktx:1.13.0
androidx.core:core:1.13.0
androidx.customview:customview-poolingcontainer:1.0.0
androidx.emoji2:emoji2:1.3.0
androidx.exifinterface:exifinterface:1.3.3
Expand All @@ -60,9 +60,15 @@ androidx.lifecycle:lifecycle-livedata-core:2.6.2
androidx.lifecycle:lifecycle-process:2.6.2
androidx.lifecycle:lifecycle-runtime-ktx:2.6.2
androidx.lifecycle:lifecycle-runtime:2.6.2
androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2
androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.2
androidx.lifecycle:lifecycle-viewmodel:2.6.2
androidx.navigation:navigation-common-ktx:2.7.7
androidx.navigation:navigation-common:2.7.7
androidx.navigation:navigation-compose:2.7.7
androidx.navigation:navigation-runtime-ktx:2.7.7
androidx.navigation:navigation-runtime:2.7.7
androidx.profileinstaller:profileinstaller:1.3.1
androidx.savedstate:savedstate-ktx:1.2.1
androidx.savedstate:savedstate:1.2.1
Expand Down
93 changes: 1 addition & 92 deletions sample/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,104 +20,13 @@

<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@android:style/Theme.Material.Light">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".foundation.PlaceholderBasicSample"
android:exported="true"
android:label="@string/foundation_title_basics">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="io.github.fornewid.sample.SAMPLE_CODE" />
</intent-filter>
</activity>

<activity
android:name=".foundation.PlaceholderFadeSample"
android:exported="true"
android:label="@string/foundation_title_fade">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="io.github.fornewid.sample.SAMPLE_CODE" />
</intent-filter>
</activity>

<activity
android:name=".foundation.PlaceholderShimmerSample"
android:exported="true"
android:label="@string/foundation_title_shimmer">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="io.github.fornewid.sample.SAMPLE_CODE" />
</intent-filter>
</activity>

<activity
android:name=".material.PlaceholderBasicSample"
android:exported="true"
android:label="@string/material_title_basics">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="io.github.fornewid.sample.SAMPLE_CODE" />
</intent-filter>
</activity>

<activity
android:name=".material.PlaceholderFadeSample"
android:exported="true"
android:label="@string/material_title_fade">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="io.github.fornewid.sample.SAMPLE_CODE" />
</intent-filter>
</activity>

<activity
android:name=".material.PlaceholderShimmerSample"
android:exported="true"
android:label="@string/material_title_shimmer">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="io.github.fornewid.sample.SAMPLE_CODE" />
</intent-filter>
</activity>

<activity
android:name=".material3.PlaceholderBasicSample"
android:exported="true"
android:label="@string/material3_title_basics">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="io.github.fornewid.sample.SAMPLE_CODE" />
</intent-filter>
</activity>

<activity
android:name=".material3.PlaceholderFadeSample"
android:exported="true"
android:label="@string/material3_title_fade">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="io.github.fornewid.sample.SAMPLE_CODE" />
</intent-filter>
</activity>

<activity
android:name=".material3.PlaceholderShimmerSample"
android:exported="true"
android:label="@string/material3_title_shimmer">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="io.github.fornewid.sample.SAMPLE_CODE" />
</intent-filter>
</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* Copyright 2024 fornewid
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.fornewid.placeholder.sample

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Divider
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp

private data class Demo(
val title: String,
val destination: Destination,
)

@Composable
fun HomeScreen(onItemClick: (Destination) -> Unit) {
val items: List<Demo> = listOf(
Demo(
title = stringResource(R.string.foundation_title_basics),
destination = Destination.PlaceholderFoundationBasic,
),
Demo(
title = stringResource(R.string.foundation_title_fade),
destination = Destination.PlaceholderFoundationFade,
),
Demo(
title = stringResource(R.string.foundation_title_shimmer),
destination = Destination.PlaceholderFoundationShimmer,
),
Demo(
title = stringResource(R.string.material_title_basics),
destination = Destination.PlaceholderMaterialBasic,
),
Demo(
title = stringResource(R.string.material_title_fade),
destination = Destination.PlaceholderMaterialFade,
),
Demo(
title = stringResource(R.string.material_title_shimmer),
destination = Destination.PlaceholderMaterialShimmer,
),
Demo(
title = stringResource(R.string.material3_title_basics),
destination = Destination.PlaceholderMaterial3Basic,
),
Demo(
title = stringResource(R.string.material3_title_fade),
destination = Destination.PlaceholderMaterial3Fade,
),
Demo(
title = stringResource(R.string.material3_title_shimmer),
destination = Destination.PlaceholderMaterial3Shimmer,
),
)

Scaffold(
topBar = {
TopAppBar(
title = { Text(text = stringResource(R.string.app_name)) },
backgroundColor = MaterialTheme.colors.surface,
)
},
) { contentPadding ->
LazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = contentPadding,
) {
items(
items = items,
contentType = { "Demo" },
) { demo ->
HomeDemoItem(demo, onItemClick = onItemClick)
Divider()
}
}
}
}

@Composable
private fun HomeDemoItem(
demo: Demo,
onItemClick: (Destination) -> Unit,
modifier: Modifier = Modifier,
) {
Column(
verticalArrangement = Arrangement.Center,
modifier = modifier
.fillMaxWidth()
.requiredHeight(48.dp)
.clickable { onItemClick(demo.destination) }
.padding(horizontal = 16.dp),
) {
Text(
text = demo.title,
modifier = Modifier.fillMaxWidth(),
style = MaterialTheme.typography.subtitle1,
)
}
}
Loading
Loading