Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#15 theme #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
Binary file removed app/src/main/assets/VID_20190615_173334.mp4
Binary file not shown.
Binary file added app/src/main/assets/VID_20190831_213015.mp4
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package com.example.android_curse.ui.onbording

import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.viewpager2.widget.ViewPager2
import by.kirich1409.viewbindingdelegate.viewBinding
Expand All @@ -17,22 +19,16 @@ import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import com.hannesdorfmann.adapterdelegates4.ListDelegationAdapter
import dev.chrisbanes.insetter.applyInsetter
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch

class OnbordingFragment : BaseFragment(R.layout.fragment_onbording) {

private val viewBinding by viewBinding(FragmentOnbordingBinding::bind)
// private lateinit var binding: FragmentOnbordingBinding

private var player: ExoPlayer? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
private val viewModel: OnbordingViewModel by viewModels()

// binding = FragmentOnbordingBinding.inflate(layoutInflater)
private val viewBinding by viewBinding(FragmentOnbordingBinding::bind)

//TODO()
// viewBinding.playerView.player = player!! //TODO()
}
private fun player(): ExoPlayer = viewBinding.playerView.player as ExoPlayer

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand All @@ -45,44 +41,60 @@ class OnbordingFragment : BaseFragment(R.layout.fragment_onbording) {
type(navigationBars = true) { margin() }
}

player = SimpleExoPlayer.Builder(requireContext()).build().apply {
addMediaItem(MediaItem.fromUri("asset:///VID_20190615_173334.mp4"))
viewBinding.playerView.player = SimpleExoPlayer.Builder(requireContext()).build().apply {
addMediaItem(MediaItem.fromUri("asset:///VID_20190831_213015.mp4"))
repeatMode = Player.REPEAT_MODE_ALL
prepare()
}

viewBinding.playerView.player = player!!

viewBinding.viewPager.setTextPages()
viewBinding.viewPager.attachDots(viewBinding.onboardingTextTabLayout)

viewBinding.signInButton.setOnClickListener {
// TODO()
findNavController().navigate(R.id.action_onbordingFragment_to_signInFragment)
Toast.makeText(requireContext(), "нажата текста войти", Toast.LENGTH_SHORT).show()
}
viewBinding.signUpButton.setOnClickListener {
findNavController().navigate(R.id.action_onbordingFragment_to_signUpFragment)

// TODO()
Toast.makeText(requireContext(), "нажата текста регистрации", Toast.LENGTH_SHORT).show()
}

viewBinding.volumeControlButton.setOnClickListener { viewModel.change() }
lifecycleScope.launch {
viewModel.isOffVolumeControlStateFlow().collect { value: Boolean ->
if (value) {
player().volume = 0f
viewBinding.volumeControlButton.setImageDrawable(
ResourcesCompat.getDrawable(
resources,
R.drawable.ic_volume_off_white_24dp,
requireContext().theme
)
)
} else {
player().volume = 100f
viewBinding.volumeControlButton.setImageDrawable(
ResourcesCompat.getDrawable(
resources,
R.drawable.ic_volume_on_white_24dp,
requireContext().theme
)
)
}
}
}
}

override fun onResume() {
super.onResume()
player?.play()
viewBinding.playerView.player?.play()
}

override fun onPause() {
super.onPause()
player?.pause()
viewBinding.playerView.player?.pause()
}

override fun onDestroy() {
super.onDestroy()
player?.release()
viewBinding.playerView.player?.release()
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.android_curse.ui.onbording


import com.example.android_curse.ui.base.BaseViewModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow

class OnbordingViewModel : BaseViewModel() {

private val _isOffVolumeControlStateFlow = MutableStateFlow<Boolean>(true)

fun isOffVolumeControlStateFlow(): Flow<Boolean> = _isOffVolumeControlStateFlow

fun change() {
val compareAndSet : Boolean = _isOffVolumeControlStateFlow.compareAndSet(true, false)
if (!compareAndSet){
_isOffVolumeControlStateFlow.compareAndSet(false, true)
}
}

}
4 changes: 0 additions & 4 deletions app/src/main/res/color/brand_blue.xml

This file was deleted.

1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_onbording.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:backgroundTint="@color/green_blue"
android:text="@string/onboarding_sign_Up_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
7 changes: 1 addition & 6 deletions app/src/main/res/layout/fragment_sign_in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@

<ImageButton
android:id="@+id/back_bottom"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_baseline_arrow_back_24"
style="@style/AndroidCurse.BackButton"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down
7 changes: 1 addition & 6 deletions app/src/main/res/layout/fragment_sign_up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@

<ImageButton
android:id="@+id/backButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_baseline_arrow_back_24"
style="@style/AndroidCurse.BackButton"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="gray">#CCCCCC</color>
<color name="color_post_like_border">#FF9800</color>
todo
<color name="orange">#FF9800</color>
<color name="green_blue">#1ECECA</color>
</resources>
13 changes: 12 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
<item name="android:paddingTop">16dp</item>
<item name="android:textStyle">bold</item>
<item name="android:textAppearance">@style/TextAppearance.MaterialComponents.Body1</item>
<item name="android:textColor">@color/brand_blue</item>
<item name="android:textColor">@color/green_blue</item>
</style>
<style name="AndroidCurse.BackButton">
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_baseline_arrow_back_24"
</style>

<style name="AndroidCurse"></style>

</resources>
8 changes: 4 additions & 4 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<!-- Base application theme. -->
<style name="Theme.Android_curse" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<item name="colorPrimary">@color/orange</item>
<item name="colorPrimaryVariant">@color/orange</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondary">@color/green_blue</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
Expand Down