diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 76681df51c159d0b528184366473e086a2eeac95..74d3b9c72492c45911810944e8182d0970fda017 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -4,6 +4,17 @@ <value> <entry key="app"> <State> + <runningDeviceTargetSelectedWithDropDown> + <Target> + <type value="RUNNING_DEVICE_TARGET" /> + <deviceKey> + <Key> + <type value="VIRTUAL_DEVICE_PATH" /> + <value value="C:\Users\seres\.android\avd\Pixel_3a_API_34_extension_level_7_x86_64.avd" /> + </Key> + </deviceKey> + </Target> + </runningDeviceTargetSelectedWithDropDown> <targetSelectedWithDropDown> <Target> <type value="QUICK_BOOT_TARGET" /> @@ -15,7 +26,7 @@ </deviceKey> </Target> </targetSelectedWithDropDown> - <timeTargetWasSelectedWithDropDown value="2024-03-13T00:29:24.764409600Z" /> + <timeTargetWasSelectedWithDropDown value="2024-03-13T14:56:57.962285400Z" /> </State> </entry> </value> diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 09920437c93eaad1577d3fd81ff0c531c4ba9ae6..72324438a71a364b69d134d49f8c6684cd6e02e7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -18,6 +18,8 @@ android { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } + + buildTypes { release { isMinifyEnabled = false @@ -49,12 +51,15 @@ dependencies { implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1") implementation("androidx.navigation:navigation-fragment-ktx:2.3.5") implementation("androidx.navigation:navigation-ui-ktx:2.3.5") + implementation("androidx.compose.ui:ui-unit:1.0.1") implementation("nl.joery.animatedbottombar:library:1.1.0") implementation("com.squareup.retrofit2:retrofit:2.9.0") implementation("com.squareup.retrofit2:converter-gson:2.9.0") implementation("androidx.annotation:annotation:1.7.1") implementation("androidx.legacy:legacy-support-v4:1.0.0") + implementation("ir.mahozad.android:pie-chart:0.7.0") + testImplementation("junit:junit:4.13.2") //For runBlockingTest, CoroutineDispatcher etc. diff --git a/app/src/main/java/com/ssk/bondoman/MainActivity.kt b/app/src/main/java/com/ssk/bondoman/MainActivity.kt index 0ece24ee7d0f4eb279dc8c151b9eb53c0cff53d3..6cc656710f0ae82517bd309d95abe3c7002688cb 100644 --- a/app/src/main/java/com/ssk/bondoman/MainActivity.kt +++ b/app/src/main/java/com/ssk/bondoman/MainActivity.kt @@ -1,5 +1,6 @@ package com.ssk.bondoman +import android.content.pm.ActivityInfo import android.os.Bundle import android.view.Menu import androidx.appcompat.app.AppCompatActivity @@ -13,8 +14,8 @@ class MainActivity : AppCompatActivity() { private lateinit var navController: NavController override fun onCreate(savedInstanceState: Bundle?) { + this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); super.onCreate(savedInstanceState) - binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) diff --git a/app/src/main/java/com/ssk/bondoman/ui/graph/GraphFragment.kt b/app/src/main/java/com/ssk/bondoman/ui/graph/GraphFragment.kt index ad03607b419d0d7c785b4b33aca5ba5a17ab0f8d..913dbe03d545ca37c7fcc3cf60732fc8b19d7800 100644 --- a/app/src/main/java/com/ssk/bondoman/ui/graph/GraphFragment.kt +++ b/app/src/main/java/com/ssk/bondoman/ui/graph/GraphFragment.kt @@ -1,13 +1,20 @@ package com.ssk.bondoman.ui.graph +import android.content.pm.ActivityInfo +import android.graphics.Color import android.os.Bundle +import android.util.Log 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 androidx.compose.ui.unit.dp import com.ssk.bondoman.databinding.FragmentGraphBinding +import ir.mahozad.android.PieChart +import ir.mahozad.android.component.Wrapping +import ir.mahozad.android.unit.Dimension class GraphFragment : Fragment() { @@ -28,10 +35,33 @@ class GraphFragment : Fragment() { _binding = FragmentGraphBinding.inflate(inflater, container, false) val root: View = binding.root - val textView: TextView = binding.textGraph - graphViewModel.text.observe(viewLifecycleOwner) { - textView.text = it + //Pembelian && Penjualan + val textViewPembelian: TextView = binding.pembelian + val textViewPenjualan: TextView = binding.penjualan + + graphViewModel.textPembelian.observe(viewLifecycleOwner) { + textViewPembelian.text = "Pembelian: 60.000" // should change later according to DB + } + graphViewModel.textPenjualan.observe(viewLifecycleOwner) { + textViewPenjualan.text = "Penjualan: 40.000" // should change later according to DB + } + + //PieChart + val pieChart = binding.pieChart + + pieChart.slices = graphViewModel.TSGraph.value!! + graphViewModel.TSGraph.observe(viewLifecycleOwner) { another_slices -> + // Update slices when TSGraph changes + + pieChart.apply { +// layoutParams.width = Dimension.DP(400f).dp.toInt() +// layoutParams.height = Dimension.DP(400f).dp.toInt() + slices = another_slices + + } } + + return root } @@ -39,4 +69,17 @@ class GraphFragment : Fragment() { super.onDestroyView() _binding = null } + + override fun onResume() { + super.onResume() + getActivity()?.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); + + } + + override fun onPause(){ + super.onPause() + getActivity()?.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + } + + } \ No newline at end of file diff --git a/app/src/main/java/com/ssk/bondoman/ui/graph/GraphViewModel.kt b/app/src/main/java/com/ssk/bondoman/ui/graph/GraphViewModel.kt index 5bdeb2382320c8d8f56e4ad44e13f065ecf880a2..ae41f8faa9d833c30aea3a9c419e076d0a7dfece 100644 --- a/app/src/main/java/com/ssk/bondoman/ui/graph/GraphViewModel.kt +++ b/app/src/main/java/com/ssk/bondoman/ui/graph/GraphViewModel.kt @@ -1,13 +1,38 @@ package com.ssk.bondoman.ui.graph +import android.graphics.Color import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel +import ir.mahozad.android.PieChart +import ir.mahozad.android.PieChart.Slice class GraphViewModel : ViewModel() { - private val _text = MutableLiveData<String>().apply { - value = "This is graph Fragment" + private val _textPembelian = MutableLiveData<String>().apply { + value = "Pembelian: " + } + val textPembelian: LiveData<String> = _textPembelian + + private val _textPenjualan = MutableLiveData<String>().apply { + value = "Penjualan: " + } + val textPenjualan: LiveData<String> = _textPenjualan + + private val _TSGraph = MutableLiveData<List<Slice>>().apply{ + value = listOf( + Slice(0.4f, Color.BLUE), + Slice(0.6f, Color.CYAN) + ) + } + + val TSGraph : LiveData<List<Slice>> = _TSGraph + + fun getPurchaseAmount(value : Int) : String{ + return "Pembelian: $value" + } + + fun getSalesAmount(value : Int) : String{ + return "Penjualan: $value" } - val text: LiveData<String> = _text } \ No newline at end of file diff --git a/app/src/main/java/com/ssk/bondoman/ui/transaction/TransactionFragment.kt b/app/src/main/java/com/ssk/bondoman/ui/transaction/TransactionFragment.kt index 7614be98dcdfb5a5813d927471565880fb886b35..7e0b04898b68fb4821398a7f6026407ba6149d69 100644 --- a/app/src/main/java/com/ssk/bondoman/ui/transaction/TransactionFragment.kt +++ b/app/src/main/java/com/ssk/bondoman/ui/transaction/TransactionFragment.kt @@ -1,5 +1,6 @@ package com.ssk.bondoman.ui.transaction +import android.content.pm.ActivityInfo import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -25,6 +26,9 @@ class TransactionFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle? ): View { + // allow potrait and landscape mode in this fragment + + _binding = FragmentTransactionBinding.inflate(inflater, container, false) val root: View = binding.root @@ -50,8 +54,11 @@ class TransactionFragment : Fragment() { } } + override fun onDestroyView() { super.onDestroyView() _binding = null } + + } diff --git a/app/src/main/res/layout-land/activity_main.xml b/app/src/main/res/layout-land/activity_main.xml new file mode 100644 index 0000000000000000000000000000000000000000..8721f9e7e8d565da678cf7d8580d766c4946334b --- /dev/null +++ b/app/src/main/res/layout-land/activity_main.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<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:id="@+id/container" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingTop="?attr/actionBarSize"> + + <nl.joery.animatedbottombar.AnimatedBottomBar + android:id="@+id/nav_view" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="#FFF" + app:abb_indicatorAppearance="round" + app:abb_indicatorHeight="4dp" + app:abb_indicatorMargin="16dp" + app:abb_selectedIndex="0" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:abb_selectedTabType="text" + app:abb_textStyle="bold" + app:abb_tabs="@menu/bottom_nav_menu" /> + + + <fragment + android:id="@+id/nav_host_fragment_activity_main" + android:name="androidx.navigation.fragment.NavHostFragment" + android:layout_width="733dp" + android:layout_height="293dp" + android:visibility="visible" + app:defaultNavHost="true" + app:layout_constraintBottom_toTopOf="@id/nav_view" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.0" + app:navGraph="@navigation/mobile_navigation" + tools:ignore="FragmentTagUsage" /> + +</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_graph.xml b/app/src/main/res/layout-land/fragment_graph.xml new file mode 100644 index 0000000000000000000000000000000000000000..5b7f876b6d2aa16ef76d0fefb98635b7c0e7198b --- /dev/null +++ b/app/src/main/res/layout-land/fragment_graph.xml @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="utf-8"?> +<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"> + + + <LinearLayout + android:layout_width="248dp" + android:layout_height="141dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/linearLayout" + app:layout_constraintHorizontal_bias="0.462" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.131"> + + <ir.mahozad.android.PieChart + android:id="@+id/pie_chart" + android:layout_width="279dp" + android:layout_height="match_parent" + android:layout_weight="1" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.431" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/linearLayout" + android:layout_width="228dp" + android:layout_height="153dp" + android:layout_marginEnd="100dp" + android:orientation="vertical" + android:padding="16dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.064"> + + <LinearLayout + android:layout_width="196dp" + android:layout_height="51dp" + android:orientation="horizontal" + android:padding="16dp"> + + <View + android:layout_width="11dp" + android:layout_height="10dp" + android:layout_marginStart="8dp" + android:background="#FF0000FF" /> + + <!-- Teks "Pembelian" --> + <TextView + android:id="@+id/pembelian" + android:layout_width="122dp" + android:layout_height="22dp" + android:layout_marginStart="8dp" + android:text="Pembelian" + android:textColor="@android:color/black" + android:textSize="12sp" /> + </LinearLayout> + + <LinearLayout + android:layout_width="198dp" + android:layout_height="47dp" + android:orientation="horizontal" + android:padding="16dp"> + + <View + android:layout_width="6dp" + android:layout_height="10dp" + android:layout_marginStart="8dp" + android:background="#FF00FFFF" /> + + <!-- Teks "Penjualan" --> + <TextView + android:id="@+id/penjualan" + android:layout_width="122dp" + android:layout_height="22dp" + android:layout_marginStart="8dp" + android:text="Penjualan: 60000" + android:textColor="@android:color/black" + android:textSize="12sp" /> + + </LinearLayout> + + + </LinearLayout> + +</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_transaction.xml b/app/src/main/res/layout-land/fragment_transaction.xml new file mode 100644 index 0000000000000000000000000000000000000000..cabcd1e416c4bf104064377a5c41cf844ac39806 --- /dev/null +++ b/app/src/main/res/layout-land/fragment_transaction.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<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.transaction.TransactionFragment"> + + + <TextView + android:id="@+id/text_transaction" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:layout_marginEnd="8dp" + android:text="Daftar Transaksi" + android:textAlignment="center" + android:textSize="20sp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.0" /> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/transaction_list" + android:layout_width="494dp" + android:layout_height="268dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.497" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/text_transaction" + app:layout_constraintVertical_bias="0.333" /> + + +</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ecb504c8163145f0cd4b19c2282193302e2e65b4..43bea8cc7bdd190ee67d86b3ec6438593f4975e2 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -29,11 +29,14 @@ android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" + android:visibility="visible" app:defaultNavHost="true" app:layout_constraintBottom_toTopOf="@id/nav_view" + app:layout_constraintHorizontal_bias="0.0" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.0" app:navGraph="@navigation/mobile_navigation" tools:ignore="FragmentTagUsage" /> diff --git a/app/src/main/res/layout/fragment_graph.xml b/app/src/main/res/layout/fragment_graph.xml index 54053eed4448bd44ec27178a235b2435bc7e12f4..d5c9d2bc1603099c0d5d44384df2dac3154651ca 100644 --- a/app/src/main/res/layout/fragment_graph.xml +++ b/app/src/main/res/layout/fragment_graph.xml @@ -6,17 +6,75 @@ android:layout_height="match_parent" tools:context=".ui.graph.GraphFragment"> - <TextView - android:id="@+id/text_graph" + <ir.mahozad.android.PieChart + android:id="@+id/pie_chart" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="80dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:layout_marginEnd="8dp" - android:textAlignment="center" - android:textSize="20sp" + android:orientation="vertical" + android:padding="16dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toBottomOf="@+id/pie_chart" + app:layout_constraintVertical_bias="0.141"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:padding="16dp"> + + <View + android:layout_width="11dp" + android:layout_height="10dp" + android:layout_marginStart="8dp" + android:background="#FF0000FF" /> + + <!-- Teks "Pembelian" --> + <TextView + android:id="@+id/pembelian" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:text="Pembelian" + android:textColor="@android:color/black" + android:textSize="18sp" /> + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:padding="16dp"> + <!-- Kotak kosong dengan latar belakang biru --> + + <!-- Teks "Penjualan" --> + <View + android:layout_width="10dp" + android:layout_height="10dp" + android:layout_marginStart="8dp" + android:background="#FF00FFFF" /> + + <TextView + android:id="@+id/penjualan" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:text="Penjualan" + android:textColor="@android:color/black" + android:textSize="18sp" /> + </LinearLayout> + + + </LinearLayout> + </androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_transaction.xml b/app/src/main/res/layout/fragment_transaction.xml index 9e255384e048a6b78e3fdedd2de81de14a81290e..bd90562cd10fb1dc94e352ec0e2867d719767246 100644 --- a/app/src/main/res/layout/fragment_transaction.xml +++ b/app/src/main/res/layout/fragment_transaction.xml @@ -26,8 +26,8 @@ <androidx.recyclerview.widget.RecyclerView android:id="@+id/transaction_list" - android:layout_width="348dp" - android:layout_height="390dp" + android:layout_width="339dp" + android:layout_height="539dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.492"