aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsHomePageAdapter.kt36
-rw-r--r--Client/BrzoDoLokacije/app/src/main/res/layout/post_item_home_page.xml50
-rw-r--r--Client/BrzoDoLokacije/app/src/main/res/values/styles.xml7
3 files changed, 93 insertions, 0 deletions
diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsHomePageAdapter.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsHomePageAdapter.kt
new file mode 100644
index 0000000..c5bdcb3
--- /dev/null
+++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsHomePageAdapter.kt
@@ -0,0 +1,36 @@
+package com.example.brzodolokacije.Adapters
+
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.TextView
+import androidx.core.net.toUri
+import androidx.recyclerview.widget.RecyclerView
+import com.example.brzodolokacije.Models.PostPreview
+import com.example.brzodolokacije.R
+
+class ShowPopularPostsAdapter(var postPreview:MutableList<PostPreview>):
+ RecyclerView.Adapter<PostViewHolder>() {
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PostViewHolder {
+ val view=LayoutInflater.from(parent.context).inflate(R.layout.post_item_home_page,parent,false)
+ return PostViewHolder(view)
+ }
+
+ override fun onBindViewHolder(holder: PostViewHolder, position: Int) {
+ return holder.bindView(postPreview[position] )
+ }
+
+ override fun getItemCount(): Int {
+ return postPreview.size
+ }
+
+}
+class PostViewHolder(view: View):RecyclerView.ViewHolder(view){
+ private val background:com.google.android.material.imageview.ShapeableImageView=view.findViewById(R.id.ivPIHPBackground)
+ private val locationName:TextView=view.findViewById(R.id.tvPIHPLocationName)
+
+ fun bindView(postPreview:PostPreview){
+ background.setImageURI(postPreview.images[0]._id.toUri())
+ locationName.text=postPreview.location.name
+ }
+} \ No newline at end of file
diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/post_item_home_page.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/post_item_home_page.xml
new file mode 100644
index 0000000..04515c0
--- /dev/null
+++ b/Client/BrzoDoLokacije/app/src/main/res/layout/post_item_home_page.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <com.google.android.material.imageview.ShapeableImageView
+ android:id="@+id/ivPIHPBackground"
+ android:layout_width="0dp"
+ android:layout_height="390dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginEnd="8dp"
+ android:layout_marginBottom="8dp"
+ android:scaleType="fitXY"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:shapeAppearanceOverlay="@style/imageViewCircle"
+ app:srcCompat="@drawable/b1" />
+
+ <com.google.android.material.imageview.ShapeableImageView
+ android:id="@+id/ivPIHPMenu"
+ android:layout_width="match_parent"
+ android:layout_height="70dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="8dp"
+ app:layout_constraintBottom_toBottomOf="@+id/ivPIHPBackground"
+ app:layout_constraintEnd_toEndOf="@+id/ivPIHPBackground"
+
+ app:layout_constraintStart_toStartOf="@+id/ivPIHPBackground"
+ app:shapeAppearanceOverlay="@style/roundedBottom"
+ app:srcCompat="@color/dark_blue_transparent" />
+
+ <TextView
+ android:id="@+id/tvPIHPLocationName"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="52dp"
+ android:layout_marginTop="8dp"
+ android:text="TextView"
+ android:textSize="20dp"
+ android:textColor="@color/white"
+ app:layout_constraintStart_toStartOf="@+id/ivPIHPMenu"
+ app:layout_constraintTop_toTopOf="@+id/ivPIHPMenu" />
+
+
+</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file
diff --git a/Client/BrzoDoLokacije/app/src/main/res/values/styles.xml b/Client/BrzoDoLokacije/app/src/main/res/values/styles.xml
index 2dee0ab..798c013 100644
--- a/Client/BrzoDoLokacije/app/src/main/res/values/styles.xml
+++ b/Client/BrzoDoLokacije/app/src/main/res/values/styles.xml
@@ -10,4 +10,11 @@
<item name="cornerSize">15dp</item>
<item name="color">@color/white</item>
</style>
+ <style name="Circular">
+ <item name="cornerSize">20%</item>
+ </style>
+ <style name="roundedBottom">
+ <item name="cornerSizeBottomLeft">70dp</item>
+ <item name="cornerSizeBottomRight">70dp</item>
+ </style>
</resources> \ No newline at end of file