Skip to content

Commit

Permalink
Merge pull request #40 from ImaginativeShohag/upgrade-to-material3
Browse files Browse the repository at this point in the history
Migrate to Material 3
  • Loading branch information
ImaginativeShohag authored Jul 7, 2024
2 parents 9d4e0ed + 50f164e commit 5a9c390
Show file tree
Hide file tree
Showing 193 changed files with 5,159 additions and 5,233 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.jar filter=lfs diff=lfs merge=lfs -text
8 changes: 5 additions & 3 deletions .github/workflows/build-beta-upload-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ jobs:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
lfs: 'true'

- name: Set up ruby env
uses: ruby/setup-ruby@v1
Expand All @@ -27,7 +29,7 @@ jobs:

# Set up your GitHub Actions workflow with a specific version of Java
- name: Setup Java JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
Expand Down Expand Up @@ -59,7 +61,7 @@ jobs:
GOOGLE_PLAY_SERVICE_ACCOUNT_KEY: ${{ steps.service_account_json_file.outputs.filePath }}

- name: Upload build artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: assets
path: |
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/build-production-upload-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
lfs: 'true'

- name: Set up ruby env
uses: ruby/setup-ruby@v1
Expand All @@ -24,7 +26,7 @@ jobs:

# Set up your GitHub Actions workflow with a specific version of Java
- name: Setup Java JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
Expand Down Expand Up @@ -56,7 +58,7 @@ jobs:
GOOGLE_PLAY_SERVICE_ACCOUNT_KEY: ${{ steps.service_account_json_file.outputs.filePath }}

- name: Upload build artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: assets
path: |
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
lfs: 'true'

- name: Initialize local properties
env:
Expand All @@ -69,7 +71,7 @@ jobs:

# Set up your GitHub Actions workflow with a specific version of Java
- name: Setup Java JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ktlint_with_reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ jobs:
- name: Clone repo
uses: actions/checkout@master
with:
lfs: 'true'
fetch-depth: 1
- name: ktlint
uses: ScaCap/action-ktlint@master
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
android: true
ktlint_version: 1.3.1
custom_rule_path: spotless/ktlint/ktlint-compose-0.4.5-all.jar
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ lint/tmp/
*.hprof

# IntelliJ project icon
!.idea/icon.svg
!.idea/icon.svg
!.idea/ktlint-plugin.xml
12 changes: 12 additions & 0 deletions .idea/ktlint-plugin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Feel free to request features or suggestions for improvements.
- Hilt
- Everywhere dark mode support
- A lot of Ready to use compositions
- Material 3
- Gradle Kotlin DSL
- CI/CD
- ktlint
Expand Down Expand Up @@ -80,7 +81,7 @@ Feel free to request features or suggestions for improvements.

- Migrate to Material 3
- [x] CMS
- [ ] Full app
- [x] Full app
- [ ] Add accompanist WebView
- [ ] x, y, z translation simulation
- [ ] Shadow manipulation with device gyroscope
Expand All @@ -98,6 +99,8 @@ Feel free to request features or suggestions for improvements.
- [x] Check map example issue: on click freeze
- [ ] New: File browser using MediaStore
- [ ] Get sidebar from Emudi app (https://www.youtube.com/watch?v=HNSKJIQtb4c)
- [ ] Update `popBackStack()`
- [ ] Migrate ExoPlayer: https://developer.android.com/media/media3/exoplayer/migration-guide

# Note

Expand Down
5 changes: 2 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ android {
minSdk = BuildConfigConst.minSdk
targetSdk = BuildConfigConst.targetSdk
versionCode = (findProperty("android.injected.version.code") as? String)?.toIntOrNull() ?: 1
versionName = "6.0.0.${getCurrentDateAsYYMMDD()}" // Major.Minor.Patch.YYMMDD
versionName = "7.0.0.${getCurrentDateAsYYMMDD()}" // Major.Minor.Patch.YYMMDD
vectorDrawables.useSupportLibrary = true

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -87,7 +87,7 @@ android {

// Enable experimental compose APIs
freeCompilerArgs =
freeCompilerArgs + "-opt-in=androidx.compose.material.ExperimentalMaterialApi"
freeCompilerArgs + "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api"
freeCompilerArgs =
freeCompilerArgs + "-opt-in=androidx.compose.animation.ExperimentalAnimationApi"
freeCompilerArgs =
Expand Down Expand Up @@ -164,7 +164,6 @@ dependencies {
implementation(Libs.AndroidX.Compose.foundation)
implementation(Libs.AndroidX.Compose.layout)
// Material Design
implementation(Libs.AndroidX.Compose.material)
implementation(Libs.AndroidX.Compose.material3)
implementation(Libs.AndroidX.Compose.material3WindowSizeClass)
// Material design icons
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/org/imaginativeworld/whynotcompose/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ import org.imaginativeworld.whynotcompose.utils.onesignal.MyNotificationWillShow
import timber.log.Timber

@HiltAndroidApp
class App : Application(), OnMapsSdkInitializedCallback {

class App :
Application(),
OnMapsSdkInitializedCallback {
override fun onCreate() {
super.onCreate()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

package org.imaginativeworld.whynotcompose.models

data class ListItem(
data class ListItemModel(
val id: Int,
val name: String,
val image: String = "https://picsum.photos/seed/$id/128/128"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ package org.imaginativeworld.whynotcompose.repositories
import org.imaginativeworld.whynotcompose.base.models.User
import org.imaginativeworld.whynotcompose.base.models.github.GithubRepo
import org.imaginativeworld.whynotcompose.base.models.github.Owner
import org.imaginativeworld.whynotcompose.models.ListItem
import org.imaginativeworld.whynotcompose.models.ListItemModel

object MockData {
val dummyUser = User(
Expand All @@ -38,20 +38,20 @@ object MockData {
)

val dummyListItem = listOf(
ListItem(id = 1, name = "Cupcake"),
ListItem(id = 2, name = "Donut"),
ListItem(id = 3, name = "Eclair"),
ListItem(id = 4, name = "Froyo"),
ListItem(id = 5, name = "Gingerbread"),
ListItem(id = 6, name = "Honeycomb"),
ListItem(id = 7, name = "Ice cream sandwich"),
ListItem(id = 8, name = "Jelly bean"),
ListItem(id = 9, name = "KitKat"),
ListItem(id = 10, name = "Lollipop"),
ListItem(id = 11, name = "Marshmallow"),
ListItem(id = 12, name = "Nougat"),
ListItem(id = 13, name = "Oreo"),
ListItem(id = 14, name = "Pie")
ListItemModel(id = 1, name = "Cupcake"),
ListItemModel(id = 2, name = "Donut"),
ListItemModel(id = 3, name = "Eclair"),
ListItemModel(id = 4, name = "Froyo"),
ListItemModel(id = 5, name = "Gingerbread"),
ListItemModel(id = 6, name = "Honeycomb"),
ListItemModel(id = 7, name = "Ice cream sandwich"),
ListItemModel(id = 8, name = "Jelly bean"),
ListItemModel(id = 9, name = "KitKat"),
ListItemModel(id = 10, name = "Lollipop"),
ListItemModel(id = 11, name = "Marshmallow"),
ListItemModel(id = 12, name = "Nougat"),
ListItemModel(id = 13, name = "Oreo"),
ListItemModel(id = 14, name = "Pie")
)

val dummyGithubRepo = GithubRepo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,31 @@ package org.imaginativeworld.whynotcompose.ui.compositions

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Snackbar
import androidx.compose.material.SnackbarData
import androidx.compose.material.SnackbarDefaults
import androidx.compose.material.SnackbarHost
import androidx.compose.material.SnackbarHostState
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Snackbar
import androidx.compose.material3.SnackbarData
import androidx.compose.material3.SnackbarDefaults
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

@Composable
fun CustomSnackbarHost(state: SnackbarHostState) {
SnackbarHost(state) { data ->
fun CustomSnackbarHost(
state: SnackbarHostState,
modifier: Modifier = Modifier
) {
SnackbarHost(state, modifier) { data ->
CustomSnackbar(
modifier = Modifier,
snackbarData = data,
backgroundColor = MaterialTheme.colors.onBackground
backgroundColor = MaterialTheme.colorScheme.onBackground
)
}
}
Expand All @@ -65,12 +66,11 @@ fun CustomSnackbar(
modifier: Modifier = Modifier,
actionOnNewLine: Boolean = false,
shape: Shape = MaterialTheme.shapes.small,
backgroundColor: Color = SnackbarDefaults.backgroundColor,
contentColor: Color = MaterialTheme.colors.surface,
actionColor: Color = SnackbarDefaults.primaryActionColor,
elevation: Dp = 6.dp
backgroundColor: Color = SnackbarDefaults.color,
contentColor: Color = MaterialTheme.colorScheme.surface,
actionColor: Color = SnackbarDefaults.actionColor
) {
val actionLabel = snackbarData.actionLabel
val actionLabel = snackbarData.visuals.actionLabel
val actionComposable: (@Composable () -> Unit)? = if (actionLabel != null) {
@Composable {
TextButton(
Expand All @@ -87,15 +87,14 @@ fun CustomSnackbar(
content = {
Text(
modifier = Modifier.fillMaxWidth(),
text = snackbarData.message,
text = snackbarData.visuals.message,
textAlign = TextAlign.Center
)
},
action = actionComposable,
actionOnNewLine = actionOnNewLine,
shape = shape,
backgroundColor = backgroundColor,
contentColor = contentColor,
elevation = elevation
containerColor = backgroundColor,
contentColor = contentColor
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
package org.imaginativeworld.whynotcompose.ui.screens

import androidx.compose.foundation.background
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -46,23 +46,24 @@ fun MainScreen(

@Preview
@Composable
fun MainScreenSkeletonPreview() {
private fun MainScreenSkeletonPreview() {
AppTheme {
MainScreenSkeleton(
updateUiThemeMode = {}
)
}
}

@Suppress("ktlint:compose:modifier-missing-check")
@Composable
fun MainScreenSkeleton(
updateUiThemeMode: (UIThemeMode) -> Unit
) {
val navController = rememberNavController()

NavHostMain(
Modifier.background(MaterialTheme.colors.background),
navController = navController,
updateUiThemeMode = updateUiThemeMode
updateUiThemeMode = updateUiThemeMode,
Modifier.background(MaterialTheme.colorScheme.background)
)
}
Loading

0 comments on commit 5a9c390

Please sign in to comment.