dola 10 месяцев назад
Родитель
Сommit
251bfb02b5

+ 61 - 0
app/src/main/java/com/sambath/kunkhmer/screen/news/HighlightAdminFragment.kt

@@ -0,0 +1,61 @@
+package com.sambath.kunkhmer.screen.news
+
+import android.app.DatePickerDialog
+import android.os.Bundle
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import com.sambath.kunkhmer.R
+import kotlinx.android.synthetic.main.fragment_fighter_admin.view.et_date
+import kotlinx.android.synthetic.main.fragment_highlight_admin.view.til_date
+import java.text.SimpleDateFormat
+import java.util.Calendar
+
+class HighlightAdminFragment : Fragment() {
+    private var _root: View? = null
+    private val binding get() = _root!!
+
+    private val calendar = Calendar.getInstance()
+    private val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+0000")
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+    }
+
+    override fun onCreateView(
+        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
+    ): View? {
+        // Inflate the layout for this fragment
+        _root = inflater.inflate(R.layout.fragment_highlight_admin, container, false)
+
+        binding.til_date.setOnClickListener {
+            showDatePickerDialog()
+        }
+
+        return binding
+    }
+
+    private fun showDatePickerDialog() {
+        val year = calendar.get(Calendar.YEAR)
+        val month = calendar.get(Calendar.MONTH)
+        val day = calendar.get(Calendar.DAY_OF_MONTH)
+
+        val datePickerDialog = DatePickerDialog(
+            requireContext(),
+            DatePickerDialog.OnDateSetListener { view, year, monthOfYear, dayOfMonth ->
+                // Update the calendar with the selected date
+                calendar.set(year, monthOfYear, dayOfMonth)
+
+                // Format the selected date and update the EditText text
+                val formattedDate = dateFormat.format(calendar.time)
+                binding.til_date.setText(formattedDate)
+            },
+            year,
+            month,
+            day
+        )
+
+        datePickerDialog.show()
+    }
+}

+ 5 - 0
app/src/main/java/com/sambath/kunkhmer/screen/news/NewsAdminFragment.kt

@@ -22,6 +22,7 @@ import kotlinx.android.synthetic.main.fragment_news_admin.view.submitButton
 import kotlinx.android.synthetic.main.fragment_news_admin.view.uploadButton
 import kotlinx.android.synthetic.main.fragment_news_admin.view.uploadedImageView
 import androidx.navigation.findNavController
+import kotlinx.android.synthetic.main.fragment_news_admin.view.create_highlight
 import kotlinx.android.synthetic.main.fragment_news_admin.view.til_title
 
 class NewsAdminFragment : Fragment() {
@@ -69,6 +70,10 @@ class NewsAdminFragment : Fragment() {
         binding.et_title.setText("Theara predicts elbow-driven victory, claims world Kun Khmer title")
         binding.et_desc.setText("Top fighter")
 
+        binding.create_highlight.setOnClickListener {
+            requireActivity().findNavController(R.id.nav_host_fragment_activity_main).navigate(R.id.navigation_create_highlight)
+        }
+
         return binding;
     }
 

+ 74 - 0
app/src/main/res/layout/fragment_highlight_admin.xml

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/color_black"
+    android:orientation="vertical"
+    android:padding="10dp">
+
+    <com.google.android.material.textfield.TextInputLayout
+        android:id="@+id/til_title"
+        style="@style/BoxInputLayout"
+        android:layout_width="match_parent"
+        android:layout_height="48dp"
+        android:layout_below="@id/tv_username"
+        app:endIconMode="clear_text"
+        app:hintEnabled="false">
+
+        <androidx.appcompat.widget.AppCompatEditText
+            android:id="@+id/et_title"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="@color/color_white"
+            android:hint="@string/hint_title"
+            android:inputType="text"
+            android:maxLength="50"
+            android:padding="0dp" />
+    </com.google.android.material.textfield.TextInputLayout>
+
+    <TextView
+        android:id="@+id/til_date"
+        style="@style/BoxInputLayout"
+        android:layout_width="match_parent"
+        android:layout_height="48dp"
+        android:background="@color/color_white"
+        android:gravity="center_vertical"
+        android:padding="15dp"
+        android:text="@string/hint_date"
+        app:endIconMode="clear_text" />
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:background="@color/color_gray_600" />
+
+    <com.google.android.material.textfield.TextInputLayout
+        android:id="@+id/til_url"
+        style="@style/BoxInputLayout"
+        android:layout_width="match_parent"
+        android:layout_height="48dp"
+        app:endIconMode="clear_text"
+        app:hintEnabled="false">
+
+        <androidx.appcompat.widget.AppCompatEditText
+            android:id="@+id/et_url"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="@color/color_white"
+            android:hint="@string/url"
+            android:inputType="text"
+            android:maxLength="50"
+            android:padding="0dp" />
+    </com.google.android.material.textfield.TextInputLayout>
+
+    <Button
+        android:id="@+id/submitButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:paddingStart="16dp"
+        android:paddingEnd="16dp"
+        android:text="Submit" />
+
+</LinearLayout>

+ 9 - 0
app/src/main/res/layout/fragment_news_admin.xml

@@ -75,4 +75,13 @@
         android:paddingStart="16dp"
         android:paddingEnd="16dp"
         android:text="Submit" />
+    <TextView
+        android:id="@+id/create_highlight"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:layout_marginTop="10dp"
+        android:padding="5dp"
+        android:text="Create Highlight"
+        android:textColor="@color/color_white" />
 </LinearLayout>

+ 6 - 0
app/src/main/res/navigation/mobile_navigation.xml

@@ -47,4 +47,10 @@
         android:label="@string/create_fighter"
         tools:layout="@layout/fragment_create_fighter"/>
 
+    <fragment
+        android:id="@+id/navigation_create_highlight"
+        android:name="com.sambath.kunkhmer.screen.news.HighlightAdminFragment"
+        android:label="@string/create_highlight"
+        tools:layout="@layout/fragment_highlight_admin"/>
+
 </navigation>

+ 5 - 0
app/src/main/res/navigation/mobile_navigation_admin.xml

@@ -48,4 +48,9 @@
         tools:layout="@layout/fragment_create_fighter"/>
 
 
+    <fragment
+        android:id="@+id/navigation_create_highlight"
+        android:name="com.sambath.kunkhmer.screen.news.HighlightAdminFragment"
+        android:label="@string/create_highlight"
+        tools:layout="@layout/fragment_highlight_admin"/>
 </navigation>

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -112,4 +112,6 @@
     <string name="height">Height</string>
     <string name="nationality">Nationality</string>
     <string name="hint_status">Status</string>
+    <string name="create_highlight">Create Highlight</string>
+    <string name="url">URL</string>
 </resources>