feat(categoryCreate): Add UI layout

This commit is contained in:
Peter Vacho 2025-01-04 23:43:05 +01:00
parent bc72deeaf6
commit 4dc468ff2b
Signed by: school
GPG key ID: 8CFC3837052871B4
4 changed files with 82 additions and 5 deletions

View file

@ -16,3 +16,8 @@ data class CategoryResponse(
val owner_user_id: String,
val created_at: OffsetDateTime
): Parcelable
data class CategoryRequest(
val name: String,
val color: Color,
)

View file

@ -1,8 +1,11 @@
package com.p_vacho.neat_calendar.api.services
import com.p_vacho.neat_calendar.api.models.CategoryRequest
import com.p_vacho.neat_calendar.api.models.CategoryResponse
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
interface CategoryService {
@ -15,6 +18,9 @@ interface CategoryService {
@GET("/categories/{category_id}")
suspend fun getCategory(@Path("category_id") categoryId: String): CategoryResponse
@POST("/categories")
suspend fun createCategory(@Body categoryData: CategoryRequest): CategoryResponse
@DELETE("/categories/{category_id}")
suspend fun deleteCategory(@Path("category_id") categoryId: String): Unit
}

View file

@ -1,10 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout
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/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.CreateCategoryActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="16dp"
android:padding="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="4dp">
<LinearLayout
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<!-- Category Name -->
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/category_name"
app:boxStrokeWidth="1dp"
app:boxStrokeColor="?attr/colorPrimary">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etCategoryName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
tools:text="Work" />
</com.google.android.material.textfield.TextInputLayout>
<!-- Color Picker -->
<com.google.android.material.button.MaterialButton
android:id="@+id/btnColorPicker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/select_color"
app:icon="@drawable/ic_circle"
app:iconTint="@android:color/holo_blue_dark"
app:cornerRadius="8dp"
style="@style/Widget.MaterialComponents.Button.OutlinedButton" />
<!-- Save Button -->
<com.google.android.material.button.MaterialButton
android:id="@+id/btnSaveCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/save"
app:cornerRadius="8dp" />
<!-- Cancel Button -->
<com.google.android.material.button.MaterialButton
android:id="@+id/btnCancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/cancel"
app:icon="@drawable/ic_arrow_back"
app:iconGravity="textStart"
app:iconPadding="8dp"
style="@style/Widget.MaterialComponents.Button.OutlinedButton" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</FrameLayout>

View file

@ -85,4 +85,5 @@
<string name="categories">Categories</string>
<string name="delete_category">Delete category</string>
<string name="event_details">Event Details</string>
<string name="category_name">Category Name</string>
</resources>