Skip to content
Snippets Groups Projects
Commit 1c5d25ab authored by Cetta Reswara's avatar Cetta Reswara
Browse files

add: AddTransactionActivity

parent c9cb31a4
Branches
Tags
No related merge requests found
Showing with 173 additions and 37 deletions
......@@ -2,6 +2,12 @@
<project version="4">
<component name="deploymentTargetDropDown">
<value>
<entry key="TransaksiBaruActivity">
<State />
</entry>
<entry key="TransaksiBaruActivity (1)">
<State />
</entry>
<entry key="app">
<State />
</entry>
......
......@@ -26,7 +26,10 @@
android:exported="true"
android:theme="@style/Theme.BondoMan">
</activity>
<activity android:name=".SettingsActivity" />
<activity
android:name=".TransaksiBaruActivity"
android:exported="true">
</activity>
</application>
</manifest>
\ No newline at end of file
......@@ -92,6 +92,11 @@ class MainActivity : AppCompatActivity() {
frameHeaderText.text = title
}
companion object {
const val EXTRA_FRAGMENT = "com.example.bondoman.EXTRA_FRAGMENT"
const val FRAGMENT_TRANSAKSI = "transaksi_fragment"
}
// override fun onCreate(savedInstanceState: Bundle?) {
// super.onCreate(savedInstanceState)
......
package com.example.bondoman
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Spinner
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.floatingactionbutton.FloatingActionButton
class TransaksiBaruActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_add_transaksi)
val id_kategori: Spinner = findViewById(R.id.id_kategori)
val categories = listOf("Pembelian", "Pemasukan")
val adapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, categories)
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
id_kategori.adapter = adapter
// Handle item selection
id_kategori.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
val selectedCategory = parent?.getItemAtPosition(position).toString()
// Do something with the selected category
}
override fun onNothingSelected(parent: AdapterView<*>?) {
// Handle case when nothing is selected
}
}
// Initialize closeFab directly without declaring a variable
findViewById<FloatingActionButton>(R.id.fab_close).setOnClickListener {
// Navigate back to MainActivity and open the transaction fragment
Intent(this, MainActivity::class.java).apply {
// Pass any necessary data to indicate fragment selection
putExtra(MainActivity.EXTRA_FRAGMENT, MainActivity.FRAGMENT_TRANSAKSI)
startActivity(this)
}
finish()
}
}
}
package com.example.bondoman
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.bondoman.adapters.CardAdapter
import com.example.bondoman.database.yourDataList
import com.google.android.material.floatingactionbutton.FloatingActionButton
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
......@@ -48,6 +50,15 @@ class fragmen_transaksi : Fragment() {
recyclerView.adapter = context?.let { CardAdapter(it, yourDataList) }
// Find the FloatingActionButton
val fab: FloatingActionButton = view.findViewById(R.id.fab)
// Set onClickListener for the FloatingActionButton
fab.setOnClickListener {
val intent = Intent(requireContext(), TransaksiBaruActivity::class.java)
startActivity(intent)
}
return view
}
......
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="50dp"
android:height="50dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2Z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="50dp"
android:height="50dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="@android:color/white"
android:alpha="0.97">
<path
android:fillColor="@android:color/white"
android:pathData="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
</vector>
......@@ -7,22 +7,6 @@
android:layout_height="match_parent"
android:background="@color/white" >
<TextView
android:id="@+id/section_name"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="50dp"
android:paddingBottom="10dp"
android:fontFamily="@font/inter"
android:textStyle="bold"
android:text="Transaksi"
android:textColor="@color/black"
android:textSize="25sp"
android:visibility="gone"
tools:layout_editor_absoluteX="10dp"
tools:visibility="visible" />
<LinearLayout
android:layout_width="292dp"
android:layout_height="wrap_content"
......@@ -30,6 +14,22 @@
android:orientation="vertical"
tools:ignore="UselessParent">
<TextView
android:id="@+id/section_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="@font/inter"
android:gravity="center_horizontal"
android:paddingTop="50dp"
android:paddingBottom="10dp"
android:text="@string/transaksi_baru"
android:textColor="@color/black"
android:textSize="25sp"
android:textStyle="bold"
android:visibility="gone"
tools:layout_editor_absoluteX="10dp"
tools:visibility="visible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -44,7 +44,7 @@
<EditText
android:id="@+id/id_judul"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="43dp"
android:layout_marginTop="2dp"
android:background="@color/light_gray"
android:inputType="text"
......@@ -67,10 +67,11 @@
<EditText
android:id="@+id/id_nominal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="2dp"
android:layout_height="43dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@color/light_gray"
android:inputType="textPassword"
android:inputType="numberDecimal"
android:hint="@string/nominal"
android:textColorHint="@color/light_gray"
android:autofillHints="no"
......@@ -87,17 +88,14 @@
android:layout_gravity="start"
android:text="@string/kategori" />
<EditText
<Spinner
android:id="@+id/id_kategori"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="43dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="8dp"
android:background="@color/light_gray"
android:inputType="text"
android:hint="@string/kategori"
android:textColorHint="@color/light_gray"
android:autofillHints="no"
android:maxLines="1" />
android:spinnerMode="dropdown" />
<TextView
android:layout_width="wrap_content"
......@@ -113,7 +111,7 @@
<EditText
android:id="@+id/id_lokasi"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="43dp"
android:layout_marginTop="2dp"
android:background="@color/light_gray"
android:inputType="text"
......@@ -134,6 +132,22 @@
android:textColor="@color/black"
android:background="@color/main_green"
android:text="@string/simpan" />
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_close"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="end|top"
android:layout_margin="16dp"
android:scaleType="center"
android:src="@drawable/ic_close"
android:tint="@android:color/white"
app:backgroundTint="@color/red"
app:borderWidth="0dp"
app:elevation="6dp"
app:maxImageSize="24dp" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recycler_view"
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"
android:padding="8dp"
android:clipToPadding="false"
android:background="@android:color/white"
android:scrollbars="vertical"/>
\ No newline at end of file
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:clipToPadding="false"
android:background="@android:color/white"
android:scrollbars="vertical"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_add"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:ignore="ContentDescription" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="kategori_options">["Pembelian", "Pemasukan"]</string-array>
</resources>
\ No newline at end of file
......@@ -9,4 +9,5 @@
<color name="white">#FFFFFFFF</color>
<color name="light_gray">#D9D9D9</color>
<color name="main_green">#A7F8DB</color>
<color name="red">#FF2313</color>
</resources>
\ No newline at end of file
......@@ -21,4 +21,5 @@
<string name="setting_button_3">Keluar</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="transaksi_baru">Transaksi Baru</string>
</resources>
\ No newline at end of file
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