checkpoint before calling it a night.
App bar is mostly working for each fragment. Need to cleanup the code and add shared element animations.
This commit is contained in:
parent
39355fec9a
commit
05ed1763da
|
@ -16,7 +16,6 @@ import dagger.Module
|
|||
import dagger.android.ContributesAndroidInjector
|
||||
import dagger.android.support.DaggerAppCompatActivity
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.app_bar_main.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class MainActivity : DaggerAppCompatActivity() {
|
||||
|
@ -31,8 +30,6 @@ class MainActivity : DaggerAppCompatActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
setSupportActionBar(toolbar)
|
||||
setupNavigation()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
@ -52,7 +49,7 @@ class MainActivity : DaggerAppCompatActivity() {
|
|||
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
|
||||
}
|
||||
|
||||
private fun setupNavigation() {
|
||||
public fun setupNavigation() {
|
||||
// create and setup the navController and appbarConfiguration
|
||||
navController = Navigation.findNavController(this, R.id.nav_host_fragment).also { n ->
|
||||
appBarConfiguration = AppBarConfiguration(n.graph, drawer_layout).also { a ->
|
||||
|
@ -64,11 +61,11 @@ class MainActivity : DaggerAppCompatActivity() {
|
|||
// remove icon tint so that our colored nav icons show through
|
||||
nav_view.itemIconTintList = null
|
||||
|
||||
// counting the fab as navigation-related. So set it up here
|
||||
fab.setOnClickListener(::onFabClicked)
|
||||
navController.addOnNavigatedListener { _, destination ->
|
||||
if (destination.id == R.id.nav_home_fragment) fab.show() else fab.hide()
|
||||
}
|
||||
// // counting the fab as navigation-related. So set it up here
|
||||
// fab.setOnClickListener(::onFabClicked)
|
||||
// navController.addOnNavigatedListener { _, destination ->
|
||||
// if (destination.id == R.id.nav_home_fragment) fab.show() else fab.hide()
|
||||
// }
|
||||
}
|
||||
|
||||
private fun onFabClicked(view: View) {
|
||||
|
|
|
@ -3,12 +3,11 @@ package cash.z.android.wallet.ui.fragment
|
|||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import cash.z.android.wallet.R
|
||||
import cash.z.android.wallet.ui.activity.MainActivity
|
||||
import kotlinx.android.synthetic.main.fragment_home.*
|
||||
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
|
@ -47,6 +46,12 @@ class HomeFragment : Fragment() {
|
|||
return inflater.inflate(R.layout.fragment_home, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
(activity as MainActivity).setSupportActionBar(toolbar)
|
||||
(activity as MainActivity).setupNavigation()
|
||||
}
|
||||
|
||||
// TODO: Rename method, update argument and hook method into UI event
|
||||
fun onButtonPressed(uri: Uri) {
|
||||
listener?.onFragmentInteraction(uri)
|
||||
|
|
|
@ -8,6 +8,8 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import cash.z.android.wallet.R
|
||||
import cash.z.android.wallet.ui.activity.MainActivity
|
||||
import kotlinx.android.synthetic.main.fragment_home.*
|
||||
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
|
@ -46,6 +48,12 @@ class ReceiveFragment : Fragment() {
|
|||
return inflater.inflate(R.layout.fragment_receive, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
(activity as MainActivity).setSupportActionBar(toolbar)
|
||||
(activity as MainActivity).supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
|
||||
// TODO: Rename method, update argument and hook method into UI event
|
||||
fun onButtonPressed(uri: Uri) {
|
||||
listener?.onFragmentInteraction(uri)
|
||||
|
|
|
@ -8,6 +8,8 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import cash.z.android.wallet.R
|
||||
import cash.z.android.wallet.ui.activity.MainActivity
|
||||
import kotlinx.android.synthetic.main.fragment_home.*
|
||||
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
|
@ -46,6 +48,12 @@ class RequestFragment : Fragment() {
|
|||
return inflater.inflate(R.layout.fragment_request, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
(activity as MainActivity).setSupportActionBar(toolbar)
|
||||
(activity as MainActivity).supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
|
||||
// TODO: Rename method, update argument and hook method into UI event
|
||||
fun onButtonPressed(uri: Uri) {
|
||||
listener?.onFragmentInteraction(uri)
|
||||
|
|
|
@ -8,6 +8,8 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import cash.z.android.wallet.R
|
||||
import cash.z.android.wallet.ui.activity.MainActivity
|
||||
import kotlinx.android.synthetic.main.fragment_home.*
|
||||
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
|
@ -51,13 +53,11 @@ class SendFragment : Fragment() {
|
|||
listener?.onFragmentInteraction(uri)
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
if (context is OnFragmentInteractionListener) {
|
||||
listener = context
|
||||
} else {
|
||||
// throw RuntimeException(context.toString() + " must implement OnFragmentInteractionListener")
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
(activity as MainActivity).setSupportActionBar(toolbar)
|
||||
(activity as MainActivity).supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
|
||||
override fun onDetach() {
|
||||
|
|
|
@ -8,10 +8,13 @@
|
|||
android:fitsSystemWindows="true"
|
||||
tools:openDrawer="start">
|
||||
|
||||
<include
|
||||
layout="@layout/app_bar_main"
|
||||
<fragment
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/mobile_navigation" />
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/nav_view"
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.activity.MainActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_main"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="@drawable/ic_add_black_24dp"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:tint="@color/fab_icon_color" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:showIn="@layout/app_bar_main"
|
||||
tools:context=".ui.activity.MainActivity">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/mobile_navigation" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -16,7 +16,6 @@
|
|||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="180dp"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
android:background="@android:color/black"
|
||||
tools:context=".ui.fragment.ReceiveFragment">
|
||||
|
||||
<include layout="@layout/include_app_bar"
|
||||
tools:ignore="MissingConstraints" />
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
|
|
|
@ -8,12 +8,16 @@
|
|||
android:background="@color/colorPrimary"
|
||||
tools:context=".ui.fragment.RequestFragment">
|
||||
|
||||
<include layout="@layout/include_app_bar"
|
||||
tools:ignore="MissingConstraints" />
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/destination_title_request"
|
||||
android:textColor="@color/zcashWhite"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context=".ui.fragment.SendFragment">
|
||||
|
||||
<include layout="@layout/include_app_bar"
|
||||
tools:ignore="MissingConstraints" />
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.appbar.AppBarLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:showIn="@layout/fragment_send">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
|
@ -8,7 +8,7 @@
|
|||
<fragment
|
||||
android:id="@+id/nav_home_fragment"
|
||||
android:name="cash.z.android.wallet.ui.fragment.HomeFragment"
|
||||
android:label="@string/destination_title_home"
|
||||
|
||||
tools:layout="@layout/fragment_home">
|
||||
<action
|
||||
android:id="@+id/action_home_fragment_to_send_fragment"
|
||||
|
|
Loading…
Reference in New Issue