feat: 휴가 관리 화면 구현 (휠 다이얼 연차 설정)
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -4,8 +4,11 @@ import android.os.Bundle
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.example.shiftalarm.databinding.FragmentSettingsLabBinding
|
import com.example.shiftalarm.databinding.FragmentSettingsLabBinding
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class FragmentSettingsLab : Fragment() {
|
class FragmentSettingsLab : Fragment() {
|
||||||
|
|
||||||
@@ -20,6 +23,56 @@ class FragmentSettingsLab : Fragment() {
|
|||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
setupNumberPicker()
|
||||||
|
loadAnnualLeave()
|
||||||
|
setupSaveButton()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupNumberPicker() {
|
||||||
|
binding.npTotalDays.apply {
|
||||||
|
minValue = 1
|
||||||
|
maxValue = 25
|
||||||
|
wrapSelectorWheel = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun loadAnnualLeave() {
|
||||||
|
lifecycleScope.launch {
|
||||||
|
val repo = ShiftRepository(requireContext())
|
||||||
|
|
||||||
|
val annualLeave = repo.getAnnualLeave()
|
||||||
|
annualLeave?.let {
|
||||||
|
binding.npTotalDays.value = it.totalDays.toInt()
|
||||||
|
binding.tvRemainingDays.text = String.format("%.1f", it.remainingDays)
|
||||||
|
} ?: run {
|
||||||
|
// Default: 15 days
|
||||||
|
binding.npTotalDays.value = 15
|
||||||
|
binding.tvRemainingDays.text = "15.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupSaveButton() {
|
||||||
|
binding.btnSaveAnnualLeave.setOnClickListener {
|
||||||
|
val totalDays = binding.npTotalDays.value.toFloat()
|
||||||
|
|
||||||
|
lifecycleScope.launch {
|
||||||
|
val repo = ShiftRepository(requireContext())
|
||||||
|
|
||||||
|
repo.recalculateAndSaveAnnualLeave(totalDays)
|
||||||
|
|
||||||
|
val updated = repo.getAnnualLeave()
|
||||||
|
updated?.let {
|
||||||
|
binding.tvRemainingDays.text = String.format("%.1f", it.remainingDays)
|
||||||
|
Toast.makeText(requireContext(), "연차가 저장되었습니다. (남은 연차: ${String.format("%.1f", it.remainingDays)}일)", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
_binding = null
|
_binding = null
|
||||||
|
|||||||
@@ -5,32 +5,124 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="24dp"
|
android:padding="24dp"
|
||||||
android:gravity="center">
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
<ImageView
|
<!-- Header Title -->
|
||||||
android:layout_width="80dp"
|
<TextView
|
||||||
android:layout_height="80dp"
|
android:layout_width="wrap_content"
|
||||||
android:src="@drawable/ic_settings"
|
android:layout_height="wrap_content"
|
||||||
app:tint="@color/text_tertiary"
|
android:text="나의 연차 설정"
|
||||||
android:layout_marginBottom="16dp"
|
android:textSize="20sp"
|
||||||
android:alpha="0.5"/>
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary"
|
||||||
|
android:layout_marginBottom="32dp"/>
|
||||||
|
|
||||||
|
<!-- Total Annual Leave Setting -->
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="24dp"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="4dp"
|
||||||
|
app:cardBackgroundColor="@color/surface">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="24dp"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="실험실 기능 준비 중"
|
android:text="총 연차"
|
||||||
android:textSize="18sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_secondary"
|
android:textColor="@color/text_secondary"
|
||||||
|
android:layout_marginBottom="16dp"/>
|
||||||
|
|
||||||
|
<!-- NumberPicker for Total Days -->
|
||||||
|
<NumberPicker
|
||||||
|
android:id="@+id/npTotalDays"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"/>
|
android:layout_marginBottom="8dp"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="더욱 편리한 기능을 개발하고 있습니다.\n다음 업데이트를 기대해 주세요!"
|
android:text="일"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@color/text_tertiary"
|
android:textColor="@color/text_tertiary"/>
|
||||||
android:gravity="center"
|
|
||||||
android:lineSpacingExtra="4dp"/>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<!-- Remaining Annual Leave Display -->
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="32dp"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="4dp"
|
||||||
|
app:cardBackgroundColor="@color/surface">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="24dp"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="남은 연차"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="@color/text_secondary"
|
||||||
|
android:layout_marginBottom="8dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvRemainingDays"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="0.0"
|
||||||
|
android:textSize="36sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/primary"
|
||||||
|
android:layout_marginBottom="4dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="일"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_tertiary"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<!-- Calculation Info -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="※ 연차: -1일 차감 / 반년: -0.5일 차감"
|
||||||
|
android:textSize="13sp"
|
||||||
|
android:textColor="@color/text_tertiary"
|
||||||
|
android:layout_marginBottom="24dp"
|
||||||
|
android:gravity="center"/>
|
||||||
|
|
||||||
|
<!-- Save Button -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnSaveAnnualLeave"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:text="저장"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:cornerRadius="12dp"
|
||||||
|
android:backgroundTint="@color/primary"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">shiftring</string>
|
<string name="app_name">Shift Alarm</string>
|
||||||
|
<string name="team_selection">Team selection</string>
|
||||||
|
<string name="current_shift">Current shift: %1$s</string>
|
||||||
|
<string name="next_shift">Next shift: %1$s</string>
|
||||||
|
<string name="alarm_status">Alarm Status</string>
|
||||||
|
<string name="company_selection">Company selection</string>
|
||||||
|
<string name="tab_basic">Basic Settings</string>
|
||||||
|
<string name="tab_alarm">Alarm Settings</string>
|
||||||
|
<string name="tab_additional">Extras</string>
|
||||||
|
<string name="tab_lab">Leave Management</string>
|
||||||
|
<string-array name="factory_array">
|
||||||
|
<item>Jeonju</item>
|
||||||
|
<item>Nonsan</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="team_array">
|
||||||
|
<item>A Team</item>
|
||||||
|
<item>B Team</item>
|
||||||
|
<item>C Team</item>
|
||||||
|
<item>D Team</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="theme_array">
|
||||||
|
<item>System Settings</item>
|
||||||
|
<item>Light</item>
|
||||||
|
<item>Dark</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<string name="tab_basic">기본 설정</string>
|
<string name="tab_basic">기본 설정</string>
|
||||||
<string name="tab_alarm">알람 설정</string>
|
<string name="tab_alarm">알람 설정</string>
|
||||||
<string name="tab_additional">부가기능</string>
|
<string name="tab_additional">부가기능</string>
|
||||||
<string name="tab_lab">실험실</string>
|
<string name="tab_lab">휴가 관리</string>
|
||||||
|
|
||||||
<string-array name="factory_array">
|
<string-array name="factory_array">
|
||||||
<item>전주</item>
|
<item>전주</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user