Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Morit #2

Merged
merged 5 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 5 additions & 12 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.example.posyandu

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
94 changes: 53 additions & 41 deletions app/src/main/java/com/example/posyandu/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,61 +1,73 @@
package com.example.posyandu

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.example.posyandu.ChatFragment
import com.example.posyandu.HomeFragment
import com.example.posyandu.MateriFragment
import com.example.posyandu.PosyanduFragment
import com.example.posyandu.ProfileFragment
import com.example.posyandu.R
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.navigation.NavigationBarView

class MainActivity : AppCompatActivity() {
import android.os.Bundle
import android.os.PersistableBundle
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.TextView

class MainActivity : AppCompatActivity(), View.OnClickListener {
private lateinit var editWidth: EditText
private lateinit var editHeight: EditText
private lateinit var editLength: EditText
private lateinit var btnCalculate: Button
private lateinit var tvResult: TextView

companion object {
private const val STATE_RESULT = "state_result"
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
editWidth = findViewById(R.id.edit_width)
editHeight = findViewById(R.id.edit_height)
editLength = findViewById(R.id.edit_length)
btnCalculate = findViewById(R.id.btn_calculate)
tvResult = findViewById(R.id.tv_result)
btnCalculate.setOnClickListener(this)

if (savedInstanceState != null) {
val result = savedInstanceState.getString(STATE_RESULT)
tvResult.text = result
}
}

val bottomNav = findViewById<BottomNavigationView>(R.id.bottom_navigation)
bottomNav.selectedItemId = R.id.home
bottomNav.setOnItemSelectedListener(navListener)

// as soon as the application opens the first fragment should
// be shown to the user in this case it is algorithm fragment
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, HomeFragment()).commit()
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putString(STATE_RESULT, tvResult.text.toString())
}

private val navListener = NavigationBarView.OnItemSelectedListener {
// By using switch we can easily get the
// selected fragment by using there id
lateinit var selectedFragment: Fragment
when (it.itemId) {
R.id.materi -> {
selectedFragment = MateriFragment()
}

R.id.chat -> {
selectedFragment = ChatFragment()
override fun onClick(view: View?) {
if (view?.id == R.id.btn_calculate) {
val inputLength = editLength.text.toString().trim()
val inputWidth = editWidth.text.toString().trim()
val inputHeight = editHeight.text.toString().trim()
var isEmptyFields = false

if (inputLength.isEmpty()) {
isEmptyFields = true
editLength.error = "Panjang tidak boleh kosong"
}

R.id.home -> {
selectedFragment = HomeFragment()
if (inputWidth.isEmpty()) {
isEmptyFields = true
editWidth.error = "Lebar tidak boleh kosong"
}

R.id.posyandu -> {
selectedFragment = PosyanduFragment()
if (inputHeight.isEmpty()) {
isEmptyFields = true
editHeight.error = "Tinggi tidak boleh kosong"
}

R.id.profile -> {
selectedFragment = ProfileFragment()
if (!isEmptyFields) {
val volume = inputLength.toDouble() * inputWidth.toDouble() * inputHeight.toDouble()
tvResult.text = volume.toString()
}
}
// It will help to replace the
// one fragment to other.
supportFragmentManager.beginTransaction().replace(R.id.fragment_container, selectedFragment)
.commit()
true
}
}
}
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/button_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- res/drawable/rounded_button_background.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="12dp" /> <!-- Adjust the radius as needed for the desired roundness -->
<solid android:color="#000000" /> <!-- Set the background color -->
</shape>
Binary file added app/src/main/res/drawable/ilustrasi_bidan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ilustrasi_remaja.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/mail_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/pass_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- res/drawable/rounded_text_input_layout_background.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/white" />
<corners android:radius="14dp" /> <!-- Adjust the radius as needed for the desired roundness -->
<stroke android:color="#CCCCCC" android:width="1dp" /> <!-- Border color and width -->
</shape>
100 changes: 100 additions & 0 deletions app/src/main/res/layout/activity_login_bidan.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingHorizontal="20dp"
android:paddingVertical="14dp">

<TextView
android:id="@+id/loginTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter_bold"
android:text="Login Sebagai Bidan"
android:textSize="20sp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="14dp"
/>

<ImageView
android:id="@+id/imageBidan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ilustrasi_bidan"
app:layout_constraintTop_toBottomOf="@+id/loginTitle"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginVertical="32dp"
/>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/usernameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/imageBidan"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginVertical="20dp"
android:hint="Username"
app:boxCornerRadiusBottomStart="12dp"
app:boxCornerRadiusBottomEnd="12dp"
app:boxCornerRadiusTopEnd="12dp"
app:boxCornerRadiusTopStart="12dp"
>
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/passwordInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="20dp"
app:boxCornerRadiusBottomStart="12dp"
app:boxCornerRadiusBottomEnd="12dp"
app:boxCornerRadiusTopEnd="12dp"
app:boxCornerRadiusTopStart="12dp"
android:hint="Password"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/usernameInput"
app:passwordToggleEnabled="true">

<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"/>
</com.google.android.material.textfield.TextInputLayout>

<TextView
android:id="@+id/hyperlinkLupaPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lupa Password?"
android:autoLink="web"
android:linksClickable="true"
app:layout_constraintTop_toBottomOf="@+id/passwordInput"
app:layout_constraintEnd_toEndOf="@+id/passwordInput"
android:paddingVertical="14dp"
/>



<com.google.android.material.button.MaterialButton
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cornerRadius="12dp"
android:text="Login"
app:layout_constraintTop_toBottomOf="@+id/hyperlinkLupaPassword"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:background="@drawable/button_background"
android:fontFamily="@font/inter_bold"
android:textSize="14sp"/>

</androidx.constraintlayout.widget.ConstraintLayout>
Loading