-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from d4rken-org/onboarding_page
Add extra onboarding screen
- Loading branch information
Showing
7 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/src/main/java/eu/darken/octi/main/ui/onboarding/ui/OnboardingFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package eu.darken.octi.main.ui.onboarding.ui | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.fragment.app.viewModels | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import eu.darken.octi.R | ||
import eu.darken.octi.common.PrivacyPolicy | ||
import eu.darken.octi.common.WebpageTool | ||
import eu.darken.octi.common.uix.Fragment3 | ||
import eu.darken.octi.common.viewbinding.viewBinding | ||
import eu.darken.octi.databinding.OnboardingFragmentBinding | ||
import javax.inject.Inject | ||
|
||
|
||
@AndroidEntryPoint | ||
class OnboardingFragment : Fragment3(R.layout.onboarding_fragment) { | ||
|
||
override val vm: OnboardingFragmentVM by viewModels() | ||
override val ui: OnboardingFragmentBinding by viewBinding() | ||
|
||
@Inject lateinit var webpageTool: WebpageTool | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
ui.goPrivacyPolicy.setOnClickListener { webpageTool.open(PrivacyPolicy.URL) } | ||
ui.continueAction.setOnClickListener { vm.finishOnboarding() } | ||
super.onViewCreated(view, savedInstanceState) | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/eu/darken/octi/main/ui/onboarding/ui/OnboardingFragmentVM.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package eu.darken.octi.main.ui.onboarding.ui | ||
|
||
import androidx.lifecycle.SavedStateHandle | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import eu.darken.octi.common.coroutine.DispatcherProvider | ||
import eu.darken.octi.common.datastore.value | ||
import eu.darken.octi.common.debug.logging.logTag | ||
import eu.darken.octi.common.uix.ViewModel3 | ||
import eu.darken.octi.main.core.GeneralSettings | ||
import kotlinx.coroutines.flow.* | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class OnboardingFragmentVM @Inject constructor( | ||
@Suppress("UNUSED_PARAMETER") handle: SavedStateHandle, | ||
private val dispatcherProvider: DispatcherProvider, | ||
private val generalSettings: GeneralSettings, | ||
) : ViewModel3(dispatcherProvider = dispatcherProvider) { | ||
|
||
fun finishOnboarding() = launch { | ||
generalSettings.isOnboardingDone.value(true) | ||
OnboardingFragmentDirections.actionOnboardingFragmentToDashFragment().navigate() | ||
} | ||
|
||
companion object { | ||
val TAG = logTag("Onboarding", "Fragment", "VM") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:padding="32dp"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<ImageView | ||
android:id="@+id/mascot" | ||
android:layout_width="96dp" | ||
android:layout_height="96dp" | ||
android:layout_marginTop="48dp" | ||
android:src="@mipmap/ic_launcher_round" | ||
app:layout_constraintEnd_toEndOf="@id/title" | ||
app:layout_constraintStart_toStartOf="@id/title" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/title" | ||
style="@style/TextAppearance.Material3.HeadlineLarge" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:text="@string/app_name" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/mascot" /> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/body1" | ||
style="@style/TextAppearance.MaterialComponents.Body1" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="32dp" | ||
android:text="@string/onboarding_body1" | ||
app:layout_constraintTop_toBottomOf="@id/title" /> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/body2" | ||
style="@style/TextAppearance.MaterialComponents.Body1" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:text="@string/onboarding_body2" | ||
app:layout_constraintTop_toBottomOf="@id/body1" /> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/body3" | ||
style="@style/TextAppearance.MaterialComponents.Body1" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:text="@string/onboarding_body3" | ||
app:layout_constraintTop_toBottomOf="@id/body2" /> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/go_privacy_policy" | ||
style="@style/Widget.Material3.Button.TonalButton" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginVertical="32dp" | ||
android:text="@string/settings_privacy_policy_label" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/body3" /> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/continue_action" | ||
style="@style/Widget.Material3.Button" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="32dp" | ||
android:layout_marginTop="32dp" | ||
android:text="@string/general_continue" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/go_privacy_policy" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</ScrollView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters