From 57a9b5bc0cfdbfa46f98c30f06c62431ef6878ca Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Thu, 3 Oct 2019 17:31:45 +0200 Subject: [PATCH] Added home screen --- .../topjohnwu/magisk/di/ViewModelsModule.kt | 2 + .../topjohnwu/magisk/redesign/MainActivity.kt | 9 + .../magisk/redesign/home/HomeFragment.kt | 16 + .../magisk/redesign/home/HomeViewModel.kt | 5 + app/src/main/res/layout/activity_main_md2.xml | 373 +----------------- app/src/main/res/layout/fragment_home_md2.xml | 369 +++++++++++++++++ 6 files changed, 416 insertions(+), 358 deletions(-) create mode 100644 app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeFragment.kt create mode 100644 app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt create mode 100644 app/src/main/res/layout/fragment_home_md2.xml diff --git a/app/src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt b/app/src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt index 7d8b41871..f2e28cb55 100644 --- a/app/src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt +++ b/app/src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt @@ -12,6 +12,7 @@ import com.topjohnwu.magisk.ui.surequest.SuRequestViewModel import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.dsl.module import com.topjohnwu.magisk.redesign.MainViewModel as RedesignViewModel +import com.topjohnwu.magisk.redesign.home.HomeViewModel as RedesignHomeViewModel val viewModelModules = module { @@ -29,4 +30,5 @@ val viewModelModules = module { // redesign viewModel { RedesignViewModel() } + viewModel { RedesignHomeViewModel() } } diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt index 6b4a7ef37..9ab1f1822 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt @@ -1,15 +1,24 @@ package com.topjohnwu.magisk.redesign import android.graphics.Insets +import androidx.fragment.app.Fragment import com.topjohnwu.magisk.R import com.topjohnwu.magisk.databinding.ActivityMainMd2Binding import com.topjohnwu.magisk.redesign.compat.CompatActivity +import com.topjohnwu.magisk.redesign.home.HomeFragment import org.koin.androidx.viewmodel.ext.android.viewModel +import kotlin.reflect.KClass open class MainActivity : CompatActivity() { override val layoutRes = R.layout.activity_main_md2 override val viewModel by viewModel() + override val navHostId: Int = R.id.main_nav_host + override val defaultPosition: Int = 0 + + override val baseFragments: List> = listOf( + HomeFragment::class + ) override fun peekSystemWindowInsets(insets: Insets) { viewModel.insets.value = insets diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeFragment.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeFragment.kt new file mode 100644 index 000000000..9807f1512 --- /dev/null +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeFragment.kt @@ -0,0 +1,16 @@ +package com.topjohnwu.magisk.redesign.home + +import android.graphics.Insets +import com.topjohnwu.magisk.R +import com.topjohnwu.magisk.databinding.FragmentHomeMd2Binding +import com.topjohnwu.magisk.redesign.compat.CompatFragment +import org.koin.androidx.viewmodel.ext.android.viewModel + +class HomeFragment : CompatFragment() { + + override val layoutRes = R.layout.fragment_home_md2 + override val viewModel by viewModel() + + override fun consumeSystemWindowInsets(insets: Insets) = insets + +} \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt new file mode 100644 index 000000000..fc6b53c3f --- /dev/null +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt @@ -0,0 +1,5 @@ +package com.topjohnwu.magisk.redesign.home + +import com.topjohnwu.magisk.redesign.compat.CompatViewModel + +class HomeViewModel : CompatViewModel() \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main_md2.xml b/app/src/main/res/layout/activity_main_md2.xml index eb085bdd0..5280337be 100644 --- a/app/src/main/res/layout/activity_main_md2.xml +++ b/app/src/main/res/layout/activity_main_md2.xml @@ -14,16 +14,20 @@ + android:orientation="vertical" + android:paddingLeft="@{viewModel.insets.left}" + android:paddingRight="@{viewModel.insets.right}" + tools:ignore="RtlHardcoded"> + android:background="?colorSurfaceVariant" + android:paddingTop="@{viewModel.insets.top}"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" /> diff --git a/app/src/main/res/layout/fragment_home_md2.xml b/app/src/main/res/layout/fragment_home_md2.xml new file mode 100644 index 000000000..485c389be --- /dev/null +++ b/app/src/main/res/layout/fragment_home_md2.xml @@ -0,0 +1,369 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file