Skip to content
Snippets Groups Projects
Commit de60fbf5 authored by yansans's avatar yansans
Browse files

refactor: consistent var name and view

parent e06a16bc
Branches
Tags
2 merge requests!13Release,!2Set to api 32 and fix dependencies + login ui
Showing with 44 additions and 13 deletions
......@@ -6,6 +6,7 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.example.bondoyap.R
class GraphFragment : Fragment() {
......@@ -26,6 +27,15 @@ class GraphFragment : Fragment() {
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return inflater.inflate(R.layout.fragment_graph, container, false)
val root = inflater.inflate(R.layout.fragment_graph, container, false)
val textView: TextView = root.findViewById(R.id.text_graph)
viewModel.text.observe(viewLifecycleOwner) {
textView.text = it
}
return root
}
}
\ No newline at end of file
package com.example.bondoyap.ui.graph
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
class GraphViewModel : ViewModel() {
// TODO: Implement the ViewModel
private val _text = MutableLiveData<String>().apply {
value = "This is Graph Fragment"
}
val text: LiveData<String> = _text
}
\ No newline at end of file
......@@ -28,7 +28,7 @@ class ScannerFragment : Fragment() {
_binding = FragmentScannerBinding.inflate(inflater, container, false)
val root: View = binding.root
val textView: TextView = binding.textNotifications
val textView: TextView = binding.textScanner
scannerViewModel.text.observe(viewLifecycleOwner) {
textView.text = it
}
......
......@@ -28,7 +28,7 @@ class SettingsFragment : Fragment() {
_binding = FragmentSettingsBinding.inflate(inflater, container, false)
val root: View = binding.root
val textView: TextView = binding.textHome
val textView: TextView = binding.textSettings
settingsViewModel.text.observe(viewLifecycleOwner) {
textView.text = it
}
......
......@@ -28,7 +28,7 @@ class TransactionsFragment : Fragment() {
_binding = FragmentTransactionsBinding.inflate(inflater, container, false)
val root: View = binding.root
val textView: TextView = binding.textDashboard
val textView: TextView = binding.textTransactions
transactionsViewModel.text.observe(viewLifecycleOwner) {
textView.text = it
}
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.graph.GraphFragment">
<TextView
android:id="@+id/text_graph"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Graph Fragment" />
</FrameLayout>
\ No newline at end of file
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:textAlignment="center"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -7,7 +7,7 @@
tools:context=".ui.scanner.ScannerFragment">
<TextView
android:id="@+id/text_notifications"
android:id="@+id/text_scanner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
......
......@@ -7,7 +7,7 @@
tools:context=".ui.settings.SettingsFragment">
<TextView
android:id="@+id/text_home"
android:id="@+id/text_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
......
......@@ -7,7 +7,7 @@
tools:context=".ui.transactions.TransactionsFragment">
<TextView
android:id="@+id/text_dashboard"
android:id="@+id/text_transactions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
......
......@@ -5,6 +5,12 @@
android:id="@+id/mobile_navigation"
app:startDestination="@+id/navigation_transactions">
<fragment
android:id="@+id/navigation_login"
android:name="com.example.bondoyap.ui.login.LoginFragment"
android:label="@string/title_login"
tools:layout="@layout/fragment_transactions" />
<fragment
android:id="@+id/navigation_transactions"
android:name="com.example.bondoyap.ui.transactions.TransactionsFragment"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment