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 2 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.

39 changes: 39 additions & 0 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.

6 changes: 6 additions & 0 deletions .idea/vcs.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
75 changes: 15 additions & 60 deletions app/src/main/java/com/example/posyandu/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,73 +1,28 @@
package com.example.posyandu

import androidx.appcompat.app.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
import androidx.appcompat.app.AppCompatActivity

companion object {
private const val STATE_RESULT = "state_result"
}
class MainActivity : AppCompatActivity() {

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)
setContentView(R.layout.activity_login_bidan)

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

// Your initialization code goes here

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putString(STATE_RESULT, tvResult.text.toString())
}
// Example: Accessing a view from the layout
// val myTextView = findViewById<TextView>(R.id.my_text_view)
// myTextView.text = "Hello, Kotlin!"

// Example: Setting up a click listener for a button
// val myButton = findViewById<Button>(R.id.my_button)
// myButton.setOnClickListener {
// // Handle button click
// }
}

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"
}

if (inputWidth.isEmpty()) {
isEmptyFields = true
editWidth.error = "Lebar tidak boleh kosong"
}

if (inputHeight.isEmpty()) {
isEmptyFields = true
editHeight.error = "Tinggi tidak boleh kosong"
}
// Add other lifecycle methods and functions as needed

if (!isEmptyFields) {
val volume = inputLength.toDouble() * inputWidth.toDouble() * inputHeight.toDouble()
tvResult.text = volume.toString()
}
}
}
}
}
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