Commit ea5ca6cf authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

expanded toolbar methods and incapsulate logic

parent 3cf70f8e
...@@ -6,11 +6,13 @@ import android.view.ViewGroup ...@@ -6,11 +6,13 @@ import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.isGone
import butterknife.BindView import butterknife.BindView
import butterknife.ButterKnife import butterknife.ButterKnife
import com.biganto.visual.roompark.BuildConfig import com.biganto.visual.roompark.BuildConfig
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController import com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController
import com.biganto.visual.roompark.util.extensions.setGone
import com.biganto.visual.roompark.util.view_utils.app_bar.DragControlAppBarLayoutBehaviour import com.biganto.visual.roompark.util.view_utils.app_bar.DragControlAppBarLayoutBehaviour
import com.bluelinelabs.conductor.Conductor import com.bluelinelabs.conductor.Conductor
import com.bluelinelabs.conductor.Router import com.bluelinelabs.conductor.Router
...@@ -18,8 +20,10 @@ import com.bluelinelabs.conductor.RouterTransaction ...@@ -18,8 +20,10 @@ import com.bluelinelabs.conductor.RouterTransaction
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.textview.MaterialTextView
import io.fabric.sdk.android.Fabric import io.fabric.sdk.android.Fabric
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.status_layout_toolbar.view.*
import timber.log.Timber import timber.log.Timber
class RoomParkMainActivity( class RoomParkMainActivity(
...@@ -74,12 +78,53 @@ class RoomParkMainActivity( ...@@ -74,12 +78,53 @@ class RoomParkMainActivity(
conductor_container.requestLayout() conductor_container.requestLayout()
} }
override val statusToolbar: ViewGroup override val statusToolbar: ViewGroup
get() = tbContainer.findViewById<ViewGroup>(R.id.status_toolbar_container) get() = tbContainer.findViewById(R.id.status_toolbar_container)
override val headerToolbar: ViewGroup override val headerToolbar: ViewGroup
get() = tbContainer.findViewById<ViewGroup>(R.id.switch_toolbar_container) get() = tbContainer.findViewById(R.id.switch_toolbar_container)
override val headerToolbarBack
get() = headerToolbar.findViewById<MaterialTextView>(R.id.back_button_chevron)
override fun setToolbar(header:HeaderToolbarModel?,status:StatusToolbarModel?){
headerToolbar.setGone(header==null)
statusToolbar.setGone(status==null)
header?.let {
headerToolbarBack.setGone(it.backButton)
headerToolbarBack.text = it.backTitle?:""
headerToolbar.findViewById<MaterialTextView>(R.id.toolbar_title).text = it.title?:""
headerToolbar.findViewById<ViewGroup>(R.id.bell_container).setGone(it.switcher?:false)
}
status?.let {
statusToolbar.status_icon.setGone(it.state == null)
statusToolbar.status_title.setGone(it.state == null)
it.state?.let { state ->
statusToolbar.status_icon.isEnabled = when(state){
StatusState.AVALIABLE -> true
else -> false
}
statusToolbar.status_title.text = when(state){
StatusState.AVALIABLE -> resources.getString(R.string.estate_avalibale)
StatusState.SOLD_OUT -> resources.getString(R.string.estate_sold_out)
}
}
statusToolbar.status_title.setGone(it.title == null)
it.title?.let {title -> statusToolbar.status_title.text = title}
}
headerToolbar.requestLayout()
statusToolbar.requestLayout()
val params = topAppBar.layoutParams as AppBarLayout.LayoutParams
val toolbarHeight =
if (!headerToolbar.isGone) headerToolbar.height else 0 +
if (!statusToolbar.isGone) statusToolbar.height else 0
params.height = toolbarHeight
topAppBar.layoutParams = params
topAppBar.requestLayout()
}
override fun hide() { override fun hide() {
...@@ -118,3 +163,4 @@ class RoomParkMainActivity( ...@@ -118,3 +163,4 @@ class RoomParkMainActivity(
} }
} }
} }
...@@ -5,6 +5,7 @@ import androidx.appcompat.widget.Toolbar ...@@ -5,6 +5,7 @@ import androidx.appcompat.widget.Toolbar
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.textview.MaterialTextView
/** /**
* Created by Vladislav Bogdashkin on 26.09.2019. * Created by Vladislav Bogdashkin on 26.09.2019.
...@@ -23,6 +24,8 @@ interface ICollapsingToolBar : ISupportActionBar{ ...@@ -23,6 +24,8 @@ interface ICollapsingToolBar : ISupportActionBar{
fun appBarScrollable(allow:Boolean) fun appBarScrollable(allow:Boolean)
val statusToolbar:ViewGroup val statusToolbar:ViewGroup
val headerToolbar:ViewGroup val headerToolbar:ViewGroup
val headerToolbarBack: MaterialTextView?
fun setToolbar(header: HeaderToolbarModel? = null,status:StatusToolbarModel? = null)
} }
interface IConductorActivity{ interface IConductorActivity{
...@@ -34,3 +37,14 @@ interface IBottomNavigation{ ...@@ -34,3 +37,14 @@ interface IBottomNavigation{
fun hide() fun hide()
fun show() fun show()
} }
data class HeaderToolbarModel(
val backButton:Boolean
,val backTitle:String?
,val title:String?
,val switcher:Boolean? = null)
data class StatusToolbarModel(val state:StatusState?,val title:String?)
enum class StatusState{AVALIABLE,SOLD_OUT}
\ No newline at end of file
...@@ -7,13 +7,13 @@ import android.widget.LinearLayout ...@@ -7,13 +7,13 @@ import android.widget.LinearLayout
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import butterknife.BindView import butterknife.BindView
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.HeaderToolbarModel
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.util.extensions.toRubly import com.biganto.visual.roompark.util.extensions.toRubly
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
...@@ -74,21 +74,9 @@ class DealScreenController : ...@@ -74,21 +74,9 @@ class DealScreenController :
Timber.d("content insets : ${toolBar.topAppBar.contentInsetEnd}") Timber.d("content insets : ${toolBar.topAppBar.contentInsetEnd}")
activity?.actionBar?.setDisplayShowTitleEnabled(false) activity?.actionBar?.setDisplayShowTitleEnabled(false)
toolBar.statusToolbar.visibility=View.GONE
toolBar.headerToolbar.visibility=View.VISIBLE toolBar.setToolbar(HeaderToolbarModel(
toolBar.headerToolbar.findViewById<MaterialTextView>(R.id.toolbar_title).text = "Кв. 1231\n42342" true,"МОИ\nСДЕЛКИ",null,null))
val params = toolBar.topAppBar.layoutParams as AppBarLayout.LayoutParams
resources?.displayMetrics?.density?.let{
params.height = toolBar.headerToolbar.height
Timber.d("density: $it")
// params.height = (24f*it).toInt()
Timber.d("density: ${params.height}")
}?: error("resources not available!")
toolBar.topAppBar.layoutParams = params
toolBar.topAppBar.requestLayout()
toolBar.topAppBar.invalidate()
......
...@@ -5,6 +5,7 @@ import androidx.recyclerview.widget.LinearLayoutManager ...@@ -5,6 +5,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView import butterknife.BindView
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.HeaderToolbarModel
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController import com.biganto.visual.roompark.conductor.BigantoBaseController
...@@ -51,12 +52,18 @@ class DealsScreenController : ...@@ -51,12 +52,18 @@ class DealsScreenController :
private fun setToolbar(){ private fun setToolbar(){
toolBar.showAll() toolBar.showAll()
toolBar.appBar.setExpanded(false,true) toolBar.appBar.setExpanded(false,false)
toolBar.topAppBar.title = "МОИ СДЕЛКИ" toolBar.topAppBar.title = "МОИ СДЕЛКИ"
toolBar.appBar.liftOnScrollTargetViewId = R.id.favorites_cards_recycler_view toolBar.appBar.liftOnScrollTargetViewId = R.id.favorites_cards_recycler_view
toolBar.appBar.setLiftable(true) toolBar.appBar.setLiftable(true)
toolBar.appBarScrollable(false) toolBar.appBarScrollable(false)
dealsRecyclerView.isNestedScrollingEnabled = false dealsRecyclerView.isNestedScrollingEnabled = false
toolBar.setToolbar(
HeaderToolbarModel(
false,null,"ИЗБРАННОЕ",null)
)
} }
@Inject @Inject
......
...@@ -139,7 +139,9 @@ class FeedsScreenController : ...@@ -139,7 +139,9 @@ class FeedsScreenController :
.map { storedFeedsList[it.position] } .map { storedFeedsList[it.position] }
override fun onViewBound(v: View) { override fun onViewBound(v: View) {
toolBar.hideAll() // toolBar.hideAll()
toolBar.setToolbar()
bindRecycler() bindRecycler()
} }
......
...@@ -47,7 +47,6 @@ fun Long.bytesToSize():String{ ...@@ -47,7 +47,6 @@ fun Long.bytesToSize():String{
} }
} }
fun Float.format(fracDigits: Int): String { fun Float.format(fracDigits: Int): String {
val df = DecimalFormat() val df = DecimalFormat()
df.maximumFractionDigits = fracDigits df.maximumFractionDigits = fracDigits
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bell_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
......
...@@ -34,6 +34,19 @@ ...@@ -34,6 +34,19 @@
app:layout_constraintStart_toEndOf="@+id/status_icon" app:layout_constraintStart_toEndOf="@+id/status_icon"
app:layout_constraintTop_toTopOf="@+id/status_icon" /> app:layout_constraintTop_toTopOf="@+id/status_icon" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/mean_title"
android:fitsSystemWindows="true"
style="@style/Accent_Minor_TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="СВОБОДНА"
app:layout_constraintBottom_toBottomOf="@+id/status_icon"
app:layout_constraintStart_toEndOf="@+id/status_icon"
app:layout_constraintTop_toTopOf="@+id/status_icon" />
<ImageView <ImageView
android:id="@+id/back_cross" android:id="@+id/back_cross"
android:layout_width="24dp" android:layout_width="24dp"
......
...@@ -76,6 +76,8 @@ ...@@ -76,6 +76,8 @@
<string name="feeds_cache">Новости и заметки</string> <string name="feeds_cache">Новости и заметки</string>
<string name="albums_cache">Фотографии</string> <string name="albums_cache">Фотографии</string>
<string name="overall_cache">Всего скачано</string> <string name="overall_cache">Всего скачано</string>
<string name="estate_avalibale">СВОБОДНА</string>
<string name="estate_sold_out">ПРОДАНА</string>
<!--endregion--> <!--endregion-->
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment