-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Sdc gallery app landing page 1. Show Bottom navigation bar with Components and Layouts menus. 2. Implements components screen. 3. Implements layouts screen. 4. Handles bottom navigation clicks. 5. Update actionbar. * Rename file name. * Update components and layouts vector icons. * Address review comments. * Build failures * Delete gallery drawables. * fix package name in nav graph * bottom view margin * Review comments. * Review comment.
- Loading branch information
1 parent
b1d782e
commit f55cce3
Showing
37 changed files
with
1,151 additions
and
14 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
catalog/src/main/java/com/google/android/fhir/catalog/ComponentListFragment.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,41 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.fhir.catalog | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.viewModels | ||
import androidx.recyclerview.widget.GridLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
/** Fragment for the component list. */ | ||
class ComponentListFragment : Fragment(R.layout.fragment_components) { | ||
private val viewModel: ComponentListViewModel by viewModels() | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
setUpComponentsRecyclerView() | ||
} | ||
|
||
private fun setUpComponentsRecyclerView() { | ||
val adapter = ComponentsRecyclerViewAdapter().apply { submitList(viewModel.getComponentList()) } | ||
val recyclerView = requireView().findViewById<RecyclerView>(R.id.componentsRecyclerView) | ||
recyclerView.adapter = adapter | ||
recyclerView.layoutManager = GridLayoutManager(requireContext(), 2) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
catalog/src/main/java/com/google/android/fhir/catalog/ComponentListViewModel.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,44 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.fhir.catalog | ||
|
||
import android.app.Application | ||
import androidx.annotation.DrawableRes | ||
import androidx.annotation.StringRes | ||
import androidx.lifecycle.AndroidViewModel | ||
import androidx.lifecycle.SavedStateHandle | ||
|
||
class ComponentListViewModel(application: Application, private val state: SavedStateHandle) : | ||
AndroidViewModel(application) { | ||
|
||
fun getComponentList(): List<Component> { | ||
return Component.values().toList() | ||
} | ||
|
||
enum class Component(@DrawableRes val iconId: Int, @StringRes val textId: Int) { | ||
SINGLE_CHOICE(R.drawable.ic_singlechoice, R.string.component_name_single_choice), | ||
MULTIPLE_CHOICE(R.drawable.ic_multiplechoice, R.string.component_name_multiple_choice), | ||
DROPDOWN(R.drawable.ic_group_1278, R.string.component_name_dropdown), | ||
MODAL(R.drawable.ic_modal, R.string.component_name_modal), | ||
OPEN_CHOICE(R.drawable.ic_openchoice, R.string.component_name_open_choice), | ||
TEXT_FIELD(R.drawable.ic_textfield, R.string.component_name_text_field), | ||
DATE_PICKER(R.drawable.ic_datepicker, R.string.component_name_date_picker), | ||
TIME_PICKER(R.drawable.ic_timepicker, R.string.component_name_time_picker), | ||
SLIDER(R.drawable.ic_slider, R.string.component_name_slider), | ||
IMAGE(R.drawable.ic_image, R.string.component_name_image), | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
catalog/src/main/java/com/google/android/fhir/catalog/ComponentsRecyclerViewadapter.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,58 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.fhir.catalog | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.google.android.fhir.catalog.databinding.LandingPageItemBinding | ||
|
||
class ComponentsRecyclerViewAdapter : | ||
ListAdapter<ComponentListViewModel.Component, ComponentListViewHolder>(ComponentDiffUtil()) { | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ComponentListViewHolder { | ||
return ComponentListViewHolder( | ||
LandingPageItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ComponentListViewHolder, position: Int) { | ||
holder.bind(getItem(position)) | ||
} | ||
} | ||
|
||
class ComponentListViewHolder(private val binding: LandingPageItemBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
fun bind(component: ComponentListViewModel.Component) { | ||
binding.componentLayoutIconImageview.setImageResource(component.iconId) | ||
binding.componentLayoutTextView.text = | ||
binding.componentLayoutTextView.context.getString(component.textId) | ||
} | ||
} | ||
|
||
class ComponentDiffUtil : DiffUtil.ItemCallback<ComponentListViewModel.Component>() { | ||
override fun areItemsTheSame( | ||
oldComponent: ComponentListViewModel.Component, | ||
newComponent: ComponentListViewModel.Component | ||
) = oldComponent === newComponent | ||
|
||
override fun areContentsTheSame( | ||
oldComponent: ComponentListViewModel.Component, | ||
newComponent: ComponentListViewModel.Component | ||
) = oldComponent == newComponent | ||
} |
41 changes: 41 additions & 0 deletions
41
catalog/src/main/java/com/google/android/fhir/catalog/LayoutListFragment.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,41 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.fhir.catalog | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.viewModels | ||
import androidx.recyclerview.widget.GridLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
/** Fragment for the layout list. */ | ||
class LayoutListFragment : Fragment(R.layout.fragment_layouts) { | ||
private val viewModel: LayoutListViewModel by viewModels() | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
setUpLayoutsRecyclerView() | ||
} | ||
|
||
private fun setUpLayoutsRecyclerView() { | ||
val adapter = LayoutsRecyclerViewAdapter().apply { submitList(viewModel.getLayoutList()) } | ||
val recyclerView = requireView().findViewById<RecyclerView>(R.id.sdcLayoutsRecyclerView) | ||
recyclerView.adapter = adapter | ||
recyclerView.layoutManager = GridLayoutManager(context, 2) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
catalog/src/main/java/com/google/android/fhir/catalog/LayoutListViewModel.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,38 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.fhir.catalog | ||
|
||
import android.app.Application | ||
import androidx.annotation.DrawableRes | ||
import androidx.annotation.StringRes | ||
import androidx.lifecycle.AndroidViewModel | ||
import androidx.lifecycle.SavedStateHandle | ||
|
||
class LayoutListViewModel(application: Application, private val state: SavedStateHandle) : | ||
AndroidViewModel(application) { | ||
|
||
fun getLayoutList(): List<Layout> { | ||
return Layout.values().toList() | ||
} | ||
|
||
enum class Layout(@DrawableRes val iconId: Int, @StringRes val textId: Int) { | ||
DEFAULT(R.drawable.ic_defaultlayout, R.string.layout_name_default_text), | ||
PAGINATED(R.drawable.ic_paginatedlayout, R.string.layout_name_paginated), | ||
REVIEW(R.drawable.ic_reviewlayout, R.string.layout_name_review), | ||
READ_ONLY(R.drawable.ic_readonlylayout, R.string.layout_name_read_only), | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
catalog/src/main/java/com/google/android/fhir/catalog/LayoutsRecyclerViewAdapter.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,58 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.fhir.catalog | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.google.android.fhir.catalog.databinding.LandingPageItemBinding | ||
|
||
class LayoutsRecyclerViewAdapter : | ||
ListAdapter<LayoutListViewModel.Layout, LayoutViewHolder>(LayoutDiffUtil()) { | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LayoutViewHolder { | ||
return LayoutViewHolder( | ||
LandingPageItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: LayoutViewHolder, position: Int) { | ||
holder.bind(getItem(position)) | ||
} | ||
} | ||
|
||
class LayoutViewHolder(val binding: LandingPageItemBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
fun bind(component: LayoutListViewModel.Layout) { | ||
binding.componentLayoutIconImageview.setImageResource(component.iconId) | ||
binding.componentLayoutTextView.text = | ||
binding.componentLayoutTextView.context.getString(component.textId) | ||
} | ||
} | ||
|
||
class LayoutDiffUtil : DiffUtil.ItemCallback<LayoutListViewModel.Layout>() { | ||
override fun areItemsTheSame( | ||
oldComponent: LayoutListViewModel.Layout, | ||
newComponent: LayoutListViewModel.Layout | ||
) = oldComponent === newComponent | ||
|
||
override fun areContentsTheSame( | ||
oldComponent: LayoutListViewModel.Layout, | ||
newComponent: LayoutListViewModel.Layout | ||
) = oldComponent == newComponent | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<vector | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="20dp" | ||
android:height="20dp" | ||
android:viewportWidth="20" | ||
android:viewportHeight="20" | ||
> | ||
<path | ||
android:pathData="M13.66,0.69L8,6.34V2H0V10H8V6.34L13.66,12H10V20H18V12H13.66L19.32,6.34L13.66,0.69ZM16.49,6.35L13.66,3.52L10.83,6.35L13.66,9.18L16.49,6.35ZM6,8V4H2V8H6ZM16,14V18H12V14H16ZM6,18V14H2V18H6ZM0,12H8V20H0V12Z" | ||
android:fillColor="#1A73E8" | ||
android:fillType="evenOdd" | ||
/> | ||
</vector> |
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,12 @@ | ||
<vector | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="194dp" | ||
android:height="128dp" | ||
android:viewportWidth="194" | ||
android:viewportHeight="128" | ||
> | ||
<path | ||
android:pathData="M112.834,52.917H104.632C104.806,52.426 104.917,51.888 104.917,51.333C104.917,48.721 102.779,46.583 100.167,46.583C98.948,46.583 97.84,47.058 97,47.818C96.161,47.058 95.053,46.583 93.834,46.583C91.221,46.583 89.084,48.721 89.084,51.333C89.084,51.888 89.195,52.426 89.369,52.917H81.167V62.417H84.334V79.833H109.667V62.417H112.834V52.917ZM100.167,49.75C101.038,49.75 101.75,50.463 101.75,51.333C101.75,52.204 101.038,52.917 100.167,52.917C99.296,52.917 98.584,52.204 98.584,51.333C98.584,50.463 99.296,49.75 100.167,49.75ZM92.25,51.333C92.25,50.463 92.963,49.75 93.834,49.75C94.704,49.75 95.417,50.463 95.417,51.333C95.417,52.204 94.704,52.917 93.834,52.917C92.963,52.917 92.25,52.204 92.25,51.333ZM84.334,56.083H95.417V59.25H84.334V56.083ZM87.5,62.417H95.417V76.667H87.5V62.417ZM106.5,76.667H98.584V62.417H106.5V76.667ZM109.667,59.25H98.584V56.083H109.667V59.25Z" | ||
android:fillColor="#1A73E8" | ||
/> | ||
</vector> |
Oops, something went wrong.