From 71a2c91ec97bceb72473ccd6da3d507dec216b3a Mon Sep 17 00:00:00 2001 From: AngelSuarez03 Date: Wed, 8 May 2024 07:29:21 -0600 Subject: [PATCH] Inicio Bottom navigation menu --- .idea/deploymentTargetDropDown.xml | 15 +------ app/build.gradle.kts | 7 ++++ app/src/main/AndroidManifest.xml | 10 +++-- .../medicalhealth/MainActivity.kt | 2 +- .../medicalhealth/PrincipalActivity.kt | 35 ++++++++++++++++ .../medicalhealth/RegistrarDActivity.kt | 1 + .../ui/dashboard/DashboardFragment.kt | 42 +++++++++++++++++++ .../ui/dashboard/DashboardViewModel.kt | 13 ++++++ .../medicalhealth/ui/home/HomeFragment.kt | 42 +++++++++++++++++++ .../medicalhealth/ui/home/HomeViewModel.kt | 13 ++++++ .../ui/notifications/NotificationsFragment.kt | 42 +++++++++++++++++++ .../notifications/NotificationsViewModel.kt | 13 ++++++ .../res/drawable/ic_dashboard_black_24dp.xml | 9 ++++ .../main/res/drawable/ic_home_black_24dp.xml | 9 ++++ .../drawable/ic_notifications_black_24dp.xml | 9 ++++ .../main/res/layout/activity_modificar.xml | 9 ++-- .../main/res/layout/activity_principal.xml | 33 +++++++++++++++ .../layout/activity_registrar_dactivity.xml | 32 ++++++++++---- .../main/res/layout/fragment_dashboard.xml | 22 ++++++++++ app/src/main/res/layout/fragment_home.xml | 22 ++++++++++ .../res/layout/fragment_notifications.xml | 22 ++++++++++ app/src/main/res/menu/bottom_nav_menu.xml | 19 +++++++++ .../main/res/navigation/mobile_navigation.xml | 25 +++++++++++ app/src/main/res/values/dimens.xml | 5 +++ app/src/main/res/values/strings.xml | 4 ++ 25 files changed, 426 insertions(+), 29 deletions(-) create mode 100644 app/src/main/java/com/terratenientes/medicalhealth/PrincipalActivity.kt create mode 100644 app/src/main/java/com/terratenientes/medicalhealth/ui/dashboard/DashboardFragment.kt create mode 100644 app/src/main/java/com/terratenientes/medicalhealth/ui/dashboard/DashboardViewModel.kt create mode 100644 app/src/main/java/com/terratenientes/medicalhealth/ui/home/HomeFragment.kt create mode 100644 app/src/main/java/com/terratenientes/medicalhealth/ui/home/HomeViewModel.kt create mode 100644 app/src/main/java/com/terratenientes/medicalhealth/ui/notifications/NotificationsFragment.kt create mode 100644 app/src/main/java/com/terratenientes/medicalhealth/ui/notifications/NotificationsViewModel.kt create mode 100644 app/src/main/res/drawable/ic_dashboard_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_home_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_notifications_black_24dp.xml create mode 100644 app/src/main/res/layout/activity_principal.xml create mode 100644 app/src/main/res/layout/fragment_dashboard.xml create mode 100644 app/src/main/res/layout/fragment_home.xml create mode 100644 app/src/main/res/layout/fragment_notifications.xml create mode 100644 app/src/main/res/menu/bottom_nav_menu.xml create mode 100644 app/src/main/res/navigation/mobile_navigation.xml create mode 100644 app/src/main/res/values/dimens.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 7d885b6..0c0c338 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -3,20 +3,7 @@ - - - - - - - - - - - - - - + diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6ba360d..8e3077e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -36,6 +36,9 @@ android { viewBinding { enable = true } + buildFeatures { + viewBinding = true + } } dependencies { @@ -45,6 +48,10 @@ dependencies { implementation("com.google.android.material:material:1.11.0") implementation("androidx.constraintlayout:constraintlayout:2.1.4") implementation("androidx.activity:activity:1.8.0") + implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1") + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1") + implementation("androidx.navigation:navigation-fragment-ktx:2.6.0") + implementation("androidx.navigation:navigation-ui-ktx:2.6.0") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7e8c7fa..01888ea 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,9 +2,9 @@ - - -¿ + + + + diff --git a/app/src/main/java/com/terratenientes/medicalhealth/MainActivity.kt b/app/src/main/java/com/terratenientes/medicalhealth/MainActivity.kt index d62b115..6d709cc 100644 --- a/app/src/main/java/com/terratenientes/medicalhealth/MainActivity.kt +++ b/app/src/main/java/com/terratenientes/medicalhealth/MainActivity.kt @@ -23,7 +23,7 @@ class MainActivity : AppCompatActivity() { var res=db.validarDatos(binding.tvUsuario.text.toString(),binding.tvContrasena.text.toString()) if(res==true){ Toast.makeText(this@MainActivity,"VALIDADO",Toast.LENGTH_LONG).show() - val intent = Intent(this@MainActivity, AgregarActivity::class.java) + val intent = Intent(this@MainActivity, PrincipalActivity::class.java) startActivity(intent) }else{ Toast.makeText(this@MainActivity," NO VALIDADO",Toast.LENGTH_LONG).show() diff --git a/app/src/main/java/com/terratenientes/medicalhealth/PrincipalActivity.kt b/app/src/main/java/com/terratenientes/medicalhealth/PrincipalActivity.kt new file mode 100644 index 0000000..039966f --- /dev/null +++ b/app/src/main/java/com/terratenientes/medicalhealth/PrincipalActivity.kt @@ -0,0 +1,35 @@ +package com.terratenientes.medicalhealth + +import android.os.Bundle +import com.google.android.material.bottomnavigation.BottomNavigationView +import androidx.appcompat.app.AppCompatActivity +import androidx.navigation.findNavController +import androidx.navigation.ui.AppBarConfiguration +import androidx.navigation.ui.setupActionBarWithNavController +import androidx.navigation.ui.setupWithNavController +import com.terratenientes.medicalhealth.databinding.ActivityPrincipalBinding + +class PrincipalActivity : AppCompatActivity() { + + private lateinit var binding: ActivityPrincipalBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + binding = ActivityPrincipalBinding.inflate(layoutInflater) + setContentView(binding.root) + + val navView: BottomNavigationView = binding.navView + + val navController = findNavController(R.id.nav_host_fragment_activity_principal) + // Passing each menu ID as a set of Ids because each + // menu should be considered as top level destinations. + val appBarConfiguration = AppBarConfiguration( + setOf( + R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications + ) + ) + setupActionBarWithNavController(navController, appBarConfiguration) + navView.setupWithNavController(navController) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/terratenientes/medicalhealth/RegistrarDActivity.kt b/app/src/main/java/com/terratenientes/medicalhealth/RegistrarDActivity.kt index 005bd1d..07f5f96 100644 --- a/app/src/main/java/com/terratenientes/medicalhealth/RegistrarDActivity.kt +++ b/app/src/main/java/com/terratenientes/medicalhealth/RegistrarDActivity.kt @@ -30,5 +30,6 @@ class RegistrarDActivity : AppCompatActivity() { val usuario= Doctor(cedula,nombre,apellido,telefono,domicilio.toInt()) db.agregarDoctores(usuario,contrasena) Toast.makeText(this@RegistrarDActivity,"USUARIO AGREGADO",Toast.LENGTH_LONG).show() + finish() } } \ No newline at end of file diff --git a/app/src/main/java/com/terratenientes/medicalhealth/ui/dashboard/DashboardFragment.kt b/app/src/main/java/com/terratenientes/medicalhealth/ui/dashboard/DashboardFragment.kt new file mode 100644 index 0000000..229a044 --- /dev/null +++ b/app/src/main/java/com/terratenientes/medicalhealth/ui/dashboard/DashboardFragment.kt @@ -0,0 +1,42 @@ +package com.terratenientes.medicalhealth.ui.dashboard + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.fragment.app.Fragment +import androidx.lifecycle.ViewModelProvider +import com.terratenientes.medicalhealth.databinding.FragmentDashboardBinding + +class DashboardFragment : Fragment() { + + private var _binding: FragmentDashboardBinding? = null + + // This property is only valid between onCreateView and + // onDestroyView. + private val binding get() = _binding!! + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + val dashboardViewModel = + ViewModelProvider(this).get(DashboardViewModel::class.java) + + _binding = FragmentDashboardBinding.inflate(inflater, container, false) + val root: View = binding.root + + val textView: TextView = binding.textDashboard + dashboardViewModel.text.observe(viewLifecycleOwner) { + textView.text = it + } + return root + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/terratenientes/medicalhealth/ui/dashboard/DashboardViewModel.kt b/app/src/main/java/com/terratenientes/medicalhealth/ui/dashboard/DashboardViewModel.kt new file mode 100644 index 0000000..48f7ba5 --- /dev/null +++ b/app/src/main/java/com/terratenientes/medicalhealth/ui/dashboard/DashboardViewModel.kt @@ -0,0 +1,13 @@ +package com.terratenientes.medicalhealth.ui.dashboard + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +class DashboardViewModel : ViewModel() { + + private val _text = MutableLiveData().apply { + value = "This is dashboard Fragment" + } + val text: LiveData = _text +} \ No newline at end of file diff --git a/app/src/main/java/com/terratenientes/medicalhealth/ui/home/HomeFragment.kt b/app/src/main/java/com/terratenientes/medicalhealth/ui/home/HomeFragment.kt new file mode 100644 index 0000000..40e9c99 --- /dev/null +++ b/app/src/main/java/com/terratenientes/medicalhealth/ui/home/HomeFragment.kt @@ -0,0 +1,42 @@ +package com.terratenientes.medicalhealth.ui.home + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.fragment.app.Fragment +import androidx.lifecycle.ViewModelProvider +import com.terratenientes.medicalhealth.databinding.FragmentHomeBinding + +class HomeFragment : Fragment() { + + private var _binding: FragmentHomeBinding? = null + + // This property is only valid between onCreateView and + // onDestroyView. + private val binding get() = _binding!! + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + val homeViewModel = + ViewModelProvider(this).get(HomeViewModel::class.java) + + _binding = FragmentHomeBinding.inflate(inflater, container, false) + val root: View = binding.root + + val textView: TextView = binding.textHome + homeViewModel.text.observe(viewLifecycleOwner) { + textView.text = it + } + return root + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/terratenientes/medicalhealth/ui/home/HomeViewModel.kt b/app/src/main/java/com/terratenientes/medicalhealth/ui/home/HomeViewModel.kt new file mode 100644 index 0000000..a4b8e5d --- /dev/null +++ b/app/src/main/java/com/terratenientes/medicalhealth/ui/home/HomeViewModel.kt @@ -0,0 +1,13 @@ +package com.terratenientes.medicalhealth.ui.home + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +class HomeViewModel : ViewModel() { + + private val _text = MutableLiveData().apply { + value = "This is home Fragment" + } + val text: LiveData = _text +} \ No newline at end of file diff --git a/app/src/main/java/com/terratenientes/medicalhealth/ui/notifications/NotificationsFragment.kt b/app/src/main/java/com/terratenientes/medicalhealth/ui/notifications/NotificationsFragment.kt new file mode 100644 index 0000000..3c3743b --- /dev/null +++ b/app/src/main/java/com/terratenientes/medicalhealth/ui/notifications/NotificationsFragment.kt @@ -0,0 +1,42 @@ +package com.terratenientes.medicalhealth.ui.notifications + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.fragment.app.Fragment +import androidx.lifecycle.ViewModelProvider +import com.terratenientes.medicalhealth.databinding.FragmentNotificationsBinding + +class NotificationsFragment : Fragment() { + + private var _binding: FragmentNotificationsBinding? = null + + // This property is only valid between onCreateView and + // onDestroyView. + private val binding get() = _binding!! + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + val notificationsViewModel = + ViewModelProvider(this).get(NotificationsViewModel::class.java) + + _binding = FragmentNotificationsBinding.inflate(inflater, container, false) + val root: View = binding.root + + val textView: TextView = binding.textNotifications + notificationsViewModel.text.observe(viewLifecycleOwner) { + textView.text = it + } + return root + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/terratenientes/medicalhealth/ui/notifications/NotificationsViewModel.kt b/app/src/main/java/com/terratenientes/medicalhealth/ui/notifications/NotificationsViewModel.kt new file mode 100644 index 0000000..07b315d --- /dev/null +++ b/app/src/main/java/com/terratenientes/medicalhealth/ui/notifications/NotificationsViewModel.kt @@ -0,0 +1,13 @@ +package com.terratenientes.medicalhealth.ui.notifications + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +class NotificationsViewModel : ViewModel() { + + private val _text = MutableLiveData().apply { + value = "This is notifications Fragment" + } + val text: LiveData = _text +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_dashboard_black_24dp.xml b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml new file mode 100644 index 0000000..46fc8de --- /dev/null +++ b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_home_black_24dp.xml b/app/src/main/res/drawable/ic_home_black_24dp.xml new file mode 100644 index 0000000..f8bb0b5 --- /dev/null +++ b/app/src/main/res/drawable/ic_home_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_notifications_black_24dp.xml b/app/src/main/res/drawable/ic_notifications_black_24dp.xml new file mode 100644 index 0000000..78b75c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_notifications_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_modificar.xml b/app/src/main/res/layout/activity_modificar.xml index b1dd6d6..f7c5f06 100644 --- a/app/src/main/res/layout/activity_modificar.xml +++ b/app/src/main/res/layout/activity_modificar.xml @@ -51,13 +51,14 @@ android:id="@+id/et_nombre" android:layout_width="match_parent" android:layout_height="50sp" - android:layout_marginTop="40dp" android:layout_marginStart="40dp" + android:layout_marginTop="40dp" android:layout_marginEnd="40dp" - android:paddingStart="10dp" android:background="@drawable/radius_tv" - android:textColor="#212121" - android:hint="@string/ht_nombre"/> + android:hint="@string/ht_nombre" + android:paddingStart="10dp" + android:textColor="#212121" /> + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_registrar_dactivity.xml b/app/src/main/res/layout/activity_registrar_dactivity.xml index 346913b..05d0ddc 100644 --- a/app/src/main/res/layout/activity_registrar_dactivity.xml +++ b/app/src/main/res/layout/activity_registrar_dactivity.xml @@ -23,18 +23,24 @@ android:layout_marginTop="30dp" android:layout_width="300dp" android:layout_gravity="center_horizontal" - android:layout_height="wrap_content" + android:layout_height="50sp" android:hint="@string/et_cedula_registrar" android:id="@+id/et_cedela_registro" + android:paddingStart="10dp" + android:layout_marginBottom="20dp" + android:background="@drawable/radius_tv" android:textColorHint="@color/black" /> @@ -43,9 +49,12 @@ android:layout_gravity="center_horizontal" android:layout_width="300dp" - android:layout_height="wrap_content" + android:layout_height="50sp" android:hint="@string/et_apellido_registrar" android:id="@+id/et_apellido_registro" + android:paddingStart="10dp" + android:layout_marginBottom="20dp" + android:background="@drawable/radius_tv" android:textColorHint="@color/black" /> @@ -53,18 +62,24 @@ android:layout_gravity="center_horizontal" android:layout_width="300dp" - android:layout_height="wrap_content" + android:layout_height="50sp" android:hint="@string/et_telefono_registrar" android:id="@+id/et_telefono_registo" + android:paddingStart="10dp" + android:layout_marginBottom="20dp" + android:background="@drawable/radius_tv" android:textColorHint="@color/black" /> @@ -73,9 +88,12 @@ android:layout_gravity="center_horizontal" android:id="@+id/et_contrasena_registro" android:layout_width="300dp" - android:layout_height="wrap_content" + android:layout_height="50sp" android:ems="10" android:inputType="textPassword" + android:paddingStart="10dp" + android:layout_marginBottom="20dp" + android:background="@drawable/radius_tv" android:hint="@string/et_contrasena_registrar" android:textColorHint="@color/black" /> @@ -84,7 +102,7 @@ android:layout_gravity="center_horizontal" android:layout_width="300dp" android:id="@+id/btn_registrar_" - android:layout_height="wrap_content" + android:layout_height="50sp" android:text="@string/btn_registrar_activity" android:backgroundTint="@color/primaryColor" diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml new file mode 100644 index 0000000..166ab0e --- /dev/null +++ b/app/src/main/res/layout/fragment_dashboard.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml new file mode 100644 index 0000000..f3d9b08 --- /dev/null +++ b/app/src/main/res/layout/fragment_home.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_notifications.xml b/app/src/main/res/layout/fragment_notifications.xml new file mode 100644 index 0000000..d417935 --- /dev/null +++ b/app/src/main/res/layout/fragment_notifications.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..fb6d040 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,19 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml new file mode 100644 index 0000000..c3d1a4d --- /dev/null +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -0,0 +1,25 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..e00c2dd --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d34bb43..0b49efa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -47,5 +47,9 @@ Peso del paciente KG Agregar Receta Ayuda + PrincipalActivity + Home + Dashboard + Notifications \ No newline at end of file