diff --git a/app/BUILD.bazel b/app/BUILD.bazel index 1e4620c4821..a0898ae39b0 100644 --- a/app/BUILD.bazel +++ b/app/BUILD.bazel @@ -601,6 +601,7 @@ android_library( "//model/src/main/proto:thumbnail_java_proto_lite", "//model/src/main/proto:version_java_proto_lite", "//third_party:androidx_annotation_annotation", + "//third_party:androidx_compose_ui_ui", "//third_party:androidx_constraintlayout_constraintlayout", "//third_party:androidx_core_core", "//third_party:androidx_databinding_databinding-adapters", @@ -762,6 +763,7 @@ kt_android_library( custom_package = "org.oppia.android.app.ui", enable_data_binding = 1, manifest = "src/main/AppAndroidManifest.xml", + plugins = ["//tools/kotlin:jetpack_compose_compiler_plugin"], visibility = ["//visibility:public"], deps = [ ":binding_adapters", @@ -786,6 +788,15 @@ kt_android_library( "//domain/src/main/java/org/oppia/android/domain/survey:gating_controller", "//domain/src/main/java/org/oppia/android/domain/survey:survey_controller", "//model/src/main/proto:arguments_java_proto_lite", + "//third_party:androidx_activity_activity-compose", + "//third_party:androidx_annotation_annotation", + "//third_party:androidx_appcompat_appcompat", + "//third_party:androidx_compose_foundation_foundation", + "//third_party:androidx_compose_foundation_foundation-layout", + "//third_party:androidx_compose_material_material", + "//third_party:androidx_compose_runtime_runtime", + "//third_party:androidx_compose_ui_ui", + "//third_party:androidx_core_core-ktx", "//third_party:androidx_databinding_databinding-adapters", "//third_party:androidx_databinding_databinding-common", "//third_party:androidx_databinding_databinding-runtime", @@ -799,6 +810,7 @@ kt_android_library( "//third_party:com_github_takusemba_spotlight", "//third_party:com_google_android_flexbox_flexbox", "//third_party:javax_annotation_javax_annotation-api_jar", + "//third_party:org_jetbrains_kotlin_kotlin-stdlib-jdk8_jar", "//utility", "//utility/src/main/java/org/oppia/android/util/extensions:bundle_extensions", "//utility/src/main/java/org/oppia/android/util/parser/image:image_loader", diff --git a/app/src/main/java/org/oppia/android/app/home/HomeFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/home/HomeFragmentPresenter.kt index b62c266612d..14347d75abb 100644 --- a/app/src/main/java/org/oppia/android/app/home/HomeFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/home/HomeFragmentPresenter.kt @@ -4,6 +4,20 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.ViewCompositionStrategy +import androidx.compose.ui.unit.dp import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import androidx.recyclerview.widget.GridLayoutManager @@ -102,11 +116,40 @@ class HomeFragmentPresenter @Inject constructor( it.viewModel = homeViewModel } + binding.composeView.apply { + setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) + setContent { + MaterialTheme { + GroupedList() + } + } + } + logAppOnboardedEvent() return binding.root } + @OptIn(ExperimentalFoundationApi::class) + @Composable + fun GroupedList() { + val sections = listOf("A", "B", "C", "D", "E", "F", "G") + + LazyColumn(contentPadding = PaddingValues(6.dp)) { + sections.forEach { sectionName -> + stickyHeader { + Text( + "Section $sectionName", + Modifier.fillMaxWidth().background(Color.LightGray).padding(8.dp) + ) + } + items(10) { item -> + Text(text = "Some item $item") + } + } + } + } + private fun logAppOnboardedEvent() { val startupStateProvider = appStartupStateController.getAppStartupState() val liveData = startupStateProvider.toLiveData() diff --git a/app/src/main/res/layout/home_fragment.xml b/app/src/main/res/layout/home_fragment.xml index d7dfe561d70..546a32fda8c 100644 --- a/app/src/main/res/layout/home_fragment.xml +++ b/app/src/main/res/layout/home_fragment.xml @@ -25,6 +25,11 @@ android:visibility="@{viewModel.isProgressBarVisible?View.VISIBLE:View.GONE}" /> + +