Skip to content
Open

п #10

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
17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

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

1 change: 1 addition & 0 deletions .idea/gradle.xml

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

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
23 changes: 23 additions & 0 deletions .idea/sonarlint/issuestore/index.pb

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

6 changes: 6 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"

implementation "androidx.compose.material:material-icons-core:$compose_version"
implementation "androidx.compose.material:material-icons-extended:$compose_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha04"
implementation "androidx.navigation:navigation-compose:1.0.0-alpha09"
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha05"

// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.plcoding.jetpackcomposepokedex">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".PokedexApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,59 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.navArgument
import androidx.navigation.compose.rememberNavController
import com.plcoding.jetpackcomposepokedex.pokemondetail.PokemonDetailScreen
import com.plcoding.jetpackcomposepokedex.pokemonlist.PokemonListScreen
import com.plcoding.jetpackcomposepokedex.ui.theme.JetpackComposePokedexTheme
import dagger.hilt.android.AndroidEntryPoint
import java.util.*

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
JetpackComposePokedexTheme {

val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = "pokemon_list_screen"
) {
composable("pokemon_list_screen") {
PokemonListScreen(navController = navController)
}
composable(
"pokemon_detail_screen/{dominantColor}/{pokemonName}",
arguments = listOf(
navArgument("dominantColor") {
type = NavType.IntType
},
navArgument("pokemonName") {
type = NavType.StringType
}
)
) {
val dominantColor = remember {
val color = it.arguments?.getInt("dominantColor")
color?.let { Color(it) } ?: Color.White
}
val pokemonName = remember {
it.arguments?.getString("pokemonName")
}
PokemonDetailScreen(
dominantColor = dominantColor,
pokemonName = pokemonName?.toLowerCase(Locale.ROOT) ?: "",
navController = navController
)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.plcoding.jetpackcomposepokedex

import android.app.Application
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber

@HiltAndroidApp
class PokedexApplication : Application() {

override fun onCreate() {
super.onCreate()
Timber.plant(Timber.DebugTree())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.plcoding.jetpackcomposepokedex.data.models

data class PokedexListEntry(
val pokemonName: String,
val imageUrl: String,
val number: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.plcoding.jetpackcomposepokedex.data.remote

import com.plcoding.jetpackcomposepokedex.data.remote.responses.Pokemon
import com.plcoding.jetpackcomposepokedex.data.remote.responses.PokemonList
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

interface PokeApi {

@GET("pokemon")
suspend fun getPokemonList(
@Query("limit") limit: Int,
@Query("offset") offset: Int
): PokemonList

@GET("pokemon/{name}")
suspend fun getPokemonInfo(
@Path("name") name: String
): Pokemon
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class Ability(
val ability: AbilityX,
@SerializedName("is_hidden")
val isHidden: Boolean,
val slot: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class AbilityX(
val name: String,
val url: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class Animated(
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_female")
val backFemale: Any,
@SerializedName("back_shiny")
val backShiny: String,
@SerializedName("back_shiny_female")
val backShinyFemale: Any,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_female")
val frontFemale: Any,
@SerializedName("front_shiny")
val frontShiny: String,
@SerializedName("front_shiny_female")
val frontShinyFemale: Any
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class BlackWhite(
val animated: Animated,
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_female")
val backFemale: Any,
@SerializedName("back_shiny")
val backShiny: String,
@SerializedName("back_shiny_female")
val backShinyFemale: Any,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_female")
val frontFemale: Any,
@SerializedName("front_shiny")
val frontShiny: String,
@SerializedName("front_shiny_female")
val frontShinyFemale: Any
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class Crystal(
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_shiny")
val backShiny: String,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_shiny")
val frontShiny: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class DiamondPearl(
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_female")
val backFemale: Any,
@SerializedName("back_shiny")
val backShiny: String,
@SerializedName("back_shiny_female")
val backShinyFemale: Any,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_female")
val frontFemale: Any,
@SerializedName("front_shiny")
val frontShiny: String,
@SerializedName("front_shiny_female")
val frontShinyFemale: Any
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class DreamWorld(
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_female")
val frontFemale: Any
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class Emerald(
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_shiny")
val frontShiny: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class FireredLeafgreen(
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_shiny")
val backShiny: String,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_shiny")
val frontShiny: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class Form(
val name: String,
val url: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class GameIndice(
@SerializedName("game_index")
val gameIndex: Int,
val version: Version
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class GenerationI(
@SerializedName("red-blue")
val redBlue: RedBlue,
val yellow: Yellow
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.plcoding.jetpackcomposepokedex.data.remote.responses


import com.google.gson.annotations.SerializedName

data class GenerationIi(
val crystal: Crystal,
val gold: Gold,
val silver: Silver
)
Loading