diff --git a/README.md b/README.md index 6ba67e7..c8b2295 100644 --- a/README.md +++ b/README.md @@ -30,21 +30,29 @@ Also available in Play Store Play Store -## App preview +## Screenshots -![Home](screenshots/home.png "Home") -![Pokedex](screenshots/pokedex.png "Pokedex") -![Pokedex FAB](screenshots/pokedex-fab.png "Pokedex FAB") -![Pokedex Search](screenshots/pokedex-fab-search.png "Pokedex Search") -![Pokedex Generation](screenshots/pokedex-fab-generation.png "Pokedex Generation") -![Pokemon Info - About](screenshots/pokemon-info-about.png "Pokemon Info - About") -![Pokemon Info - Base Stats](screenshots/pokemon-info-base-stats.png "Pokemon Info - Base Stats") -![Pokemon Info - Evolution](screenshots/pokemon-info-evolution.png "Pokemon Info - Evolution") -![News Detail](screenshots/news-detail.png "News Detail") +

+ Home + Pokedex + Pokedex FAB +

+ +

+ Pokedex Search + Pokedex Generation + Pokemon Info - About +

+ +

+ Pokemon Info - Base Stats + Pokemon Info - Evolution + News Detail +

## Features -- :white_check_mark: Kotlin +- :white_check_mark: Kotlin - :white_check_mark: Live data - :white_check_mark: Navigation - :white_check_mark: MVVM Design Partner @@ -61,8 +69,8 @@ Also available in Play Store - [x] Pokedex - Search - [x] Pokedex - Generation - [x] Pokemon Info -- [ ] Pokemon Info - About -- [ ] Pokemon Info - Base Stats +- [x] Pokemon Info - About +- [x] Pokemon Info - Base Stats - [ ] Pokemon Info - Evolution - [x] News Detail @@ -74,3 +82,27 @@ Also available in Play Store ## License All the code available under the MIT license. See [LICENSE](LICENSE). + +``` +MIT License + +Copyright (c) 2019 Marcos Paulo Farias + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` diff --git a/app/src/main/java/dev/marcosfarias/pokedex/adapter/ViewPagerAdapter.kt b/app/src/main/java/dev/marcosfarias/pokedex/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..d8e52e9 --- /dev/null +++ b/app/src/main/java/dev/marcosfarias/pokedex/adapter/ViewPagerAdapter.kt @@ -0,0 +1,29 @@ +package dev.marcosfarias.pokedex.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentStatePagerAdapter + +class ViewPagerAdapter(supportFragmentManager: FragmentManager) : + FragmentStatePagerAdapter(supportFragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { + + private val mFragmentList = ArrayList() + private val mFragmentTitleList = ArrayList() + + override fun getItem(position: Int): Fragment { + return mFragmentList.get(position) + } + + override fun getCount(): Int { + return mFragmentList.size + } + + override fun getPageTitle(position: Int): CharSequence? { + return mFragmentTitleList[position] + } + + fun addFragment(fragment: Fragment, title : String) { + mFragmentList.add(fragment) + mFragmentTitleList.add(title) + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardFragment.kt index a467571..25a6711 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardFragment.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardFragment.kt @@ -11,15 +11,13 @@ import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import com.bumptech.glide.Glide import dev.marcosfarias.pokedex.R +import dev.marcosfarias.pokedex.adapter.ViewPagerAdapter +import dev.marcosfarias.pokedex.ui.dashboard.about.AboutFragment +import dev.marcosfarias.pokedex.ui.dashboard.evolution.EvolutionFragment +import dev.marcosfarias.pokedex.ui.dashboard.moves.MovesFragment +import dev.marcosfarias.pokedex.ui.dashboard.stats.StatsFragment import dev.marcosfarias.pokedex.utils.PokemonColorUtil import kotlinx.android.synthetic.main.fragment_dashboard.view.* -import kotlinx.android.synthetic.main.fragment_dashboard.view.imageView -import kotlinx.android.synthetic.main.fragment_dashboard.view.textViewID -import kotlinx.android.synthetic.main.fragment_dashboard.view.textViewName -import kotlinx.android.synthetic.main.fragment_dashboard.view.textViewType1 -import kotlinx.android.synthetic.main.fragment_dashboard.view.textViewType2 -import kotlinx.android.synthetic.main.fragment_dashboard.view.textViewType3 -import kotlinx.android.synthetic.main.item_pokemon.view.* class DashboardFragment : Fragment() { @@ -68,6 +66,19 @@ class DashboardFragment : Fragment() { .placeholder(android.R.color.transparent) .into(root.imageView) + val pager = root.viewPager + val tabs = root.tabs + + + val adapter = ViewPagerAdapter(fragmentManager!!) + adapter.addFragment(AboutFragment.newInstance(pokemon?.id), getString(R.string.dashboard_tab_1)) + adapter.addFragment(StatsFragment.newInstance(pokemon?.id), getString(R.string.dashboard_tab_2)) + adapter.addFragment(EvolutionFragment(), getString(R.string.dashboard_tab_3)) + adapter.addFragment(MovesFragment(), getString(R.string.dashboard_tab_4)) + + pager.adapter = adapter + + tabs.setupWithViewPager(pager) } @@ -82,5 +93,4 @@ class DashboardFragment : Fragment() { - } \ No newline at end of file diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/about/AboutFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/about/AboutFragment.kt new file mode 100644 index 0000000..654cfaf --- /dev/null +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/about/AboutFragment.kt @@ -0,0 +1,56 @@ +package dev.marcosfarias.pokedex.ui.dashboard.about + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProviders +import dev.marcosfarias.pokedex.R +import dev.marcosfarias.pokedex.ui.dashboard.DashboardViewModel +import kotlinx.android.synthetic.main.fragment_about.view.* + +class AboutFragment : Fragment() { + + companion object { + @JvmStatic + fun newInstance(id: String?) = AboutFragment().apply { + arguments = Bundle().apply { + putString("id", id) + } + } + } + + private lateinit var dashboardViewModel: DashboardViewModel + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + dashboardViewModel = ViewModelProviders.of(this).get(DashboardViewModel::class.java) + + val root = inflater.inflate(R.layout.fragment_about, container, false) + + arguments?.getString("id").let { + + dashboardViewModel.getPokemonById(it).observe(this, Observer { list -> + list?.get(0).let { pokemon -> + + root.textViewDescription.text = pokemon?.xdescription + root.textViewHeight.text = pokemon?.height + root.textViewWeight.text = pokemon?.weight + root.textViewEggCycle.text = pokemon?.cycles + root.textViewEggGroups.text = pokemon?.egg_groups + root.textViewBaseEXP.text = pokemon?.base_exp + } + }) + } + + + return root + } + + +} \ No newline at end of file diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionFragment.kt new file mode 100644 index 0000000..306d44a --- /dev/null +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionFragment.kt @@ -0,0 +1,27 @@ +package dev.marcosfarias.pokedex.ui.dashboard.evolution + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import androidx.lifecycle.ViewModelProviders +import dev.marcosfarias.pokedex.R +import dev.marcosfarias.pokedex.ui.dashboard.DashboardViewModel + +class EvolutionFragment : Fragment() { + + private lateinit var dashboardViewModel: DashboardViewModel + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ) : View? { + dashboardViewModel = ViewModelProviders.of(this).get(DashboardViewModel::class.java) + + val root = inflater.inflate(R.layout.fragment_evolution, container, false) + + + return root + } + + + +} \ No newline at end of file diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/moves/MovesFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/moves/MovesFragment.kt new file mode 100644 index 0000000..ff38953 --- /dev/null +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/moves/MovesFragment.kt @@ -0,0 +1,17 @@ +package dev.marcosfarias.pokedex.ui.dashboard.moves + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import dev.marcosfarias.pokedex.R + +class MovesFragment : Fragment() { + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ) : View? { + val root = inflater.inflate(R.layout.fragment_moves, container, false) + return root + } + +} \ No newline at end of file diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/stats/StatsFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/stats/StatsFragment.kt new file mode 100644 index 0000000..e81e10d --- /dev/null +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/stats/StatsFragment.kt @@ -0,0 +1,63 @@ +package dev.marcosfarias.pokedex.ui.dashboard.stats + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProviders +import dev.marcosfarias.pokedex.R +import dev.marcosfarias.pokedex.ui.dashboard.DashboardViewModel +import kotlinx.android.synthetic.main.fragment_stats.view.* + +class StatsFragment : Fragment() { + + companion object { + @JvmStatic + fun newInstance(id: String?) = StatsFragment().apply { + arguments = Bundle().apply { + putString("id", id) + } + } + } + + private lateinit var dashboardViewModel: DashboardViewModel + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ) : View? { + dashboardViewModel = ViewModelProviders.of(this).get(DashboardViewModel::class.java) + + val root = inflater.inflate(R.layout.fragment_stats, container, false) + + arguments?.getString("id").let { + + dashboardViewModel.getPokemonById(it).observe(this, Observer { list -> + list?.get(0).let { pokemon -> + + root.textViewTypeDefenses.text = pokemon?.ydescription + + root.textViewHP.text = pokemon?.hp.toString() + root.textViewAttack.text = pokemon?.attack.toString() + root.textViewDefense.text = pokemon?.defense.toString() + root.textViewSpAtk.text = pokemon?.special_attack.toString() + root.textViewSpDef.text = pokemon?.special_defense.toString() + root.textViewSpeed.text = pokemon?.speed.toString() + root.textViewTotal.text = pokemon?.total.toString() + + root.progressBarHP.progress = pokemon?.hp ?: 0 + root.progressBarAttack.progress = pokemon?.attack ?: 0 + root.progressBarDefense.progress = pokemon?.defense ?: 0 + root.progressBarSpAtk.progress = pokemon?.special_attack ?: 0 + root.progressBarSpDef.progress = pokemon?.special_defense ?: 0 + root.progressBarSpeed.progress = pokemon?.speed ?: 0 + root.progressBarTotal.progress = pokemon?.total ?: 0 + } + }) + } + + return root + } + + + +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml new file mode 100644 index 0000000..a467bc9 --- /dev/null +++ b/app/src/main/res/layout/fragment_about.xml @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml index 8071f2c..39c66be 100644 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ b/app/src/main/res/layout/fragment_dashboard.xml @@ -30,8 +30,7 @@ android:id="@+id/imageView" android:layout_width="160dp" android:layout_height="160dp" - android:layout_gravity="center" - android:src="@drawable/poke001" /> + android:layout_gravity="center" /> + app:fontFamily="@font/circularstd_medium" + tools:text="Titulo" /> + android:textSize="14sp" + tools:text="Grass" /> + android:textSize="14sp" + tools:text="Grass" /> + android:textSize="14sp" + tools:text="Grass" /> @@ -174,19 +172,14 @@ - - - - - + android:background="@color/backgroundLight" /> diff --git a/app/src/main/res/layout/fragment_evolution.xml b/app/src/main/res/layout/fragment_evolution.xml new file mode 100644 index 0000000..b8b4003 --- /dev/null +++ b/app/src/main/res/layout/fragment_evolution.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_moves.xml b/app/src/main/res/layout/fragment_moves.xml new file mode 100644 index 0000000..b8b4003 --- /dev/null +++ b/app/src/main/res/layout/fragment_moves.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_notifications.xml b/app/src/main/res/layout/fragment_notifications.xml deleted file mode 100644 index 51bd1ae..0000000 --- a/app/src/main/res/layout/fragment_notifications.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_stats.xml b/app/src/main/res/layout/fragment_stats.xml new file mode 100644 index 0000000..be45e50 --- /dev/null +++ b/app/src/main/res/layout/fragment_stats.xml @@ -0,0 +1,297 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml index fbe9486..4e71fed 100644 --- a/app/src/main/res/navigation/mobile_navigation.xml +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -50,12 +50,35 @@ android:label="@string/app_name" tools:layout="@layout/fragment_search" /> - + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b01d052..7ba532e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -10,6 +10,7 @@ true @android:color/transparent @style/AppBottomSheetDialogTheme + @style/RobotoTextViewStyle + +